Show TOC Start of Content Area

Procedure documentation Using a Third-Party JMS Provider  Locate the document in its SAP Library structure

Use

You can use a third-party JMS Provider within the SAP Application Server Java. You have to make different configurations to the jms-resources.xml deployment descriptor using one of the tags:

·        <context-factory-type> for connection factories and <external-destination-type> for destinations.

·        <object-factory-type> for connection factories.

·        <sjo-factory-type> for connection factories and <sjo-destination-type> for destinations.

These tags define a connection factory and destination, which will be acquired by JNDI lookup.

Procedure

Using <context-factory-type>

You have to make the following settings in the jms-resources.xml deployment descriptor:

...

       1.      With the <name> tag, under the <connection-factory> tag, you specify the name of the resource in the JNDI.

Note

If you want to use a JNDI lookup to access the JMS resources, and if the name of the connection factory is jms/test_JMS_ConnFactory, you have to use java:comp/env/jms/test_JMS_ConnFactory in the source code of your application.

       2.      Specify the <initial-context-property> tag under the <context-factory-type> tag. The properties are the same as the properties of the initial context in the source code of the application:

¡        <initial-context-factory> - this is the name of the initial context factory, which you use in your application to connect to the JNDI provider, for example com.third.party.jms.provider.InitialContextFactoryImpl.

¡        <provider-url> - with this tag you specify the host name and port where the JNDI Provider runs.

¡        <security-principal> - this is the user for the naming of the JMS Provider.

¡        <security-credentials> - this is the password for the naming of the JMS Provider.

       3.      With the <link-factory-name> tag you specify the name of the physical connection factory of the third-party JMS Provider.

You can optionally set <user-name> and <password> to the connection factory in the jms-resources.xml or using the SAP NetWeaver Administrator.

Note

We recommend that you use the SAP NetWeaver Administrator because in this way nobody can access the password you have set. To do that you have to:

                            a.      Open the SAP NetWeaver Administrator.

                            b.      Choose Configuration Management Infrastructure Application Resources.

                            c.      From the Show field, select All JMS Connection Factory References if you want to set a user name and password for a connection factory, or All JMS Destination References, if you want to set a user name and password for a destination.

                            d.      In the Resource Details section, specify the User Name and Password fields and choose Save.

The user name and the password will be used when you create the connection with the method createConnection().

       4.      With the <library-name> tag you specify the name of the Java EE library. You need to add the client JAR of the third-party JMS Provider to load the com.third.party.jms.provider.InitialContextFactoryImpl and all JMS classes. To do that you have to use the Telnet command DEPLOY_JMS_LIBRARY from the JMSCONNECTOR group.

>add jmsconnector

>deploy_jms_library ThirdPartyJMSProviderLibrary \path\to\third\party\provider\client.jar

       5.      For destinations, set the name of the queue or topic using the <name> tag, and the name of the connection factory using the <link-connection-factory> tag under the <external-destination-type> tag.

<?xml version=”1.0” encoding=”UTF-8"?>

<jms-resources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xsi:noNamespaceSchemaLocation="jms-resources.xsd">

 

   <connection-factory>

      <name>MyConnectionFactory</name>

      <context-factory-type>

         <initial-context-properties>

            <initial-context-factory>

               com.third.party.jms.provider.InitialContextFactoryImpl

               <!--The implementation class of initial context factory of               the third-party JMS Provider.

                  For SAP this is com.sap.engine.services.jndi.InitialContextFactoryImpl-->

            </initial-context-factory>

            <provider-url>host:port</provider-url>

            <security-principal>user</security-principal>

            <security-credentials>password</security-credentials>

         </initial-context-properties>

         <link-factory-name>

            jms/factories/ConnectionFactory

         </link-factory-name>

         <user-name>jms-user-name</user-name>

         <password>jms-password</password>

         <library-name>ThirdPartyJMSProviderLibrary</library-name>

      </context-factory-type>

   </connection-factory>

 

   <destination>

      <name>MyTopic</name>

      <type>javax.jms.Topic</type>

      <external-destination-type>

         <link-connection-factory>

            MyConnectionFactory

            <!-- This name has to be the same as the name of the connection factory -->

         </link-connection-factory>

      </external-destination-type>

   </destination>

 

</jms-resources>

Using <object-factory-type>

You have to make the following settings in the jms-resources.xml deployment descriptor:

...

       1.      With the <name> tag, under the <connection-factory> tag, you specify the name of the resource in the JNDI. The SAP JMS Connector service binds a javax.naming.Reference  in the naming with this name to the third party JMS connection factory.

Note

If you want to use a JNDI lookup to access the JMS resources, and if the name of the connection factory is jms/test_JMS_ConnFactory, you have to use java:comp/env/jms/test_JMS_ConnFactory in the source code of your application.

       2.      Specify <object-factory-name> under the <object-factory-type> tag. This is the fully qualified name of the class that implements javax.naming.spi.ObjectFactory of the third party Object Factory. The implementation of javax.naming.spi.ObjectFactory#getObjectInstance() have to create the connection factory of the third-party JMS Provider.

