Search code examples
jmsjca

What is the difference between JCA JMS and Plain JMS


I am new to JMS. I am trying to understand what is difference between JCA JMS (Java Connector Architecture) and Plain JMS. I tried finding it through the web, but I didn't find anything satisfactory. Can we write a code using JCA JMS which is supported for both WebLogic and JBoss?


Solution

  • From an API perspective there is no difference between "JCA JMS" and "Plain JMS". The difference is in how they behave. A JCA-based JMS connection factory has 2 big advantages over a plain JMS connection factory:

    • Pooled - Generally speaking, when a connection is "created" from a JCA-based JMS connection factory the underlying physical connection is taken out of a pool and when the connection is "closed" the underlying physical connection is returned to the pool. This eliminates the performance penalty of actually creating and destroying the physical connection which allows clients to be written in ways that would normally be considered an anti-pattern (e.g. "creating" and "closing" a connection for every sent message).
    • Automatic enlistment into JTA transactions - Most of the time applications running in a Java EE application server which consume JMS messages do so via an MDB. By default, the consumption of the message in an MDB (i.e. the execution of onMessage) happen within a JTA transaction. If a JCA-based JMS connection factory is used in the course of the MDB's processing (e.g. to send a message) then the JCA logic will automatically enlist the session into the JTA transaction so that the consumption of the message and the sending of the message are an atomic operation (assuming that the JCA-based connection factory is XA capable).

    I would expect that you could write application code that would behave the same in both WebLogic and JBoss AS.