Example 4: Using the JMS Connectors

This section discusses using the JMS listening and JMS target connectors.

The examples in this section are intended to be generic and independent of the JMS provider being used. Because of this, in certain steps general instructions are provided. The actual details of the task will depend on the provider being used – and may be rather involved. Please refer to the appropriate documentation.

The error queue is not configured in the examples. However, configuring the error queue may be desirable should issues arise while trying the examples.

The examples in this section focus on queues, but the process for using the JMS connectors when working with topics is essentially the same.

To use the examples in this section, a JMS provider must be configured and running. Please refer to the provider’s documentation for instructions on how to accomplish these tasks. Ensure that messages can be sent to topics and queues before proceeding with the examples.

For the JMS target connector example, you will need a utility to consume and view the messages created. For the JMS listening connector example, you will need a utility to create the messages. The exact details of these utilities depend on the provider. Some may provide an administrative console that you can use to view the contents of topics and queues, and possibly send new messages to them. Other providers may include sample Java programs that you can use to interact with the provider. Refer to the provider’s documentation for further details.

A special case exists for testing the JMS listening connector and queues when the provider is IBM MQSeries. In this instance, use Send Master to test the JMS listening connector.

In this example, PeopleSoft Integration Broker will generate a JMS message, which will be consumed outside of the PeopleSoft system.

To use the JMS target connector:

  1. On the JMS provider, create a JMS Connection Factory with the JNDI name ExampleConnectionFactory.

  2. On the JMS provider, create a JMS Queue with the JNDI name ExampleQueue.

  3. In PeopleSoft Application Designer, open the EXAMPLE_WORKREC record and add the following PeopleCode to the FieldChange event for the TEST field:

    /* create an XML document */
    &xmldata = "<?xml version='1.0'?><ConnectorTest/>";
    &xmlDoc = CreateXmlDoc(&xmldata);
    &rootNode = &xmlDoc.documentelement;
    
    /* add text to the document */
    &descNode = &rootNode.AddElement("TestNode");
    &descNode.NodeValue = "Sending a message to a JMS queue.";
    
    /* and send it out in an async request */
    
    &MSG = CreateMessage(Operation.EXAMPLE_SERVICE_ASYNC_OPR);
    &MSG.SetXmlDoc(&xmlDoc);
    %IntBroker.Publish(&MSG);
    
    MessageBox(0, "", 0, 0, "Message sent.");
    
  4. In the PeopleSoft Pure Internet Architecture, open the node definition for TARGETNODE. Set the Connector ID to JMSTARGET. Set the values for the following properties:

    Property

    Value

    JMSFactory

    ExampleConnectionFactory.

    JMSProvider

    Name of the provider being used.

    JMSUrl

    Connection URL for the provider.

    JMSQueue

    ExampleQueue.

    JMSUserName

    The username on the JMS provider.

    JMSPassword

    The encrypted password for the user ID.

  5. Test the connector:

    1. Open the test page, and click on the Test button.

    2. Verify that the message was sent to the queue. The exact mechanism for doing depends on the provider or utility that you are using.

In this example, you will use the JMS listening connector to send a message to the JMS provider. PeopleSoft Integration Broker will consume the message.

To use the JMS listening connector:

  1. On the JMS provider, create a JMS Connection Factory with the JNDI name ExampleConnectionFactory.

  2. On the JMS provider, create a JMS Queue with the JNDI name ExampleQueue.

  3. In PeopleSoft Application Designer, create a application package and application class. In the application class, put the following PeopleCode in the OnRequest function:

       Local XmlDoc &xmldoc;
       
       &xmldoc = &_MSG.GetXmlDoc(); /*&_msg is the parameter*/ 
       /* and write it to a file */
       Local File &theFile = GetFile("JMSRequest.txt", "W");
       
       &theFile.WriteString(&xmldoc.GenXmlString());
       &theFile.Close(); /* create the reponse message */
       Local Message &outmsg;
       &outmsg = CreateMessage(Operation.EXAMPLE_SERVICE_OPR, 
       %IntBroker_Response);
       /* build the body of the response */
       
       Local string &xmldata = "<?xml version='1.0'?><ConnectorTest/>";
       &xmldoc = CreateXmlDoc(&xmldata);
       
       Local XmlNode &rootNode = &xmldoc.DocumentElement;
       
       Local XmlNode &descNode = &rootNode.AddElement("ResponseMessage");
       &descNode.NodeValue = "This wasgenerated in the OnRequest handler."; 
       
       /* add the body to the message */
       &outmsg.SetXmlDoc(&xmldoc);
    
       /* send the response message */
       Return &outmsg;
    
    
  4. In the PeopleSoft Pure Internet Architecture, open the handler tab on the service operation EXAMPLE_SERVICE_OPR, and set the application class package, class and method name as you defined above.

  5. In the integrationGateway.properties file, uncomment the following line:

    ig.jms.Queues=1
  6. Set the following properties to the values indicated:

    Property

    Value

    ig.jms.Queue1

    ExampleQueue

    ig.jms.Queue1.Provider

    <the name of the provider>

    ig.jms.Queue1.JMSFactory

    ExampleConnectionFactory

    ig.jms.Queue1.Url

    <connection URL for the provider>

    ig.jms.Queue1.Use

    < the userid >

    ig.jms.Queue1.Password

    <the encrypted password for the userid. >

    ig.jms.Queue1.MessageName

    EXAMPLE_SERVICE_OPR.VERSION_1

    ig.jms.Queue1.RequestingNode

    SOURCENODE

    ig.jms.Queue1.DestinationNode

    <the name of the local node >

  7. Deploy and start the JMSListeningConnectorAdministrator servlet.

    See Using the JMS Listening Connector.

  8. Test the connector:

    1. Send a text message to the example JMS queue. Set the text of the message to:

      <?xml version="1.0"?>
      <ConnectorTest>
           <TestNode>Sending a message to the JMS Listening Connector.</TestNode>
      </ConnectorTest>
      
    2. Check the message logs and the file named in the OnRequest method of application class . The message should be present in both.