use of org.apache.rocketmq.iot.protocol.mqtt.handler.downstream.impl.MqttSubscribeMessageHandler in project rocketmq-externals by apache.
the class PubSubIntegrationTest method setup.
@Before
public void setup() {
clientManager = new ClientManagerImpl();
subscriptionStore = new InMemorySubscriptionStore();
messageDispatcher = new MessageDispatcher(clientManager);
mqttConnectMessageHandler = new MqttConnectMessageHandler(clientManager);
mqttSubscribeMessageHandler = new MqttSubscribeMessageHandler(subscriptionStore);
mqttMessageForwarder = new MqttMessageForwarder(subscriptionStore);
messageDispatcher.registerHandler(Message.Type.MQTT_CONNECT, mqttConnectMessageHandler);
messageDispatcher.registerHandler(Message.Type.MQTT_PUBLISH, mqttMessageForwarder);
messageDispatcher.registerHandler(Message.Type.MQTT_SUBSCRIBE, mqttSubscribeMessageHandler);
producer = Mockito.spy(new MqttClient());
producer.setId(producerId);
consumer = Mockito.spy(new MqttClient());
consumer.setId(consumerId);
producerChannel = new EmbeddedChannel(messageDispatcher);
producer.setCtx(producerChannel.pipeline().context("producer-ctx"));
consumerChannel = new EmbeddedChannel(messageDispatcher);
consumer.setCtx(consumerChannel.pipeline().context("consumer-ctx"));
topicSubscriptions.add(new MqttTopicSubscription(topicName, MqttQoS.AT_MOST_ONCE));
// Mockito.when(consumerCtx.writeAndFlush(Mockito.any(MqttMessage.class))).then(
// new Answer<Object>() {
// @Override public Object answer(InvocationOnMock mock) throws Throwable {
// MqttMessage message = (MqttMessage) mock.getArguments()[0];
// consumerChannel.writeOutbound(message);
// return consumerChannel.newSucceededFuture();
// }
// }
// );
}
use of org.apache.rocketmq.iot.protocol.mqtt.handler.downstream.impl.MqttSubscribeMessageHandler in project rocketmq-externals by apache.
the class MQTTBridge method registerMessageHandlers.
private void registerMessageHandlers() {
messageDispatcher.registerHandler(Message.Type.MQTT_CONNECT, new MqttConnectMessageHandler(clientManager));
messageDispatcher.registerHandler(Message.Type.MQTT_DISCONNECT, new MqttDisconnectMessageHandler(clientManager));
messageDispatcher.registerHandler(Message.Type.MQTT_PUBLISH, new MqttMessageForwarder(subscriptionStore));
// TODO qos 1/2 PUBLISH
// TODO qos 1: PUBACK
// TODO qos 2: PUBREC
// TODO qos 2: PUBREL
// TODO qos 2: PUBCOMP
messageDispatcher.registerHandler(Message.Type.MQTT_PINGREQ, new MqttPingreqMessageHandler());
messageDispatcher.registerHandler(Message.Type.MQTT_SUBSCRIBE, new MqttSubscribeMessageHandler(subscriptionStore));
messageDispatcher.registerHandler(Message.Type.MQTT_UNSUBSCRIBE, new MqttUnsubscribeMessagHandler(subscriptionStore));
}
use of org.apache.rocketmq.iot.protocol.mqtt.handler.downstream.impl.MqttSubscribeMessageHandler in project rocketmq-externals by apache.
the class ConsumeMessageIntegrationTest method setup.
@Before
public void setup() {
clientManager = new ClientManagerImpl();
subscriptionStore = new InMemorySubscriptionStore();
messageDispatcher = new MessageDispatcher(clientManager);
mqttConnectMessageHandler = new MqttConnectMessageHandler(clientManager);
mqttSubscribeMessageHandler = new MqttSubscribeMessageHandler(subscriptionStore);
mqttMessageForwarder = new MqttMessageForwarder(subscriptionStore);
messageDispatcher.registerHandler(Message.Type.MQTT_CONNECT, mqttConnectMessageHandler);
messageDispatcher.registerHandler(Message.Type.MQTT_SUBSCRIBE, mqttSubscribeMessageHandler);
messageDispatcher.registerHandler(Message.Type.MQTT_PUBLISH, mqttMessageForwarder);
embeddedChannel = new EmbeddedChannel(messageDispatcher);
subscriptions = new ArrayList<>();
subscriptions.add(new MqttTopicSubscription(topicName, MqttQoS.AT_MOST_ONCE));
consuemr = Mockito.spy(new MqttClient());
consuermCtx = Mockito.mock(ChannelHandlerContext.class);
Mockito.when(consuemr.getCtx()).thenReturn(consuermCtx);
}
Aggregations