Fix issue #30 rewind of message ByteBuffer

This commit is contained in:
andrea
2014-02-15 12:06:03 +01:00
parent 5163b094ae
commit e73a2a8b9e
4 changed files with 112 additions and 10 deletions
@@ -245,15 +245,15 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
* */
private void publish2Subscribers(String topic, AbstractMessage.QOSType qos, ByteBuffer message, boolean retain, Integer messageID) {
LOG.debug("publish2Subscribers republishing to existing subscribers that matches the topic {}, content", topic);
LOG.debug("content <{}>", new String(message.array()));
if (LOG.isDebugEnabled()) {
LOG.debug("content <{}>", DebugUtils.payload2Str(message));
LOG.debug("subscription tree {}", subscriptions.dumpTree());
}
for (final Subscription sub : subscriptions.matches(topic)) {
if (qos.ordinal() > sub.getRequestedQos().ordinal()) {
qos = sub.getRequestedQos();
}
message.rewind();
LOG.debug("Broker republishing to client <{}> topic <{}> qos <{}>, active {}",
sub.getClientId(), sub.getTopic(), qos, sub.isActive());
@@ -298,7 +298,9 @@ class ProtocolProcessor implements EventHandler<ValueEvent> {
pubMessage.setPayload(message);
LOG.info("send publish message to <{}> on topic <{}>", clientId, topic);
LOG.debug("content <{}>", new String(message.array()));
if (LOG.isDebugEnabled()) {
LOG.debug("content <{}>", DebugUtils.payload2Str(message));
}
if (pubMessage.getQos() != AbstractMessage.QOSType.MOST_ONE) {
pubMessage.setMessageID(messageID);
}