public void publish(UTF8Buffer topic, Buffer payload, QoS qos, boolean retain, Callback<Void> cb) { queue.assertExecuting(); if( disconnected ) { cb.onFailure(createDisconnectedError()); return; } PUBLISH command = new PUBLISH().qos(qos).retain(retain); command.topicName(topic).payload(payload); send(command, cb); }
listener.onPublish(publish.topicName(), publish.payload(), cb); } catch (Throwable e) { handleFatalFailure(e);
public void publish(UTF8Buffer topic, Buffer payload, QoS qos, boolean retain, Callback<Void> cb) { queue.assertExecuting(); if( disconnected ) { cb.onFailure(createDisconnectedError()); return; } PUBLISH command = new PUBLISH().qos(qos).retain(retain); command.topicName(topic).payload(payload); send(command, cb); }
ActiveMQMessage convertMessage(PUBLISH command) throws JMSException { ActiveMQBytesMessage msg = new ActiveMQBytesMessage(); msg.setProducerId(producerId); MessageId id = new MessageId(producerId, publisherIdGenerator.getNextSequenceId()); msg.setMessageId(id); LOG.trace("MQTT-->ActiveMQ: MQTT_MSGID:{} client:{} connection:{} ActiveMQ_MSGID:{}", command.messageId(), clientId, connectionInfo.getConnectionId(), msg.getMessageId()); msg.setTimestamp(System.currentTimeMillis()); msg.setPriority((byte) Message.DEFAULT_PRIORITY); msg.setPersistent(command.qos() != QoS.AT_MOST_ONCE && !command.retain()); msg.setIntProperty(QOS_PROPERTY_NAME, command.qos().ordinal()); if (command.retain()) { msg.setBooleanProperty(RETAIN_PROPERTY, true); } ActiveMQDestination destination; synchronized (activeMQDestinationMap) { destination = activeMQDestinationMap.get(command.topicName().toString()); if (destination == null) { String topicName = MQTTProtocolSupport.convertMQTTToActiveMQ(command.topicName().toString()); destination = new ActiveMQTopic(topicName); activeMQDestinationMap.put(command.topicName().toString(), destination); } } msg.setJMSDestination(destination); msg.writeBytes(command.payload().data, command.payload().offset, command.payload().length); return msg; }
ActiveMQMessage convertMessage(PUBLISH command) throws JMSException { ActiveMQBytesMessage msg = new ActiveMQBytesMessage(); msg.setProducerId(producerId); MessageId id = new MessageId(producerId, publisherIdGenerator.getNextSequenceId()); msg.setMessageId(id); LOG.trace("MQTT-->ActiveMQ: MQTT_MSGID:{} client:{} connection:{} ActiveMQ_MSGID:{}", command.messageId(), clientId, connectionInfo.getConnectionId(), msg.getMessageId()); msg.setTimestamp(System.currentTimeMillis()); msg.setPriority((byte) Message.DEFAULT_PRIORITY); msg.setPersistent(command.qos() != QoS.AT_MOST_ONCE && !command.retain()); msg.setIntProperty(QOS_PROPERTY_NAME, command.qos().ordinal()); if (command.retain()) { msg.setBooleanProperty(RETAIN_PROPERTY, true); } ActiveMQDestination destination; synchronized (activeMQDestinationMap) { destination = activeMQDestinationMap.get(command.topicName().toString()); if (destination == null) { String topicName = MQTTProtocolSupport.convertMQTTToActiveMQ(command.topicName().toString()); destination = new ActiveMQTopic(topicName); activeMQDestinationMap.put(command.topicName().toString(), destination); } } msg.setJMSDestination(destination); msg.writeBytes(command.payload().data, command.payload().offset, command.payload().length); return msg; }
listener.onPublish(publish.topicName(), publish.payload(), cb); } catch (Throwable e) { handleFatalFailure(e);
destination = activeMQDestinationMap.get(command.topicName()); if (destination == null) { String topicName = MQTTProtocolSupport.convertMQTTToActiveMQ(command.topicName().toString()); try { destination = findSubscriptionStrategy().onSend(topicName); activeMQDestinationMap.put(command.topicName().toString(), destination);
destination = activeMQDestinationMap.get(command.topicName()); if (destination == null) { String topicName = MQTTProtocolSupport.convertMQTTToActiveMQ(command.topicName().toString()); try { destination = findSubscriptionStrategy().onSend(topicName); activeMQDestinationMap.put(command.topicName().toString(), destination);
destination = activeMQDestinationMap.get(command.topicName()); if (destination == null) { String topicName = MQTTProtocolSupport.convertMQTTToActiveMQ(command.topicName().toString()); try { destination = findSubscriptionStrategy().onSend(topicName); activeMQDestinationMap.put(command.topicName().toString(), destination);
void onMQTTPublish(PUBLISH command) throws IOException, JMSException { checkConnected(); LOG.trace("MQTT Rcv PUBLISH message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); //Both version 3.1 and 3.1.1 do not allow the topic name to contain a wildcard in the publish packet if (containsMqttWildcard(command.topicName().toString())) { // [MQTT-3.3.2-2]: The Topic Name in the PUBLISH Packet MUST NOT contain wildcard characters getMQTTTransport().onException(IOExceptionSupport.create("The topic name must not contain wildcard characters.", null)); return; } ActiveMQMessage message = convertMessage(command); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, createResponseHandler(command)); }
void onMQTTPublish(PUBLISH command) throws IOException, JMSException { checkConnected(); LOG.trace("MQTT Rcv PUBLISH message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); //Both version 3.1 and 3.1.1 do not allow the topic name to contain a wildcard in the publish packet if (containsMqttWildcard(command.topicName().toString())) { // [MQTT-3.3.2-2]: The Topic Name in the PUBLISH Packet MUST NOT contain wildcard characters getMQTTTransport().onException(IOExceptionSupport.create("The topic name must not contain wildcard characters.", null)); return; } ActiveMQMessage message = convertMessage(command); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, createResponseHandler(command)); }
void onMQTTPublish(PUBLISH command) throws IOException, JMSException { checkConnected(); LOG.trace("MQTT Rcv PUBLISH message:{} client:{} connection:{}", command.messageId(), clientId, connectionInfo.getConnectionId()); //Both version 3.1 and 3.1.1 do not allow the topic name to contain a wildcard in the publish packet if (containsMqttWildcard(command.topicName().toString())) { // [MQTT-3.3.2-2]: The Topic Name in the PUBLISH Packet MUST NOT contain wildcard characters getMQTTTransport().onException(IOExceptionSupport.create("The topic name must not contain wildcard characters.", null)); return; } ActiveMQMessage message = convertMessage(command); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, createResponseHandler(command)); }
public void onTransportError() { if (connect != null) { if (connected.get()) { if (connect.willTopic() != null && connect.willMessage() != null && !willSent) { willSent = true; try { PUBLISH publish = new PUBLISH(); publish.topicName(connect.willTopic()); publish.qos(connect.willQos()); publish.messageId(MQTTPacketIdGenerator.getNextSequenceId(getClientId())); publish.payload(connect.willMessage()); ActiveMQMessage message = convertMessage(publish); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, null); } catch (Exception e) { LOG.warn("Failed to publish Will Message " + connect.willMessage()); } } // remove connection info sendToActiveMQ(connectionInfo.createRemoveCommand(), null); } } }
public void onTransportError() { if (connect != null) { if (connected.get()) { if (connect.willTopic() != null && connect.willMessage() != null && !willSent) { willSent = true; try { PUBLISH publish = new PUBLISH(); publish.topicName(connect.willTopic()); publish.qos(connect.willQos()); publish.messageId(MQTTPacketIdGenerator.getNextSequenceId(getClientId())); publish.payload(connect.willMessage()); ActiveMQMessage message = convertMessage(publish); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, null); } catch (Exception e) { LOG.warn("Failed to publish Will Message " + connect.willMessage()); } } // remove connection info sendToActiveMQ(connectionInfo.createRemoveCommand(), null); } } }
public void onTransportError() { if (connect != null) { if (connected.get()) { if (connect.willTopic() != null && connect.willMessage() != null && !willSent) { willSent = true; try { PUBLISH publish = new PUBLISH(); publish.topicName(connect.willTopic()); publish.qos(connect.willQos()); publish.messageId(packetIdGenerator.getNextSequenceId(getClientId())); publish.payload(connect.willMessage()); publish.retain(connect.willRetain()); ActiveMQMessage message = convertMessage(publish); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, null); } catch (Exception e) { LOG.warn("Failed to publish Will Message " + connect.willMessage()); } } // remove connection info sendToActiveMQ(connectionInfo.createRemoveCommand(), null); } } }
public void onTransportError() { if (connect != null) { if (connected.get()) { if (connect.willTopic() != null && connect.willMessage() != null && !willSent) { willSent = true; try { PUBLISH publish = new PUBLISH(); publish.topicName(connect.willTopic()); publish.qos(connect.willQos()); publish.messageId(packetIdGenerator.getNextSequenceId(getClientId())); publish.payload(connect.willMessage()); publish.retain(connect.willRetain()); ActiveMQMessage message = convertMessage(publish); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, null); } catch (Exception e) { LOG.warn("Failed to publish Will Message " + connect.willMessage()); } } // remove connection info sendToActiveMQ(connectionInfo.createRemoveCommand(), null); } } }
public void onTransportError() { if (connect != null) { if (connected.get()) { if (connect.willTopic() != null && connect.willMessage() != null && !willSent) { willSent = true; try { PUBLISH publish = new PUBLISH(); publish.topicName(connect.willTopic()); publish.qos(connect.willQos()); publish.messageId(packetIdGenerator.getNextSequenceId(getClientId())); publish.payload(connect.willMessage()); publish.retain(connect.willRetain()); ActiveMQMessage message = convertMessage(publish); message.setProducerId(producerId); message.onSend(); sendToActiveMQ(message, null); } catch (Exception e) { LOG.warn("Failed to publish Will Message " + connect.willMessage()); } } // remove connection info sendToActiveMQ(connectionInfo.createRemoveCommand(), null); } } }
result.topicName(new UTF8Buffer(topicName));
result.topicName(new UTF8Buffer(topicName));