0
votes

According your experience when you have to create a JMS service and put all the methods (create connection, create session and so on...) inside a bean which send a message to a Message Driven Bean and receive a response by this one, is better it would be a stateful or stateless bean?

1

1 Answers

1
votes

It should be stateless as this just acts as a service to send messages. Stateful bean is created per client, and it should contain some client state, data that is used during method calls that you don't want to send each time. Common example is shopping cart, which hold the basket state between method calls.

There is no state needed between sending messages via you JMS service, so no point of making it stateful. Also stateless beans are usually better from performance perspective.