• Post Reply Bookmark Topic Watch Topic
  • New Topic

JMS simple consumer problem!

 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I have a consumer, say andres, under a particular topic, soccer.
The question is, how do I retrieve the messages that are stored in the JMS server?
So far I've done the following.
1o.) Lookup a ConnectionFactory through JNDI

2o.) Create a connection

3o.) create a session

Now, I know the topic name is Soccer and the subscriber is andres. I've seen some code examples, but they create a subscriber using something like this

I do NOT need to create any subscriber because it is already created. I just need to start pulling the messages from the server. I'm using OpenJMS. I also know that I have to start the connection, something like this:

and use the method.
hope you guys understand :roll:
cheers
 
gautam shah
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andres Gonzalez:
Hi. I have a consumer, say andres, under a particular topic, soccer.
The question is, how do I retrieve the messages that are stored in the JMS server?
So far I've done the following.
1o.) Lookup a ConnectionFactory through JNDI

2o.) Create a connection

3o.) create a session

Now, I know the topic name is Soccer and the subscriber is andres. I've seen some code examples, but they create a subscriber using something like this

I do NOT need to create any subscriber because it is already created. I just need to start pulling the messages from the server. I'm using OpenJMS. I also know that I have to start the connection, something like this:

and use the method.
hope you guys understand :roll:
cheers

what about session.setMessageListener(this or that or any) ???
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but I wouldn't like to set a listener. I just want to start my application, connect to the JMS server and pull the messages from it. that's it.
I tried to search the API and I found a method call receive(). I tried but it didn't retrieve any message. Does anyone know how to do it??
thanks
 
gautam shah
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andres Gonzalez:
Yes, but I wouldn't like to set a listener. I just want to start my application, connect to the JMS server and pull the messages from it. that's it.
I tried to search the API and I found a method call receive(). I tried but it didn't retrieve any message. Does anyone know how to do it??
thanks

better u look in to JMS specification. after that u can easily decide taht what can be make happening and what not....
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes... but I think I solve the problem:
when you use:

a durable subscriber is only created if it doesn't exist in the JMS server. Once you have "recovered" the subscriber, you attach a listener to it:

and you start pulling the messages from the JMS.
You use session.createReceiver if you want to create a queue receiver using the point-to-point model.
thanks
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Have you solved the problem. Because even i try the option , but it is not working fine. And also where the information be stored , when the subscriber is not up.
Regards,
M.S. Raman.
Originally posted by Andres Gonzalez:
Yes... but I think I solve the problem:
when you use:

a durable subscriber is only created if it doesn't exist in the JMS server. Once you have "recovered" the subscriber, you attach a listener to it:

and you start pulling the messages from the JMS.
You use session.createReceiver if you want to create a queue receiver using the point-to-point model.
thanks
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Malli, It is working now ok, what sort of problem are you experiencing?
"If a particular topic has durable subscribers, the messaging server retains all the messages published on the topic in a database or file for delivery to those subscribers that might be currently disconnected from the system"
I extracted this paragraph from Professional JMS programming, good book. It answers your last question, doesn't it??
SO, if you want the your messages to be stored persistenly, you must do this:

otherwise

In my case I started using JDBM because OpenJMS was bundle with it, but it is not very appropiate database for commercial use. Then I switched to MySQL.
cheers
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!