0
votes

I'm using Spring JMS and Web Sphere Default Messaging Provider for my Messaging Needs. I have created a Topic and connection factory on WAS.

I am able to send message to Topic using JMSTemplate from my publisher.

But Whenever I call JmsTemplate.receive() in my Subscriber , it goes into waiting state and I am not able to receive message in my Subscriber.

However I am able to receive message in Subscriber using JmsTemplate if a use a Listener as Subscriber or if a start a new thread whenever I am publishing message using my Publisher.

Looking for help !

1

1 Answers

1
votes

Messages are not stored in the topic. If you create a Publisher, send messages ans then start a subscriber no messages will be subscribed. At the time of publishing if there are any subscribers subscribed to that topic then only those subscribers will receive the message. If no subscribers exist then messages will be dropped.

It goes into waiting state that means it is waiting for messages from the JMS server and there are no currently available.

Whatever mode of subscribing you are using - asynchronous(MessageListener) or Synchronous(receive) you need to create subscriber before.

You can use

subscriber.receive(long timeout);

if you do not want to wait indefinitely.