Search in sources :

Example 1 with HeartbeatSubscriptionInformation

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);
    }
}
Also used : SubscriptionReply(joynr.SubscriptionReply) MessagingQos(io.joynr.messaging.MessagingQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) UnicastSubscriptionQos(joynr.UnicastSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos) Method(java.lang.reflect.Method) HeartbeatSubscriptionInformation(io.joynr.pubsub.HeartbeatSubscriptionInformation)

Aggregations

MessagingQos (io.joynr.messaging.MessagingQos)1 HeartbeatSubscriptionInformation (io.joynr.pubsub.HeartbeatSubscriptionInformation)1 SubscriptionQos (io.joynr.pubsub.SubscriptionQos)1 Method (java.lang.reflect.Method)1 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)1 SubscriptionReply (joynr.SubscriptionReply)1 UnicastSubscriptionQos (joynr.UnicastSubscriptionQos)1