Show TOC

Procedure documentationCreating and Configuring JMS Resources and Resource References Locate this document in the navigation structure

 

In the process of developing Java EE applications you have to perform several tasks. One of these tasks is to create an Enterprise Application Project (EAR) 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   File   New   Project  .

    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 Modify.

    4. Select the Create SAP JMS resources descriptor from the Project Facet list to create the jms-resources.xml deployment descriptor in the EAR Project. Choose OK and then 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 on. 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 Facet list. Choose Apply and then 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 as well.

  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   Configuration Management   Infrastructure   JMS Server Configuration  .

  3. Create the connection factories and destinations needed for the application using the Create button. 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   Configuration Management   Infrastructure   Application Resources  .

  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 JMS 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 SAP NetWeaver 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 Note

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

    End of the note.
  4. Complete the fields between the tags.

The XML Schema file can be displayed not only in Source view, but also in 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 will appear automatically in the Source view as well.

Example

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

Syntax Syntax

  1. <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>
    
End of the code.

More Information