KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
So I have an ActiveMQ broker and some producers that puts some self made objects in the broker. I also have some consumers that receive those messages(serialized objects) without problem. But I want to create a tool that connects to the broker and displays all messages (serialized objects). I tried to do that using and ActiveMQConnection : Set<ActiveMQQueue> currentMessageQueues = activeMQConnection.getDestinationSource().getQueues(); Iterator<ActiveMQQueue> messageQueueIterator = currentMessageQueues.iterator(); while (messageQueueIterator.hasNext()) { ActiveMQQueue currentQueue = messageQueueIterator.next(); QueueSession queueSession = activeMQConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE); QueueBrowser browser = queueSession.createBrowser(currentQueue); Enumeration<?> messagesInQueue = browser.getEnumeration(); while (messagesInQueue.hasMoreElements()) { Message queueMessage = (Message) messagesInQueue.nextElement(); if (queueMessage instanceof ActiveMQObjectMessage) { ActiveMQObjectMessage objectMessage = (ActiveMQObjectMessage) queueMessage; objectMessage.getObject(); } } } With this code I get an exception on objectMessage.getObject(): javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: MyMessage I used debug mode and ActiveMQObjectMessage has the object set to null. Is this approach good and If yes what I am doing wrong? How can I also receive the object from the broker?
Tags (comma-separated)
Save Edits
Cancel