Abraham
Abraham

Reputation: 603

how to send Message from Session bean to MessageDrivenBean indirectly

I'm wondering how to send a Message(javax.jms.Message) from a MySatefulSessionBean to MySingletonBean and then to MyMessageDrivenBean. I'm using Netbeans so I can Right click on the Source code of the Singleton Bean and choose Send JMS Message.

But this would make the Message generated in the MySingletonBean to be sent to MyMessageDrivenBean when what I actually wanted to do is for the Message to be forwarded from MySatefulSessionBean to MyMessageDrivenBean.

i.e instead of creating a new Message in MySingleTonBean and sending it to MyMessageDrivenBean for processing, I want the Message that MySatefulSessionBean instantiated to be processed by MyMessageDrivenBean's onMessage(Message msg) method.

I cannot make MySatefulSessionBean to directly talk with send Message to MyMessageDrivenBean due to personal reason; so the Message should go to the MyMessageDrivenBean indirectly

Can you enlighten me on how to it?

Thanks in advance

Upvotes: 0

Views: 620

Answers (2)

Mike Braun
Mike Braun

Reputation: 3769

Don't actually prepare the message in your stateful session bean, but prepare only the actual payload.

Call your singleton with this payload as a method parameter, and then keep the JMS message creation an internal detail of the singleton.

Upvotes: 1

Piotr Kochański
Piotr Kochański

Reputation: 22692

You are not supposed to receive JMS messages in EJBs other then Message Driven Beans. So your MySingletonBean should not receive JMS messages. If you manage to implement it somehow you would get all kind of crazy errors (because of EJB object lifecycle rules).

So rethink you architecture.

Upvotes: 1

Related Questions