Version 7

    Extending JBoss ESB to include JCA Mail Inflow

     

    JBoss ESB provides a generic mechanism to enable message inflow using JCA adapters, further information of which can be found here.  This page describes how to use this mechanism to enable message inflow from a POP or IMAP server.

     

    There are 3 tasks involved in configuring the inflow

    • Deploying the resource adapter

    • Defining the Mail Endpoint

    • Configuring the jca-gateway

     

    (jump to the end of the page for an easy way to try the mail inflow)

     

    Deploying the Resource Adapter

     

    The JBoss AS connector project includes a resource adapter which enables inflow from a mail server.  The resource adapter (mail-ra.rar) is attached to this page and the source for this adapter can be found within the AS codebase.

     

    The resource adapter should be placed in the deploy directory of the esb server.

     

    Defining a Mail Endpoint

     

    The mail endpoint you define must implement the org.jboss.soa.esb.listeners.jca.InflowGateway and org.jboss.resource.adapter.mail.inflow.MailListener interfaces.

     

    public interface InflowGateway
    {
       public void setServiceInvoker(org.jboss.soa.esb.client.ServiceInvoker invoker);
    }
    

     

    The InflowGateway interface specifies a method which is used to initialise the jca-gateway on deployment.  This method is invoked once, before the gateway is active, to specify the ServiceInvoker used to forward ESB messages to the configured target service.

     

    public interface MailListener
    {
       public void onMessage(javax.mail.Message mailMessage);
    }
    

     

    The MailListener interface specified a method which is called for each Mail message passed into the system.  This method is responsible for creating the ESB message and populating it with the contents of the Mail message.  The method must be thread safe as it can be invoked concurrently.

     

    Configuring the jca-gateway

     

    The jca-gateway is configured in the jboss-esb.xml file as part of the service definition used as the target.  The jca-gateway specific part of the configuration should contain the following

    <jca-gateway name="Mail-JCA-Gateway"
       adapter="mail-ra.rar"
       endpointClass="<mail endpoint class>"
       is-gateway="true" transacted="false">
       <activation-config>
          <property name="mailServer" value="<server>"/>
          <property name="storeProtocol" value="<protocol (imap/imaps/pop3/pop3s)>"/>
          <property name="mailFolder" value="<folder>"/>
          <property name="userName" value="<user>"/>
          <property name="password" value="<password>"/>
          <property name="pollingInterval" value="<polling milliseconds>"/>
       </activation-config>
    </jca-gateway>
    

     

    The above configuration should be modified to reflect the mail server account being polled for new messages.

     

    Making things easy

     

    Attached to this page is a sample quickstart which demonstrates the mail inflow.  This quickstart includes the resource adapter as part of the esb, for convenience, but this is not the recommended way of deploying the adapter.

     

    To deploy and test the quickstart do the following

    • Unpack it into the samples/quickstarts directory

    • Edit the jboss-esb.xml to reflect your mail server configuration

    • Deploy it using 'ant deploy'

    • Send an email to the address being polled

     

    The quickstart contains an example Mail Endpoint to create the ESB message.  You should take a look at this Mail Endpoint and modify it to suit your needs.

     

    Please Note: JCA inflow does not work in 4.2GA because of an issue with jUDDI.  You will need to build a distribution from HEAD in order to use it.

     

    Caution

     

    The mail-ra.jar attached to this page is an older version. Please use the appropriate mail-ra.jar that is bundled with the SOA-P server that you are using.