use of io.joynr.pubsub.HeartbeatSubscriptionInformation 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