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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations