use of joynr.SubscriptionReply in project joynr by bmwcarit.
the class PublicationManagerImpl method handleMulticastSubscriptionRequest.
private void handleMulticastSubscriptionRequest(String proxyParticipantId, String providerParticipantId, MulticastSubscriptionRequest subscriptionRequest, ProviderContainer providerContainer) {
logger.trace("Received multicast subscription request {} for provider with participant ID {}", subscriptionRequest, providerParticipantId);
dispatcher.sendSubscriptionReply(providerParticipantId, proxyParticipantId, new SubscriptionReply(subscriptionRequest.getSubscriptionId()), createMessagingQos(subscriptionRequest.getQos()));
}
use of joynr.SubscriptionReply in project joynr by bmwcarit.
the class SubscriptionManagerTest method testHandleSubscriptionReplyWithSuccessWithBroadcastListener.
@Test
public void testHandleSubscriptionReplyWithSuccessWithBroadcastListener() {
SubscriptionReply subscriptionReply = new SubscriptionReply(subscriptionId);
@SuppressWarnings("unchecked") Future<String> futureMock = mock(Future.class);
subscriptionFutureMap.put(subscriptionId, futureMock);
BroadcastSubscriptionListener broadcastListener = mock(BroadcastSubscriptionListener.class);
broadcastSubscriptionDirectory.put(subscriptionId, broadcastListener);
subscriptionManager.handleSubscriptionReply(subscriptionReply);
verify(futureMock).onSuccess(eq(subscriptionId));
verify(broadcastListener).onSubscribed(eq(subscriptionId));
}
use of joynr.SubscriptionReply in project joynr by bmwcarit.
the class SubscriptionManagerTest method testHandleSubscriptionReplyWithErrorWithSubscriptionListener.
@Test
public void testHandleSubscriptionReplyWithErrorWithSubscriptionListener() {
SubscriptionException subscriptionError = new SubscriptionException(subscriptionId);
SubscriptionReply subscriptionReply = new SubscriptionReply(subscriptionId, subscriptionError);
@SuppressWarnings("unchecked") Future<String> futureMock = mock(Future.class);
subscriptionFutureMap.put(subscriptionId, futureMock);
AttributeSubscriptionListener<?> subscriptionListener = mock(AttributeSubscriptionListener.class);
attributeSubscriptionDirectory.put(subscriptionId, subscriptionListener);
subscriptionManager.handleSubscriptionReply(subscriptionReply);
verify(futureMock).onFailure(eq(subscriptionError));
verify(subscriptionListener).onError(eq(subscriptionError));
}
use of joynr.SubscriptionReply in project joynr by bmwcarit.
the class SubscriptionManagerTest method testHandleSubscriptionReplyWithErrorWithBroadcastListener.
@Test
public void testHandleSubscriptionReplyWithErrorWithBroadcastListener() {
SubscriptionException subscriptionError = new SubscriptionException(subscriptionId);
SubscriptionReply subscriptionReply = new SubscriptionReply(subscriptionId, subscriptionError);
@SuppressWarnings("unchecked") Future<String> futureMock = mock(Future.class);
subscriptionFutureMap.put(subscriptionId, futureMock);
BroadcastSubscriptionListener broadcastListener = mock(BroadcastSubscriptionListener.class);
broadcastSubscriptionDirectory.put(subscriptionId, broadcastListener);
subscriptionManager.handleSubscriptionReply(subscriptionReply);
verify(futureMock).onFailure(eq(subscriptionError));
verify(broadcastListener).onError(eq(subscriptionError));
}
use of joynr.SubscriptionReply in project joynr by bmwcarit.
the class PublicationManagerImpl method handleSubscriptionRequest.
private void handleSubscriptionRequest(PublicationInformation publicationInformation, SubscriptionRequest subscriptionRequest, ProviderContainer providerContainer) {
final String subscriptionId = subscriptionRequest.getSubscriptionId();
SubscriptionQos subscriptionQos = subscriptionRequest.getQos();
MessagingQos messagingQos = createMessagingQos(subscriptionQos);
try {
Method method = findGetterForAttributeName(providerContainer.getProviderProxy().getClass(), subscriptionRequest.getSubscribedToName());
triggerPublication(publicationInformation, providerContainer, method);
boolean hasSubscriptionHeartBeat = subscriptionQos instanceof HeartbeatSubscriptionInformation;
boolean isOnChangeSubscription = subscriptionQos instanceof OnChangeSubscriptionQos;
if (hasSubscriptionHeartBeat || isOnChangeSubscription) {
// TODO: send error subscription reply is periodMs < MIN_PERIOD_MS or periodMs > MAX_PERIOD_MS?
final PublicationTimer timer = new PublicationTimer(publicationInformation, method, providerContainer, this, attributePollInterpreter);
timer.startTimer();
publicationTimers.put(subscriptionId, timer);
}
if (subscriptionQos instanceof OnChangeSubscriptionQos) {
handleOnChangeSubscription(subscriptionRequest, providerContainer, subscriptionId);
}
dispatcher.sendSubscriptionReply(publicationInformation.providerParticipantId, publicationInformation.proxyParticipantId, new SubscriptionReply(subscriptionId), messagingQos);
} catch (NoSuchMethodException e) {
cancelPublicationCreation(subscriptionId);
logger.error("Error subscribing: {}. The provider does not have the requested attribute", subscriptionRequest);
sendSubscriptionReplyWithError(publicationInformation, subscriptionId, e, messagingQos);
}
}
Aggregations