/** Specialized version to publish will testament message. */ private void forwardPublishWill(WillMessage will, String clientID) { // it has just to publish the message downstream to the subscribers // NB it's a will publish, it needs a PacketIdentifier for this conn, default to 1 Integer messageId = null; if (will.getQos() != AbstractMessage.QOSType.MOST_ONE) { messageId = m_messagesStore.nextPacketID(clientID); } IMessagesStore.StoredMessage tobeStored = asStoredMessage(will); tobeStored.setClientID(clientID); tobeStored.setMessageID(messageId); route2Subscribers(tobeStored); }
private static IMessagesStore.StoredMessage asStoredMessage(WillMessage will) { IMessagesStore.StoredMessage pub = new IMessagesStore.StoredMessage(will.getPayload().array(), will.getQos(), will.getTopic()); pub.setRetained(will.isRetained()); return pub; }