I'm using a QueueBrowser
to get a message from the queue, but I can't get the messageId. For some reason my userId is displayed
private void viewMessage() throws NamingException, JMSException {
Queue queue = (Queue) initialContext.lookup("dynamicQueues/" + "TestQueue");
if (queueBrowser == null){
queueBrowser = queueSession.createBrowser(queue);
}
Enumeration<Message> messageEnumeration = queueBrowser.getEnumeration();
ArrayList<Message> messages = new ArrayList<>();
while (messageEnumeration.hasMoreElements()){
messages.add(messageEnumeration.nextElement());
}
messages.forEach(value -> {
try {
System.out.println(value.getJMSMessageID());
} catch (JMSException e) {
throw new RuntimeException(e);
}
});
}
In Artemis the "User ID" of the message displayed in the console is the "Message ID" set by the sending client (user). It is a little confusing but that is the value that JMS client would have set on the message as Its JMS Message ID on send. The message ID value you see is the broker created ID for the message it received from a sender and is used for internal tracking.