use of io.joynr.messaging.mqtt.JoynrMqttClient in project joynr by bmwcarit.
the class MqttPahoClientTest method createMqttClientInternal.
private JoynrMqttClient createMqttClientInternal(final MqttStatusReceiver mqttStatusReceiver) {
injector = Guice.createInjector(override(new MqttPahoModule()).with(new AbstractModule() {
@Override
protected void configure() {
if (mqttStatusReceiver != null) {
bind(MqttStatusReceiver.class).toInstance(mqttStatusReceiver);
}
}
}), new JoynrPropertiesModule(properties), new AbstractModule() {
@Override
protected void configure() {
bind(MessageRouter.class).toInstance(mockMessageRouter);
bind(ScheduledExecutorService.class).annotatedWith(Names.named(MessageRouter.SCHEDULEDTHREADPOOL)).toInstance(Executors.newScheduledThreadPool(10));
bind(RawMessagingPreprocessor.class).to(NoOpRawMessagingPreprocessor.class);
Multibinder.newSetBinder(binder(), new TypeLiteral<JoynrMessageProcessor>() {
});
}
});
// create a new Factory because the factory caches its client.
mqttClientFactory = injector.getInstance(MqttClientFactory.class);
JoynrMqttClient client = mqttClientFactory.create();
client.setMessageListener(mockReceiver);
return client;
}
use of io.joynr.messaging.mqtt.JoynrMqttClient in project joynr by bmwcarit.
the class MqttPahoClientFactory method createInternal.
private JoynrMqttClient createInternal() {
MqttPahoClient pahoClient = null;
try {
logger.debug("Create Mqtt Client. Address: {}", ownAddress);
String clientId = clientIdProvider.getClientId();
MqttClient mqttClient = new MqttClient(ownAddress.getBrokerUri(), clientId, new MemoryPersistence(), scheduledExecutorService);
logger.info("Creating MQTT Paho client using MQTT client ID: {}", clientId);
pahoClient = new MqttPahoClient(mqttClient, reconnectSleepMs, keepAliveTimerSec, connectionTimeoutSec, timeToWaitMs, maxMsgsInflight, maxMsgSizeBytes, cleanSession, keyStorePath, trustStorePath, keyStorePWD, trustStorePWD, mqttStatusReceiver);
} catch (MqttException e) {
logger.error("Create MqttClient failed", e);
}
return pahoClient;
}
Aggregations