Red Hat Training

A Red Hat training course is available for JBoss Enterprise SOA Platform

Chapter 5. Building and Using Services

5.1. Message Listener Configuration Properties

Each listener configuration needs to supply information for:
  • the registry (see the service-category, service-name, service-description and EPR-description tag names.) If you set the optional remove-old-service tag name to true, the Enterprise Service Bus will remove any pre-existing service entry from the registry and then add this new instance. Always use this functionality with care as the entire service will be removed, including every end-point reference.
  • the instantiation of the listener class (see the listenerClass tag name).
  • the endpoint reference that the listener will service. This is transport-specific. The following example corresponds to a Java Message Service endpoint reference (see the connection-factory, destination-type, destination-name, jndi-type, jndi-URL and message-selector tag names).
  • the action pipeline. This needs one or more <action> elements, each of which must contain the class tag name. These will determine which action class will be instantiated for that link in the chain.
  <?xml version = "1.0" encoding = "UTF-8"?>
<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">

<providers>
  <jms-provider name="JBossMQ" 
    connection-factory="ConnectionFactory"
    jndi-URL="jnp://127.0.0.1:1099" 
    jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
    jndi-pkg-prefix="org.jboss.naming:org.jnp.interfaces">
    <jms-bus busid="quickstartGwChannel">
      <jms-message-filter dest-type="QUEUE" 
        dest-name="queue/quickstart_helloworld_Request_gw"/>
    </jms-bus>
    <jms-bus busid="quickstartEsbChannel">
      <jms-message-filter dest-type="QUEUE"
        dest-name="queue/quickstart_helloworld_Request_esb"/>
    </jms-bus>
  </jms-provider>
</providers>
      
<services>
  <service category="FirstServiceESB" 
    name="SimpleListener" description="Hello World">
    <listeners>
      <jms-listener name="JMS-Gateway" 
        busidref="quickstartGwChannel" maxThreads="1"
        is-gateway="true"/>
      <jms-listener name="helloWorld"
        busidref="quickstartEsbChannel" maxThreads="1"/>
    </listeners>

    <actions>
      <action name="action1" class="org.jboss.soa.esb.samples.
quickstart.helloworld.MyJMSListenerAction"
        process="displayMessage" />
      <action name="notificationAction" 
        class="org.jboss.soa.esb.actions.Notifier">
        <property name="okMethod" value="notifyOK" />
        <property name="notification-details"> 
          <NotificationList type="ok">
            <target class="NotifyConsole"/>
          </NotificationList>
          <NotificationList type="err">
            <target class="NotifyConsole"/>
          </NotificationList>
        </property>

     </action>    
   </actions>  
  </service>  
 </services>
</jbossesb>
This example configuration instantiates a listener object (the jms-listener tag), which will wait for those incoming ESB messages that are serialized within an interface. It then delivers each incoming message to an action pipeline consisting of two steps (<action> elements):
  1. action1: MyJMSListenerAction (an example follows).
  2. notificationAction: an org.jboss.soa.esb.actions.SystemPrintln class.
The reason there are two listeners is that the gateway listener is the ESB-unaware listener and its role is to encapsulate the JMS message in the ESB message used throughout the enterprise service bus.