use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.
the class WebSocketTest method sendMessage.
private void sendMessage() throws Throwable {
OneWayRequest request = new OneWayRequest("method", new Object[0], new Class<?>[0]);
MessagingQos messagingQos = new MessagingQos(100000);
ImmutableMessage msg = messageFactory.createOneWayRequest("fromID", "toID", request, messagingQos).getImmutableMessage();
SuccessAction successAction = mock(SuccessAction.class);
webSocketMessagingStub.transmit(msg, successAction, new FailureAction() {
@Override
public void execute(Throwable error) {
Assert.fail(error.getMessage());
}
});
Mockito.verify(messageRouterMock, Mockito.timeout(1000)).route(argThat(new SerializedDataOfImmutableMessageMatcher(msg)));
Mockito.verify(successAction).execute();
}
use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.
the class ConsumerApplication method run.
@SuppressWarnings("checkstyle:methodlength")
@Override
public void run() {
DiscoveryQos discoveryQos = new DiscoveryQos();
discoveryQos.setDiscoveryTimeoutMs(10000);
discoveryQos.setCacheMaxAgeMs(Long.MAX_VALUE);
discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
ProxyBuilder<SystemIntegrationTestProxy> proxyBuilder = runtime.getProxyBuilder(providerDomain, SystemIntegrationTestProxy.class);
boolean success = false;
try {
systemIntegrationTestProxy = proxyBuilder.setMessagingQos(new MessagingQos(10000)).setDiscoveryQos(discoveryQos).build(new ProxyCreatedCallback<SystemIntegrationTestProxy>() {
@Override
public void onProxyCreationFinished(SystemIntegrationTestProxy result) {
LOG.info("proxy created");
proxyCreated.release();
}
@Override
public void onProxyCreationError(JoynrRuntimeException error) {
LOG.error("error creating proxy");
}
});
try {
if (proxyCreated.tryAcquire(11000, TimeUnit.MILLISECONDS) == false) {
throw new DiscoveryException("proxy not created in time");
}
} catch (InterruptedException e) {
throw new DiscoveryException("proxy not created in time");
}
try {
int addendA = 3333333;
int addendB = 4444444;
Integer sum = systemIntegrationTestProxy.add(addendA, addendB);
if (sum != null && sum == (addendA + addendB)) {
LOG.info("SIT RESULT success: Java consumer -> " + providerDomain + " (" + addendA + " + " + addendB + " = " + sum + ")");
success = true;
}
} catch (Exception e) {
// fallthrough
}
} catch (DiscoveryException | JoynrCommunicationException e) {
// fallthrough
}
if (!success) {
LOG.info("SIT RESULT error: Java consumer -> " + providerDomain);
}
System.exit((success) ? 0 : 1);
}
use of io.joynr.messaging.MessagingQos 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);
}
}
use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.
the class PublicationManagerImpl method sendSubscriptionReplyWithError.
private void sendSubscriptionReplyWithError(SubscriptionException e, PublicationInformation publicationInformation, SubscriptionRequest subscriptionRequest) {
SubscriptionQos subscriptionQos = subscriptionRequest.getQos();
MessagingQos messagingQos = new MessagingQos();
if (subscriptionQos.getExpiryDateMs() == SubscriptionQos.NO_EXPIRY_DATE) {
messagingQos.setTtl_ms(SubscriptionQos.INFINITE_SUBSCRIPTION);
} else {
// TTL uplift will be done in JoynrMessageFactory
messagingQos.setTtl_ms(subscriptionQos.getExpiryDateMs() - System.currentTimeMillis());
}
SubscriptionReply subscriptionReply = new SubscriptionReply(publicationInformation.getSubscriptionId(), e);
dispatcher.sendSubscriptionReply(publicationInformation.providerParticipantId, publicationInformation.proxyParticipantId, subscriptionReply, messagingQos);
}
use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.
the class PublicationManagerImpl method sendSubscriptionPublication.
@Override
public void sendSubscriptionPublication(SubscriptionPublication publication, PublicationInformation publicationInformation) throws JoynrSendBufferFullException, JoynrMessageNotSentException, JsonGenerationException, JsonMappingException, IOException {
MessagingQos messagingQos = new MessagingQos();
// TTL uplift will be done in JoynrMessageFactory
messagingQos.setTtl_ms(publicationInformation.getQos().getPublicationTtlMs());
Set<String> toParticipantIds = new HashSet<>();
toParticipantIds.add(publicationInformation.proxyParticipantId);
dispatcher.sendSubscriptionPublication(publicationInformation.providerParticipantId, toParticipantIds, publication, messagingQos);
publicationInformation.getState().updateTimeOfLastPublication();
}
Aggregations