Search in sources :

Example 41 with MutableMessage

use of joynr.MutableMessage in project joynr by bmwcarit.

the class MutableMessageFactory method createMessage.

private MutableMessage createMessage(String joynrMessageType, String fromParticipantId, String toParticipantId, Object payload, MessagingQos messagingQos, boolean upliftTtl) {
    ExpiryDate expiryDate;
    if (!upliftTtl) {
        expiryDate = DispatcherUtils.convertTtlToExpirationDate(messagingQos.getRoundTripTtl_ms());
    } else if (messagingQos.getRoundTripTtl_ms() > (Long.MAX_VALUE - ttlUpliftMs)) {
        expiryDate = DispatcherUtils.convertTtlToExpirationDate(Long.MAX_VALUE);
    } else {
        expiryDate = DispatcherUtils.convertTtlToExpirationDate(messagingQos.getRoundTripTtl_ms() + ttlUpliftMs);
    }
    MutableMessage message = new MutableMessage();
    message.setType(joynrMessageType);
    if (messagingQos.getEffort() != null && !MessagingQosEffort.NORMAL.equals(messagingQos.getEffort())) {
        message.setEffort(String.valueOf(messagingQos.getEffort()));
    }
    message.setSender(fromParticipantId);
    message.setRecipient(toParticipantId);
    message.setTtlAbsolute(true);
    message.setTtlMs(expiryDate.getValue());
    message.setPayload(serializePayload(payload));
    message.setCustomHeaders(messagingQos.getCustomMessageHeaders());
    message.setCompressed(messagingQos.getCompress());
    for (JoynrMessageProcessor processor : messageProcessors) {
        message = processor.processOutgoing(message);
    }
    logger.debug("Message {} has expiry date: {}", message.getId(), expiryDate);
    return message;
}
Also used : ExpiryDate(io.joynr.common.ExpiryDate) MutableMessage(joynr.MutableMessage) JoynrMessageProcessor(io.joynr.messaging.JoynrMessageProcessor)

Example 42 with MutableMessage

use of joynr.MutableMessage in project joynr by bmwcarit.

the class MutableMessageFactory method createRequest.

public MutableMessage createRequest(final String fromParticipantId, final String toParticipantId, Request request, MessagingQos messagingQos) {
    MutableMessage msg = createMessage(Message.VALUE_MESSAGE_TYPE_REQUEST, fromParticipantId, toParticipantId, request, messagingQos);
    addRequestReplyIdCustomHeader(msg, request.getRequestReplyId());
    return msg;
}
Also used : MutableMessage(joynr.MutableMessage)

Example 43 with MutableMessage

use of joynr.MutableMessage 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;
}
Also used : MutableMessage(joynr.MutableMessage) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest)

Example 44 with MutableMessage

use of joynr.MutableMessage in project joynr by bmwcarit.

the class MutableMessageFactory method createPublication.

public MutableMessage createPublication(String fromParticipantId, String toParticipantId, SubscriptionPublication publication, MessagingQos messagingQos) {
    MutableMessage msg = createMessage(Message.VALUE_MESSAGE_TYPE_PUBLICATION, fromParticipantId, toParticipantId, publication, messagingQos);
    addRequestReplyIdCustomHeader(msg, publication.getSubscriptionId());
    return msg;
}
Also used : MutableMessage(joynr.MutableMessage)

Example 45 with MutableMessage

use of joynr.MutableMessage in project joynr by bmwcarit.

the class RequestReplyManagerImpl method sendRequest.

/*
     * (non-Javadoc)
     *
     * @see io.joynr.dispatcher.MessageSender#sendRequest(java. lang.String, java.lang.String,
     * java.lang.Object, io.joynr.dispatcher.ReplyCaller, long, long)
     */
@Override
public void sendRequest(final String fromParticipantId, final DiscoveryEntryWithMetaInfo toDiscoveryEntry, Request request, MessagingQos messagingQos) {
    logger.trace("SEND USING RequestReplySenderImpl with Id: " + System.identityHashCode(this));
    MutableMessage message = messageFactory.createRequest(fromParticipantId, toDiscoveryEntry.getParticipantId(), request, messagingQos);
    message.setLocalMessage(toDiscoveryEntry.getIsLocal());
    logger.debug("REQUEST call proxy: method: {}, requestReplyId: {}, messageId: {}, proxy participantId: {}, " + "provider participantId: {}, params: {}", request.getMethodName(), request.getRequestReplyId(), message.getId(), fromParticipantId, toDiscoveryEntry.getParticipantId(), request.getParams());
    messageSender.sendMessage(message);
}
Also used : MutableMessage(joynr.MutableMessage)

Aggregations

MutableMessage (joynr.MutableMessage)60 Test (org.junit.Test)35 MessagingQos (io.joynr.messaging.MessagingQos)15 ImmutableMessage (joynr.ImmutableMessage)9 MulticastSubscriptionRequest (joynr.MulticastSubscriptionRequest)7 SubscriptionRequest (joynr.SubscriptionRequest)6 Request (joynr.Request)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Reply (joynr.Reply)4 Injector (com.google.inject.Injector)3 JoynrMessageProcessor (io.joynr.messaging.JoynrMessageProcessor)3 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)3 MulticastPublication (joynr.MulticastPublication)3 OneWayRequest (joynr.OneWayRequest)3 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 AbstractModule (com.google.inject.AbstractModule)2 TypeLiteral (com.google.inject.TypeLiteral)2 Multibinder (com.google.inject.multibindings.Multibinder)2 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)2