[jboss-user] [JBoss Messaging] - QueueBrowser - JBossQueueBrowser$BrowserEnumeration cannot be cast to javax.jms.ObjectMessage

everson . do-not-reply at jboss.com
Sat Oct 8 16:28:25 EDT 2011


everson . [http://community.jboss.org/people/everjava] created the discussion

"QueueBrowser - JBossQueueBrowser$BrowserEnumeration cannot be cast to javax.jms.ObjectMessage"

To view the discussion, visit: http://community.jboss.org/message/630744#630744

--------------------------------------------------------------
I'm trying scanning a queue and pick up a specific object there, but I'm getting the error below ....

QueueBrowser queueBrowser = session.createBrowser(queue);
            Enumeration<ObjectMessage> messages = queueBrowser.getEnumeration();
            while (messages.hasMoreElements()) {
*   ObjectMessage objectMessage = (ObjectMessage) messages;// error here*
                Jms jms = new Jms();
                People p = jms.new People();
                p = (People) objectMessage.getObject();
                System.err.println(p.getName());
            }


java.lang.ClassCastException: org.jboss.jms.client.JBossQueueBrowser$BrowserEnumeration cannot be cast to javax.jms.ObjectMessage


to send the message

session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
            ObjectMessage om = session.createObjectMessage();
            Jms jms = new Jms();
            People p = jms.new People();
            p.setNome("Testttttt");
            om.setObject(p);
            QueueSender sender = session.createSender(queue);
            sender.send(om);
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/630744#630744]

Start a new discussion in JBoss Messaging at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111008/7dd51bb9/attachment.html 


More information about the jboss-user mailing list