Example usage for org.springframework.integration.mqtt.core DefaultMqttPahoClientFactory setServerURIs

List of usage examples for org.springframework.integration.mqtt.core DefaultMqttPahoClientFactory setServerURIs

Introduction

In this page you can find the example usage for org.springframework.integration.mqtt.core DefaultMqttPahoClientFactory setServerURIs.

Prototype

@Deprecated
public void setServerURIs(String... serverURIs) 

Source Link

Document

Use this when using multiple server instances, for example when using HA.

Usage

From source file:org.createnet.raptor.auth.service.Application.java

@Bean
public MqttPahoClientFactory mqttClientFactory() {

    DispatcherConfiguration config = (DispatcherConfiguration) ConfigurationLoader
            .getConfiguration("dispatcher", DispatcherConfiguration.class);

    DefaultMqttPahoClientFactory f = new DefaultMqttPahoClientFactory();

    f.setUserName(config.username);//from  w  w  w.j a  v  a  2  s. com
    f.setPassword(config.password);
    f.setServerURIs(config.uri);
    f.setCleanSession(true);
    f.setPersistence(new MemoryPersistence());

    return f;
}

From source file:org.springframework.integration.mqtt.MqttAdapterTests.java

private MqttPahoMessageDrivenChannelAdapter buildAdapter(final IMqttClient client, Boolean cleanSession,
        ConsumerStopAction action) throws MqttException, MqttSecurityException {
    DefaultMqttPahoClientFactory factory = new DefaultMqttPahoClientFactory() {

        @Override/*from w  w w .  j  a v a  2 s . c  o m*/
        public IMqttClient getClientInstance(String uri, String clientId) throws MqttException {
            return client;
        }

    };
    factory.setServerURIs("tcp://localhost:1883");
    if (cleanSession != null) {
        factory.setCleanSession(cleanSession);
    }
    if (action != null) {
        factory.setConsumerStopAction(action);
    }
    given(client.isConnected()).willReturn(true);
    MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter("client", factory,
            "foo");
    adapter.setApplicationEventPublisher(mock(ApplicationEventPublisher.class));
    adapter.setOutputChannel(new NullChannel());
    adapter.setTaskScheduler(mock(TaskScheduler.class));
    adapter.afterPropertiesSet();
    return adapter;
}