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

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

Introduction

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

Prototype

public void setConsumerStopAction(ConsumerStopAction consumerStopAction) 

Source Link

Document

Set the consumer stop action.

Usage

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//www.  j a v a2 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;
}