Added topic to consumed message.

This commit is contained in:
Dee Eldredge
2016-03-23 23:10:45 +01:00
committed by andsel
parent 7dab8a367f
commit 1b77e43b61
2 changed files with 13 additions and 4 deletions
@@ -4,11 +4,13 @@ import static io.moquette.spi.IMessagesStore.StoredMessage;
public class InterceptConsumedMessage { public class InterceptConsumedMessage {
final private StoredMessage msg; final private StoredMessage msg;
private final String username; private final String username;
private final String topic;
public InterceptConsumedMessage( final StoredMessage msg, String username) { public InterceptConsumedMessage( final StoredMessage msg, final String topic, final String username) {
this.msg = msg; this.msg = msg;
this.username = username; this.username = username;
this.topic = topic;
} }
public StoredMessage getMsg() { public StoredMessage getMsg() {
@@ -18,4 +20,8 @@ public class InterceptConsumedMessage {
public String getUsername() { public String getUsername() {
return username; return username;
} }
public String getTopic() {
return topic;
}
} }
@@ -288,7 +288,9 @@ public class ProtocolProcessor {
verifyToActivate(clientID, targetSession); verifyToActivate(clientID, targetSession);
targetSession.inFlightAcknowledged(messageID); targetSession.inFlightAcknowledged(messageID);
m_interceptor.notifyMessageConsumed(new InterceptConsumedMessage(inflightMsg, username)); String topic = inflightMsg.getTopic();
m_interceptor.notifyMessageConsumed(new InterceptConsumedMessage(inflightMsg, topic, username));
} }
private void verifyToActivate(String clientID, ClientSession targetSession) { private void verifyToActivate(String clientID, ClientSession targetSession) {
@@ -587,7 +589,8 @@ public class ProtocolProcessor {
verifyToActivate(clientID, targetSession); verifyToActivate(clientID, targetSession);
targetSession.secondPhaseAcknowledged(messageID); targetSession.secondPhaseAcknowledged(messageID);
String username = NettyUtils.userName(channel); String username = NettyUtils.userName(channel);
m_interceptor.notifyMessageConsumed( new InterceptConsumedMessage(inflightMsg, username) ); String topic = inflightMsg.getTopic();
m_interceptor.notifyMessageConsumed( new InterceptConsumedMessage(inflightMsg, topic, username) );
} }
public void processDisconnect(Channel channel) { public void processDisconnect(Channel channel) {