Show TOC

Creating and Configuring JMS Resources and Resource ReferencesLocate this document in the navigation structure

Use

In the process of developing Java EE applications you have to perform several tasks. One of these tasks is to create an Enterprise Application (EAR) project and the jms-resources.xml where you declare the connection factories and the destinations needed by the application. The jms-resources.xml has to be included in the EAR.

Deploying the EAR file results in the automatic deployment of all JMS resources defined by the jms-resources.xml file. The XML file is packaged in the EAR file.

JMS resources of the SAP JMS Provider are the connection factories and destinations also referred to as JMS administered objects.

JMS resource references of the SAP JMS Connector are the JMS connection factory references and the JMS destination references.

There are three ways to create JMS resources:

  1. Create administered JMS resources using the SAP NetWeaver Administrator.

    1. Via JMS Server Configuration

    2. Via Application Resources

  2. Provide a jms-resources.xml file in the Enterprise Archive (EAR) of an application.

    1. Via SAP NetWeaver Developer Studio

    2. Editing the jms-resources.xml manually

  3. Deploy a standalone jms-resources.xml . A standalone jms-resources.xml can be easily used by multiple applications. You can deploy the standalone jms-resources.xml via Telnet.

For the second and third steps the JMS resources are created in the JMS provider and the JMS resource references are created in the JMS connector. In this way the application is able to:

  • Enlist JMS resources in a global transaction together with other resources.

  • Plug a third-party JMS Provider transparently to the application.

Procedure

Creating JMS Resources and Resource References via Deployment

To provide jms-resources.xml file in an EAR, use the SAP NetWeaver Developer Studio:

  1. Create an Enterprise Application Project (EAR).

    1. Choose Start of the navigation path File Next navigation step New Next navigation step Project End of the navigation path.

    2. Expand Java EE and select Enterprise Application Project . Choose Next .

    3. Specify the name of the EAR project in the Project Name field. Leave the SAP Libraries in the Target Runtime field and the Default Configuration for SAP Libraries in the Configurations field. Choose the Modify .

    4. Select the Create SAP JMS resources descriptor from the Project Facets list to create the jms-resources.xml deployment descriptor in the EAR project. Choose OK , then choose Finish .

    5. If you do not select the Create SAP JMS resources descriptor project facet while creating the EAR project, you can add this project facet later. In the context menu of the EAR project choose Properties . Select Project Facets from the properties tree and then select the Create SAP JMS resources descriptor from the Project Facets list. Choose Apply , then choose OK .

  2. Declare the connection factories and the destinations needed by the application. Use the <sap-local-factory-type> and <sap-local-destination-type> tags to create JMS connection factory references and JMS destination references.

  3. Deploy the application and the EAR using the Developer Studio or telnet.

Creating JMS Resources via SAP NetWeaver Administrator

To create administered JMS resources, you have to:

  1. Open the SAP NetWeaver Administrator.

  2. Choose Start of the navigation path Configuration Next navigation step Infrastructure Next navigation step JMS Server Configuration End of the navigation path.

  3. Create the connection factories and destinations needed for the application using the Create pushbutton. All destinations and connection factories appear in the JMS Resource List .

Creating JMS Resource References via SAP NetWeaver Administrator

To create administered JMS resource references, you have to:

  1. Open the SAP NetWeaver Administrator.

  2. Choose Start of the navigation path Configuration Next navigation step Infrastructure Next navigation step Application Resources End of the navigation path.

  3. You can create not only the JMS connection factory references and the JMS destination references but also the real JMS connection factories and JMS destinations using the Create New Resource button. All destinations and connection factories appear in the Resource List .

In this way, you can also use some specifics of the JMS connector such as transactions.

This is an alternative of the jms-resources.xml .

Configuring JMS Resources for Java EE Applications Using the SAP NetWeaver Developer Studio

To configure the XML file, navigate to the META-INF folder of your Enterprise Application project and open the jms-resources.xml file. One of the sections of this file sets up the connection factories and the destinations.

The Developer Studio provides the functionality to apply some predefined tags and tag templates while editing the XML file. The procedure to use this functionality is simple:

  1. Position the cursor between the two tags <jms-resources> and </jms-resources> .

  2. Press Ctrl + Space . A list of the available tags and tag templates appears.

  3. Choose a tag or template. If you are not familiar with implementing resource descriptors, it is convenient to use the templates. For the jms-resources.xml file, you need to use the templates for the connection factory and destination.

    Note

    The declaration of the connection factories must precede the declaration of the destinations.

  4. Complete the fields between the tags.

The XML file can be displayed not only in the Source view, but also in the Design view. The left column contains the XML tags and the right column contains the tag values. If you change some of these values in the Design view, the changes appear automatically in the Source view.

Example

Here is an example of the jms-resources.xml .

            <jms-resources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:noNamespaceSchemaLocation="D:\Develop\JMS\Test\AdminTest\jms-resources.xsd">
        <application-name>F3</application-name>
        <connection-factory>
                <name>QF3</name>
                <sap-local-factory-type>
                        <type>javax.jms.QueueConnectionFactory</type>
                        <virtual-provider>default</virtual-provider>
                </sap-local-factory-type>
        </connection-factory>
        <connection-factory>
                <name>TF3</name>
                <sap-local-factory-type>
                        <type>javax.jms.TopicConnectionFactory</type>
                        <virtual-provider>default</virtual-provider>
                </sap-local-factory-type>
        </connection-factory>
</jms-resources>

         
More Information