use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.
the class IltConsumerTest method getRuntimeModule.
private static Module getRuntimeModule(Properties joynrConfig) {
LOG.info("getRuntimeModule: Entering");
Module runtimeModule;
String transport = System.getProperty("transport");
if (transport == null) {
throw new IllegalArgumentException("property \"transport\" not set");
}
LOG.info("getRuntimeModule: transport = " + transport);
if (transport.contains("websocket")) {
LOG.info("getRuntimeModule: websocket host = " + joynrConfig.getProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_HOST));
LOG.info("getRuntimeModule: websocket port = " + joynrConfig.getProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PORT));
LOG.info("getRuntimeModule: websocket protocol = " + joynrConfig.getProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PROTOCOL));
LOG.info("getRuntimeModule: websocket path = " + joynrConfig.getProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PATH));
LOG.info("getRuntimeModule: selecting LibjoynrWebSocketRuntimeModule");
runtimeModule = new LibjoynrWebSocketRuntimeModule();
} else {
LOG.info("getRuntimeModule: selecting CCInProcessRuntimeModule");
runtimeModule = new CCInProcessRuntimeModule();
}
Module backendTransportModules = Modules.EMPTY_MODULE;
if (transport.contains("http")) {
LOG.info("getRuntimeModule: using AtmosphereMessagingModule");
backendTransportModules = Modules.combine(backendTransportModules, new AtmosphereMessagingModule());
}
if (transport.contains("mqtt")) {
LOG.info("getRuntimeModule: using MqttPahoModule");
joynrConfig.put(MessagingPropertyKeys.PROPERTY_MESSAGING_PRIMARYGLOBALTRANSPORT, "mqtt");
backendTransportModules = Modules.combine(backendTransportModules, new MqttPahoModule());
}
LOG.info("getRuntimeModule: Leaving");
return Modules.override(runtimeModule).with(backendTransportModules);
}
use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.
the class ConsumerApplication method getRuntimeModule.
private static Module getRuntimeModule(Properties joynrConfig) {
Module runtimeModule;
Module backendTransportModules = Modules.EMPTY_MODULE;
if (invocationParameters.getRuntimeMode() == RuntimeConfig.WEBSOCKET) {
joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_HOST, invocationParameters.getCcHost());
joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PORT, invocationParameters.getCcPort());
joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PROTOCOL, "ws");
joynrConfig.setProperty(WebsocketModule.PROPERTY_WEBSOCKET_MESSAGING_PATH, "");
joynrConfig.setProperty(MessagingPropertyKeys.PERSISTENCE_FILE, STATIC_PERSISTENCE_FILE);
runtimeModule = new LibjoynrWebSocketRuntimeModule();
} else {
runtimeModule = new CCInProcessRuntimeModule();
if (invocationParameters.getBackendTransportMode() == BackendConfig.MQTT) {
joynrConfig.put("joynr.messaging.mqtt.brokerUri", invocationParameters.getMqttBrokerUri());
joynrConfig.put(MessagingPropertyKeys.PROPERTY_MESSAGING_PRIMARYGLOBALTRANSPORT, "mqtt");
backendTransportModules = Modules.combine(backendTransportModules, new MqttPahoModule());
} else {
// HTTP
backendTransportModules = Modules.combine(backendTransportModules, new AtmosphereMessagingModule());
}
}
return Modules.override(runtimeModule).with(backendTransportModules);
}
use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.
the class IltProviderApplication method getRuntimeModule.
private static Module getRuntimeModule(String[] args, Properties joynrConfig) {
Module runtimeModule;
if (args.length > 1) {
String transport = args[1].toLowerCase();
if (transport.contains("websocketcc")) {
configureWebSocket(joynrConfig);
runtimeModule = new CCWebSocketRuntimeModule();
} else if (transport.contains("websocket")) {
configureWebSocket(joynrConfig);
runtimeModule = new LibjoynrWebSocketRuntimeModule();
} else {
runtimeModule = new CCInProcessRuntimeModule();
}
Module backendTransportModules = Modules.EMPTY_MODULE;
if (transport.contains("http")) {
LOG.info("Configuring HTTP...");
backendTransportModules = Modules.combine(backendTransportModules, new AtmosphereMessagingModule());
}
if (transport.contains("mqtt")) {
LOG.info("Configuring MQTT...");
joynrConfig.put(MessagingPropertyKeys.PROPERTY_MESSAGING_PRIMARYGLOBALTRANSPORT, "mqtt");
backendTransportModules = Modules.combine(backendTransportModules, new MqttPahoModule());
}
return Modules.override(runtimeModule).with(backendTransportModules);
}
return Modules.override(new CCInProcessRuntimeModule()).with(new AtmosphereMessagingModule());
}
use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.
the class DefaultMqttClientIdProviderTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Properties properties = PropertyLoader.loadProperties(MessagingPropertyKeys.DEFAULT_MESSAGING_PROPERTIES_FILE);
Module testModule = Modules.override(new MqttPahoModule()).with(new AbstractModule() {
@Override
protected void configure() {
Multibinder.newSetBinder(binder(), JoynrMessageProcessor.class);
bind(RawMessagingPreprocessor.class).to(NoOpRawMessagingPreprocessor.class);
bind(MessageRouter.class).toInstance(mockMessageRouter);
bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL)).toInstance(Executors.newScheduledThreadPool(10));
}
});
properties.put(MessagingPropertyKeys.RECEIVERID, shortReceiverId);
Injector injectorWithShortReceiverId = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
clientIdProviderWithShortReceiverId = injectorWithShortReceiverId.getInstance(MqttClientIdProvider.class);
properties.put(MessagingPropertyKeys.RECEIVERID, longReceiverId);
Injector injectorWithLongReceiverId = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
clientIdProviderWithLongReceiverId = injectorWithLongReceiverId.getInstance(MqttClientIdProvider.class);
properties.put(MessagingPropertyKeys.RECEIVERID, standardReceiverId);
Injector injectorWithoutClientIdPrefix = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
clientIdProviderWithoutClientIdPrefix = injectorWithoutClientIdPrefix.getInstance(MqttClientIdProvider.class);
properties.put(MqttModule.PROPERTY_KEY_MQTT_CLIENT_ID_PREFIX, clientIdPrefix);
Injector injectorWithClientIdPrefix = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
clientIdProviderWithClientIdPrefix = injectorWithClientIdPrefix.getInstance(MqttClientIdProvider.class);
}
use of io.joynr.messaging.mqtt.paho.client.MqttPahoModule in project joynr by bmwcarit.
the class DefaultMqttTopicPrefixProviderTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Properties properties = PropertyLoader.loadProperties(MessagingPropertyKeys.DEFAULT_MESSAGING_PROPERTIES_FILE);
properties.put(MessagingPropertyKeys.MQTT_TOPIC_PREFIX_MULTICAST, expectedMulticastPrefix);
properties.put(MessagingPropertyKeys.MQTT_TOPIC_PREFIX_REPLYTO, expectedReplyToPrefix);
properties.put(MessagingPropertyKeys.MQTT_TOPIC_PREFIX_UNICAST, expectedUnicastPrefix);
Module testModule = Modules.override(new MqttPahoModule()).with(new AbstractModule() {
@Override
protected void configure() {
Multibinder.newSetBinder(binder(), JoynrMessageProcessor.class);
bind(RawMessagingPreprocessor.class).to(NoOpRawMessagingPreprocessor.class);
bind(MessageRouter.class).toInstance(mockMessageRouter);
bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL)).toInstance(Executors.newScheduledThreadPool(10));
}
});
Injector injector = Guice.createInjector(testModule, new JoynrPropertiesModule(properties));
mqttTopicProviderInstance = injector.getInstance(MqttTopicPrefixProvider.class);
}
Aggregations