Version 10

    Using JCA With JBoss ESB


    You can use JCA Message Inflow as an ESB Gateway.  This integration does not use MDBs, but rather ESB's lightweight inflow integration.  To enable a gateway for a service, you must first implement an endpoint class.  This class is a Java class that must implement the org.jboss.soa.esb.listeners.jca.InflowGateway class:


    public interface InflowGateway
       public void setServiceInvoker(ServiceInvoker invoker);


    The endpoint class must either have a default constructor, or a constructor that takes a ConfigTree parameter.  This Java class must also implement the messaging type of the JCA adapter you are binding to.  Here's a simple endpoint class example that hooks up to a JMS adapter:


    public class JmsEndpoint implements InflowGateway, MessageListener
       private ServiceInvoker service;
       private PackageJmsMessageContents transformer = new PackageJmsMessageContents();
       public void setServiceInvoker(ServiceInvoker invoker)
          this.service = invoker;
       public void onMessage(Message message)
             org.jboss.soa.esb.message.Message esbMessage = transformer.process(message);
          catch (Exception e)
             throw new RuntimeException(e);


    One instance of the JmsEndpoint class will be created per gateway defined for this class.  This is not like an MDB that is pooled.  Only one instance of the class will service each and every incoming message, so you must write threadsafe code.


    At configuration time, the ESB creates a ServiceInvoker and invokes the setServiceInvoker method on the endpoint class.  The ESB then activates the JCA endpoint and the endpoint class instance is ready to receive messages.  In the JmsEndpoint example, the instance receives a JMS message and converts it to an ESB message type.  Then it uses the ServiceInvoker instance to invoke on the target service.


    The JMS Endpoint class is provided for you with the ESB distribution under org.jboss.soa.esb.listeners.jca.JmsEndpoint  It is quite possible that this class would be used over and over again with any JMS JCA inflow adapters.




    A JCA inflow gateway is configured in a jboss-esb.xml file.  Here's an example:


          <service category="HelloWorld_ActionESB"
                   description="Hello World">
                <jca-gateway name="JMS-JCA-Gateway"
                         <property name="destinationType" value="javax.jms.Queue"></property>
                         <property name="destination" value="queue/esb_gateway_channel"></property>


    JCA gateways are defined in <jca-gateway> elements.  These are the configurable attributes of this XML element







    The name of the gateway



    The name of the adapter you are using.  In JBoss it is the filename of the RAR you deployed i.e. "jms-ra.rar"



    The name of your endpoint class



    The message interface for the adapter.  If you do not specify one, ESB will guess based on your endpoint class



    Default to true.  Whether or not you want to invoke the message within a JTA transaction


    You must define an .  This option is provided so that you can pass additional configuration to your endpoint class. You can read these through the ConfigTree passed to your constructore.


    Junit tests for JCA integration


    If you want to look at a running example, here you go:






    We have 2 quickstarts in this, but they have not made their way into source control yet. However they are attached at the bottom of this page. One is for JMS inflow, the other one for email. It supports both pop3 and imap, as well as ssl/nonssl. UsingMailInflowWithJBossESB is an example created independently from this one.