Search in sources :

Example 1 with MqttClientFactory

use of io.joynr.messaging.mqtt.MqttClientFactory 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;
}
Also used : JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) MessageRouter(io.joynr.messaging.routing.MessageRouter) MqttClientFactory(io.joynr.messaging.mqtt.MqttClientFactory) JoynrMqttClient(io.joynr.messaging.mqtt.JoynrMqttClient) JoynrMessageProcessor(io.joynr.messaging.JoynrMessageProcessor) NoOpRawMessagingPreprocessor(io.joynr.messaging.NoOpRawMessagingPreprocessor) RawMessagingPreprocessor(io.joynr.messaging.RawMessagingPreprocessor) AbstractModule(com.google.inject.AbstractModule)

Aggregations

AbstractModule (com.google.inject.AbstractModule)1 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)1 JoynrMessageProcessor (io.joynr.messaging.JoynrMessageProcessor)1 NoOpRawMessagingPreprocessor (io.joynr.messaging.NoOpRawMessagingPreprocessor)1 RawMessagingPreprocessor (io.joynr.messaging.RawMessagingPreprocessor)1 JoynrMqttClient (io.joynr.messaging.mqtt.JoynrMqttClient)1 MqttClientFactory (io.joynr.messaging.mqtt.MqttClientFactory)1 MessageRouter (io.joynr.messaging.routing.MessageRouter)1