Outbound JMS

Jencks supports both Inbound JMS messaging as well as outbound messaging.

Outbound messaging (or message outflow to use JCA speak) allows you to pool and reuse JMS sessions and connections when sending messages. In addition JCA takes care of associating inbound and outbound messaging with the same local transaction or XA.

This is very useful if you are inside either a Servlet or EJB type environemnt where you want to send messages from different threads, but don't want to create & close a connection, session, producer for each send.

Performance Tip


JMS is designed for high performance message exchange. It makes heavy use of asynchronous message exchange to boost performance compared to synchronous request/response type systems.

However creating and closing connections, sessions, producers is an expensive operation - since each operation will often require a synchronous request/response with the message broker (e.g. for security checks etc).

So where possible JMS resources like connections, sessions, producers, consumers should be setup once on startup and reused/pooled. Then a send or receive is a blazingly fast operation.


The following example shows how to configure the JCA container, a JMS broker, the pool & connection manager, the JMS Resource Adaptor and the JMS ConnectionFactory.

The main bean you'd actually use as an end user is right near the bottom, the jmsConnectionFactory.

IMPORTANT: The inbound and outbound config MUST match up.

Do NOT use (as shown above):

instead use:

if working from the example online. In any case, make sure they match. Hopefully this uh, 'documentation issue', will be fixed/changed at some point in the future (right now the main XML is just a link to a file in the CVS repository so I can't just update it and a new test case would have to be made to fix/explain this more clearly).

Powered by Atlassian Confluence