Search in sources :

Example 1 with MqttBolt

use of org.apache.storm.mqtt.bolt.MqttBolt in project storm by apache.

the class StormMqttIntegrationTest method buildMqttTopology.

public StormTopology buildMqttTopology() {
    TopologyBuilder builder = new TopologyBuilder();
    MqttOptions options = new MqttOptions();
    options.setTopics(Arrays.asList(TEST_TOPIC));
    options.setCleanConnection(false);
    TestSpout spout = new TestSpout(new StringMessageMapper(), options);
    MqttBolt bolt = new MqttBolt(options, new MqttTupleMapper() {

        @Override
        public MqttMessage toMessage(ITuple tuple) {
            LOG.info("Received: {}", tuple);
            return new MqttMessage(RESULT_TOPIC, RESULT_PAYLOAD.getBytes());
        }
    });
    builder.setSpout("mqtt-spout", spout);
    builder.setBolt("mqtt-bolt", bolt).shuffleGrouping("mqtt-spout");
    return builder.createTopology();
}
Also used : MqttOptions(org.apache.storm.mqtt.common.MqttOptions) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) MqttBolt(org.apache.storm.mqtt.bolt.MqttBolt) ITuple(org.apache.storm.tuple.ITuple) StringMessageMapper(org.apache.storm.mqtt.mappers.StringMessageMapper)

Aggregations

MqttBolt (org.apache.storm.mqtt.bolt.MqttBolt)1 MqttOptions (org.apache.storm.mqtt.common.MqttOptions)1 StringMessageMapper (org.apache.storm.mqtt.mappers.StringMessageMapper)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1 ITuple (org.apache.storm.tuple.ITuple)1