package com.third.party.jms.provider;

import javax.naming.Context;

import javax.naming.Name;

import javax.naming.spi.ObjectFactory;

import java.util.Hashtable;

 

public class MyObjectFactory implements ObjectFactory {

    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception {

        MyConnectionFactory connectionFactory = null;

        /*

       * initialize "connectionFactory"

       */

        return connectionFactory;

    }

}

       3.      With the <class-name> tag you specify the fully qualified Java name of the object, the connection factory that the getObjectInstance() method returns.

Note

You can optionally set <user-name> and <password> for the connection factory in the jms-resources.xml or using the SAP NetWeaver Administrator. The user name and the password will be used when you create the connection with the method createConnection().

       4.      With the <library-name> tag you specify the name of the Java EE library. The client JAR file has to be deployed on the Application Server Java as a library. You need to add the client JAR of the third-party JMS provider to load the com.x.y.z.MyObjectFactory and com.x.y.z.MyConnectionFactory.

       5.      With the elements of the <property> tag you may add javax.naming.StringAddrRef addresses to the javax.naming.Reference object passed as a first parameter to javax.naming.spi.Object Factory#getObjectInstance().

<connection-factory>

   <name>ObjectConnectionFactory</name>

   <object-factory-type>

      <object-factory-name>

         com.third.party.jms.provider.MyObjectFactory

      </object-factory-name>

      <class-name>

         com.third.party.jms.provider.MyConnectionFactory

      </class-name>

      <property>

         <description>description</description>

         <config-property-name>

            config-property-name

         </config-property-name>

         <config-property-value>

            config-property-value

         </config-property-value>

      </property>

      <user-name>user-name</user-name>

      <password>password</password>

      <library-name>thirdPartyJMSClientLibrary</library-name>

   </object-factory-type>

</connection-factory>

Using <sjo-factory-type>

You have to make the following settings in the jms-resources.xml deployment descriptor:

...

       1.      With the <name> tag, under the <connection-factory> tag, you specify the name of the resource in the JNDI. The SAP JMS Connector service binds a javax.naming.Reference in the naming with this name to the third party JMS connection factory.

Note

If you want to use a JNDI lookup to access the JMS resources, and if the name of the connection factory is jms/test_JMS_ConnFactory, you have to use the java:comp/env/jms/test_JMS_ConnFactory in the source code of your application.

       2.      With the <sjo-file-name>tag under the <sjo-factory-type> you specify the name of file that contains the Serialized Java Object (SJO), which is a JMS connection factory or JMS destination.

       3.      You can optionally set <user-name> and <password> to the connection factory in the jms-resources.xml deployment descriptor or using the SAP NetWeaver Administrator. The user name and the password will be used when you create the connection with the method createConnection().

       4.      With the <library-name>  tag you specify the name of the Java EE library. The client JAR file has to be deployed on the Application Server Java as a library.

<connection-factory>

   <name>SJOConnectionFactory</name>

   <sjo-factory-type>

      <sjo-file-name>QueueConnectionFactory.ser</sjo-file-name>

      <user-name>user-name</user-name>

      <password>password</password>

      <library-name>thirdPartyJMSClientLibrary</library-name>

   </sjo-factory-type>

</connection-factory>

       5.      For the JMS destinations you need to set the <sjo-file-name> and <library-name> tags.

<destination>

   <name>SJOQueue</name>

   <type>javax.jms.Queue</type>

   <sjo-destination-type>

      <sjo-file-name>Queue.ser</sjo-file-name>

      <library-name>thirdPartyJMSClientLibrary</library-name>

   </sjo-destination-type>

</destination>

       6.      To use the Serialized Java Object, you have to deploy the SJO file so that the SAP JMS Connector service can use it. To deploy the SJO file, use the application-j2ee-engine.xml deployment descriptor. With the <entry-name> tag you specify the fully qualified path of the SJO file in the EAR file. If you do not create a specific folder for the SJO file, you can find the SJO file in the root of the EAR file.

<?xml version="1.0" encoding="UTF-8"?>

<application-j2ee-engine

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xsi:noNamespaceSchemaLocation="application-j2ee-engine.xsd">

   <provider-name>sap.com</provider-name>

   <modules-additional>

      <module>

         <entry-name>QueueConnectionFactory.ser</entry-name>

         <container-type>JMSConnector</container-type>

      </module>

   </modules-additional>

</application-j2ee-engine>

When you run the application, the SJO file is automatically deserialized and the object (the instance of the class) is bound in the naming using the path java:comp/env/SJOConnectionFactory. In this way you can use it in the source code of your application.

End of Content Area