use of joynr.MulticastSubscriptionRequest in project joynr by bmwcarit.
the class DispatcherImpl method sendSubscriptionRequest.
// CHECKSTYLE:ON
@Override
public void sendSubscriptionRequest(String fromParticipantId, Set<DiscoveryEntryWithMetaInfo> toDiscoveryEntries, SubscriptionRequest subscriptionRequest, MessagingQos messagingQos) {
for (DiscoveryEntryWithMetaInfo toDiscoveryEntry : toDiscoveryEntries) {
MutableMessage message = messageFactory.createSubscriptionRequest(fromParticipantId, toDiscoveryEntry.getParticipantId(), subscriptionRequest, messagingQos);
message.setLocalMessage(toDiscoveryEntry.getIsLocal());
if (subscriptionRequest instanceof MulticastSubscriptionRequest) {
String multicastId = ((MulticastSubscriptionRequest) subscriptionRequest).getMulticastId();
messageRouter.addMulticastReceiver(multicastId, fromParticipantId, toDiscoveryEntry.getParticipantId());
}
logger.debug("Send SubscriptionRequest: subscriptionId: {}, messageId: {}, proxy participantId: {}, provider participantId: {}", subscriptionRequest.getSubscriptionId(), message.getId(), fromParticipantId, toDiscoveryEntry.getParticipantId());
messageSender.sendMessage(message);
}
}
use of joynr.MulticastSubscriptionRequest in project joynr by bmwcarit.
the class SubscriptionManagerImpl method registerMulticastSubscription.
@Override
public void registerMulticastSubscription(String fromParticipantId, Set<DiscoveryEntryWithMetaInfo> toDiscoveryEntries, final MulticastSubscribeInvocation multicastSubscribeInvocation) {
for (DiscoveryEntryWithMetaInfo toDiscoveryEntry : toDiscoveryEntries) {
final String multicastId = MulticastIdUtil.createMulticastId(toDiscoveryEntry.getParticipantId(), multicastSubscribeInvocation.getSubscriptionName(), multicastSubscribeInvocation.getPartitions());
logger.debug("SUBSCRIPTION call proxy: subscriptionId: {}, multicastId: {}, broadcast: {}, qos: {}," + " proxy participantId: {}, provider participantId: {}", multicastSubscribeInvocation.getSubscriptionId(), multicastId, multicastSubscribeInvocation.getSubscriptionName(), multicastSubscribeInvocation.getQos(), fromParticipantId, toDiscoveryEntry.getParticipantId());
registerSubscription(fromParticipantId, toDiscoveryEntries, multicastSubscribeInvocation, new RegisterDataAndCreateSubscriptionRequest() {
@Override
public SubscriptionRequest execute() {
String subscriptionId = multicastSubscribeInvocation.getSubscriptionId();
logger.trace("Multicast subscription registered with Id: " + subscriptionId);
Pattern multicastIdPattern = multicastWildcardRegexFactory.createIdPattern(multicastId);
if (!multicastSubscribersDirectory.containsKey(multicastIdPattern)) {
multicastSubscribersDirectory.putIfAbsent(multicastIdPattern, Sets.<String>newHashSet());
}
multicastSubscribersDirectory.get(multicastIdPattern).add(subscriptionId);
multicastBroadcastTypes.putIfAbsent(multicastIdPattern, multicastSubscribeInvocation.getOutParameterTypes());
broadcastSubscriptionListenerDirectory.put(subscriptionId, multicastSubscribeInvocation.getListener());
return new MulticastSubscriptionRequest(multicastId, multicastSubscribeInvocation.getSubscriptionId(), multicastSubscribeInvocation.getSubscriptionName(), multicastSubscribeInvocation.getQos());
}
});
}
}
use of joynr.MulticastSubscriptionRequest in project joynr by bmwcarit.
the class DispatcherImplTest method testReceiveMulticastSubscription.
@Test
public void testReceiveMulticastSubscription() throws Exception {
String from = "from";
String to = "to";
MulticastSubscriptionRequest subscriptionRequest = new MulticastSubscriptionRequest("multicastId", "subscriptionId", "multicastName", new OnChangeSubscriptionQos());
MutableMessage joynrMessage = messageFactory.createSubscriptionRequest(from, to, subscriptionRequest, new MessagingQos(1000L));
MutableMessageFactory messageFactoryMock = mock(MutableMessageFactory.class);
ObjectMapper objectMapperMock = mock(ObjectMapper.class);
when(objectMapperMock.readValue(anyString(), eq(SubscriptionRequest.class))).thenReturn(subscriptionRequest);
fixture = new DispatcherImpl(requestReplyManagerMock, subscriptionManagerMock, publicationManagerMock, messageRouterMock, messageSenderMock, messageFactoryMock, objectMapperMock);
fixture.messageArrived(joynrMessage.getImmutableMessage());
verify(publicationManagerMock).addSubscriptionRequest(eq(from), eq(to), eq(subscriptionRequest));
}
use of joynr.MulticastSubscriptionRequest in project joynr by bmwcarit.
the class MutableMessageFactory method createSubscriptionRequest.
public MutableMessage createSubscriptionRequest(String fromParticipantId, String toParticipantId, SubscriptionRequest subscriptionRequest, MessagingQos messagingQos) {
String messageType;
if (subscriptionRequest instanceof BroadcastSubscriptionRequest) {
messageType = Message.VALUE_MESSAGE_TYPE_BROADCAST_SUBSCRIPTION_REQUEST;
} else if (subscriptionRequest instanceof MulticastSubscriptionRequest) {
messageType = Message.VALUE_MESSAGE_TYPE_MULTICAST_SUBSCRIPTION_REQUEST;
} else {
messageType = Message.VALUE_MESSAGE_TYPE_SUBSCRIPTION_REQUEST;
}
MutableMessage msg = createMessage(messageType, fromParticipantId, toParticipantId, subscriptionRequest, messagingQos);
addRequestReplyIdCustomHeader(msg, subscriptionRequest.getSubscriptionId());
return msg;
}
use of joynr.MulticastSubscriptionRequest in project joynr by bmwcarit.
the class MutableMessageFactoryTest method testCreateMulticastSubscriptionRequest.
@Test
public void testCreateMulticastSubscriptionRequest() {
String multicastId = "multicastId";
String subscriptionId = "subscriptionId";
String multicastName = "multicastName";
SubscriptionQos subscriptionQos = mock(SubscriptionQos.class);
MulticastSubscriptionRequest multicastSubscriptionRequest = new MulticastSubscriptionRequest(multicastId, subscriptionId, multicastName, subscriptionQos);
MutableMessage result = mutableMessageFactory.createSubscriptionRequest(fromParticipantId, toParticipantId, multicastSubscriptionRequest, messagingQos);
assertNotNull(result);
assertEquals(Message.VALUE_MESSAGE_TYPE_MULTICAST_SUBSCRIPTION_REQUEST, result.getType());
assertExpiryDateEquals(expiryDate.getValue(), result);
}
Aggregations