This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes read message from Topic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "read message from Topic" Watch "read message from Topic" New topic
Author

read message from Topic

Vlade Maksimovic
Greenhorn

Joined: May 14, 2009
Posts: 4
Hello...
How to read message from Topic without the use of MessageListener...
I try with MessageConsumer receive() method, but.... nothing...

When I try to work with Queue, and when I use receive method, all works fine.

Thanks
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5811
    
    7

Please post the code you are using, including the code that establishes the connection to the topic.

Topics are different than queues - only listeners who are registered at the time that a message is posted to a topic will received the message. You can change this by registering a durable listener, in which case the server will ensure that the durable listener gets all messages, even those posted while the listener was not listening.


JBoss In Action
Vlade Maksimovic
Greenhorn

Joined: May 14, 2009
Posts: 4
Producer:


Customer:



Test class:


I known to do this example to work with MessageListener, but my task is that make to work without Listener. I forget to tell, I work with Jboss 5.0.1GA.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5811
    
    7

Please read this sentence again:

Topics are different than queues - only listeners who are registered at the time that a message is posted to a topic will received the message.


Then look at your test code and tell me why it does not work.

Your consumer is a little trickier - you will have to read the javadocs for the MessageConsumer.receive() method before you can tell me why it doesn't work.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: read message from Topic
 
Similar Threads
ServerSocket listening in the web container part
pub/sub issues
jms websphere example JNDI exception
DatagramPacket::getLength() does not refresh
jms pub sub