LibraryLink ToToggle FramesPrintFeedback

Service Implemented as a Message Driven Bean

In this scenario you implement your service as a MDB. When it starts, the MDB notifies the FUSE Services Framework JCA Connector. The FUSE Services Framework JCA Connector activates the FUSE Services Framework service endpoint facade, which receives client requests and invokes directly on the MDB. Incoming invocations do not have to be dispatched to another EJB.

In addition, there is no need for a service WSDL file. FUSE Services Framework uses the service endpoint interface to build a service model as it is defined in the activation specification serviceInterfaceClass property in your application's deployment descriptor file, ejb-jar.xml.

The advantages of using this approach is that it preforms faster than either of the SLSB scenarios because the MDB does not need to dispatch incoming requests to another EJB.

In addition, you do not need to implement EJB Home, Local or Remote interfaces.

The disadvantage of this approach is that the service endpoint interface has to be exposed as the messagelistener-type element in the FUSE Services Framework JCA Connector's deployment descriptor. This means that you must edit the FUSE Services Framework JCA Connector's deployment descriptor file.

FUSE Services Framework includes a working example of this scenario. It is located in the samples/integration/jca/inbound-mdb directory of your FUSE Services Framework installation.

If you want to build and run this sample, please follow the instructions outlined in the README.txt file located in this directory. The example code shown in this section is taken from this sample application.

Complete the following steps to expose your J2EE application, implemented as a MDB, as a Web service using the FUSE Services Framework JCA Connector:

  1. Write a MDB that implements the service that you want to expose. See, for instance, GreeterBean.java located in InstallDir/samples/integration/jca/inbound-mdb/src/demo/ejb and shown in Example 2.1.


  2. Write a deployment descriptor for your MDB. See, for instance, the ejb-jar.xml file located in InstallDir/samples/integration/jca/inbound-mdb/etc and shown in Example 2.2.

    Example 2.2. Message Driven Bean Deployment Descriptor—ejb-jar.xml

    <?xml version="1.0"?>
    ...
    <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
       http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
       version="2.1">
    
       <enterprise-beans>
          <message-driven>
             <ejb-name>Greeter MDB</ejb-name>
             <ejb-class>demo.ejb.GreeterBean</ejb-class>
             <messaging-type>
                org.apache.hello_world_soap_http.Greeter
             </messaging-type>
             <transaction-type>Bean</transaction-type>
     
             <activation-config>          
                <!-- displayName -->
                <activation-config-property>
                   <activation-config-property-name>
                      displayName
                   </activation-config-property-name>
                   <activation-config-property-value>
                      MyCxfEndpoint
                   </activation-config-property-value>
                 </activation-config-property>
                                                
                 <!-- service endpoint interface -->
                 <activation-config-property>
                    <activation-config-property-name>
                       serviceInterfaceClass
                    </activation-config-property-name>
                    <activation-config-property-value>
                       org.apache.hello_world_soap_http.Greeter
                    </activation-config-property-value>
                 </activation-config-property>
                                                
                 <!-- address -->
                 <activation-config-property>
                    <activation-config-property-name>
                       address
                    </activation-config-property-name>
                    <activation-config-property-value>
                       http://localhost:9999/GreeterBean
                    </activation-config-property-value>
                  </activation-config-property>
                                                
                </activation-config>
             </message-driven>
          </enterprise-beans>
                                    
               <assembly-descriptor>
               <method-permission>
                  <unchecked/>
                  <method>
                     <ejb-name>GreeterBean</ejb-name>
                     <method-name>*</method-name>
                  </method>
               </method-permission>
                   <container-transaction>
                       <description/>
                       <method>
                          <description/>
                          <ejb-name>GreeterBean</ejb-name>
                          <method-name>*</method-name>
                       </method>
                       <trans-attribute>Supports</trans-attribute>
                    </container-transaction>
                </assembly-descriptor>
    </ejb-jar>

    For more information about the supported activation configuration properties, see Inbound Activation Configuration.

    If you are using EJB 3.0, the only change you need to make to the deployment descriptor is in the opening ejb-jar element. For EJB 3.0 it should read as shown in Example 2.3.


  3. Package you application in an EJB JAR file.

  4. Make a copy of the FUSE Services Framework JCA Connector's deployment descriptor file, ra.xml, which is located in the samples/integration/jca/websphere/inbound-mdb/etc directory of your installation.

  5. Edit the ra.xml file so that the messagelistener-type element defines the same interface as the messaging-type element defined in your MDB deployment descriptor. This ensures that the FUSE Services Framework JCA Connector is notified when the MDB starts.

  6. Build the FUSE Services Framework JCA Connector RAR file. It must have the following structure and contents:


    The sample application's build.xml file includes a generate.rar target that builds the RAR file (see Example 2.4).


    The cxf.home variable must be set to the InstallDir directory. This is done for you when you set your environment (see Setting Up Your Environment in Configuring and Deploying Endpoints.

  7. Deploy the FUSE Services Framework JCA Connector RAR file and your EJB JAR file to your J2EE application server. For details, see Deploying FUSE Services Framework JCA Connector.