use of com.swiftmq.impl.mqtt.v311.netty.handler.codec.mqtt.MqttQoS in project swiftmq-ce by iitsoftware.
the class Subscription method processMessage.
@Override
public void processMessage(MessageEntry messageEntry) {
try {
QueuePullTransaction tx = consumer.createTransaction();
tx.moveToTransaction(messageEntry.getMessageIndex(), readTx);
String jmsTopicName = ((TopicImpl) messageEntry.getMessage().getJMSDestination()).getTopicName();
MqttQoS mqos = MqttQoS.valueOf(qos.value());
if (messageEntry.getMessage().propertyExists(Producer.PROP_QOS)) {
int pqos = messageEntry.getMessage().getIntProperty(Producer.PROP_QOS);
int sqos = qos.value();
if (sqos > pqos)
mqos = MqttQoS.valueOf(pqos);
}
session.getMqttConnection().getConnectionQueue().enqueue(new POSendMessage(jmsTopicName, messageEntry.getMessage(), mqos, tx, this));
incMsgsReceived(1);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.swiftmq.impl.mqtt.v311.netty.handler.codec.mqtt.MqttQoS in project swiftmq-ce by iitsoftware.
the class MQTTSession method visit.
@Override
public void visit(POSendMessage po) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mqttSwiftlet.getName(), toString() + ", visit, po=" + po + " ...");
try {
BytesMessageImpl jmsMessage = (BytesMessageImpl) po.getJmsMessage();
jmsMessage.reset();
MqttQoS qos = po.getQos();
String topicName = topicNameTranslateReverse(po.getTopicName());
byte[] b = new byte[(int) jmsMessage.getBodyLength()];
jmsMessage.readBytes(b);
ByteBuf byteBuf = new ByteBuf(b);
byteBuf.reset();
int packetId = -1;
if (qos != MqttQoS.AT_MOST_ONCE) {
if (pid == 65535)
pid = 1;
packetId = pid++;
outboundPackets.put(packetId, po);
}
mqttConnection.getOutboundQueue().enqueue(new MqttPublishMessage(new MqttFixedHeader(MqttMessageType.PUBLISH, false, qos, false, 0), new MqttPublishVariableHeader(topicName, packetId), byteBuf));
if (qos == MqttQoS.AT_MOST_ONCE) {
po.getTransaction().commit();
po.getSubscription().restart();
} else
addReplay(packetId, new MqttPublishMessage(new MqttFixedHeader(MqttMessageType.PUBLISH, true, qos, false, 0), new MqttPublishVariableHeader(topicName, packetId), byteBuf));
incMsgsReceived(1);
} catch (QueueTransactionClosedException qtc) {
} catch (Exception e) {
mqttConnection.initiateClose("send message: exception=" + e);
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.mqttSwiftlet.getName(), toString() + ", visit, po=" + po + " done");
}
Aggregations