JMS 1.1 Receive Message Service

The JMS 1.1 Receive Message service creates a JMS message consumer and is responsible for receiving messages from the specified destination.

The following table provides an overview of the JMS 1.1 Receive Message service:

System Name JMS 1.1 Receive Message service
Graphical Process Modeler (GPM) categories) All Services
Description JMS 1.1 Receive Message service receives messages synchronously from the remote JMS destination (Queue/Topic).
Business usage JMS 1.1 Receive Message service receives messages synchronously from the remote JMS destination (Queue/Topic).
Usage example Use this service to receive messages from remote Queues or Topics.
Preconfigured? Yes
Requires third-party files? The JMS provider jar must be provided to the system, by using one of the following methods:
  • Install by using the install3rdParty script
  • Load by using the custom classloader
For JBoss and WebLogic, you must use the custom classloader as these vendor jars contain classes that exist in system classloader. For example, if you need to communicate to an external WebLogic JMS server, you need the jar file that includes the weblogic.jndi.WLInitialContextFactory class. You would obtain the jar file from the corresponding vendor or your trading partner.
Platform availability All supported platforms
Related services This adapter can be used with the JMS 1.1 services that are included in business processes:
  • JMS 1.1 Acquire Connection and Session service and JMS 1.1 Release Connection and Session service – these services are used to start and stop a JMS session within a business process. They must be used as a pair in a business process.
  • JMS 1.1 Send Message service – used to send messages to a JMS topic or queue.
Application requirements None
Initiates business processes? No
Invocation None
Business process context considerations None
Returned status values None
Restrictions None
Persistence level Minimum
Testing considerations None

Configuring the JMS 1.1 Receive Message Service

You must configure this service by using the GPM.

UI Field GPM Field Description
Name   Unique and meaningful name for the service configuration. Required.
Description   Meaningful description for the service configuration, for reference purposes. Required.
Select a Group   Select one of the options:
  • None – Do not include the configuration in a service group at this time.
  • Create New Group – Enter a unique name for a new group, which will be created with this configuration. (You can then add other services to the group as well.)
  • Select Group – If service groups already exist for this service type, they are displayed in the list. Select a group from the list.
  Config Select the configuration from the list.
  BATCH_MODE When batch mode is specified, it indicates the service is in the batch receiving mode. Valid value is any valid integer. Default value is 1. For example, the service will receive 4 messages when this parameter is set to an integer 4. If there are only 3 messages to receive, it will wait for the fourth one until the time limit and then returns with 3 messages.
  DESTINATION_NAME _WFC Specifies the Destination Name in the Receive Service. If Acquire Connection And Session Services are specified, the value specified in business process will override this parameter.
  DESTINATION_TYPE_ WFC Specifies the Destination Type (QUEUE/ TOPIC) in the Receive Service. If Acquire Connection And Session Services are specified, the value specified in business process will override this parameter.
  DURABLE_SUBSCRIBER_NAME Specifies the name of the durable subscription on the subscriber. Required if IS_DURABLE_SUBSCRIBER is set to Yes.
  IS_DURABLE_SUBSCRIBER Whether a subscriber to be created should be durable or not. This is only applicable to the scenarios where TOPIC is used as DESTINATION_TYPE. Values are:
  • YES
  • NO
  MESSAGE _SELECTOR Specifies the selector filter on the consumer. Example values are:
JMSCorrelationID=
'ABC'JMSPriority=6JMSPriority=6
AND JMSCorrelationID=
'abc' JMSPriority=6 OR
JMSCorrelationID='abc'
  OUTPUT_FILE_NAME User specified file name for the data that gets received from the destination. If you are receiving documents in batch mode or from the Async Adapter, you can use %^ as the output file name. When using the %^, the output file name is assigned in the format <nodename>_yyyymmddhhmmsslll.
  RECEIVE_ TIME_LIMIT Specifies the time limit (in milliseconds) for receiving the message. Valid value is any valid integer. Default is 300000 (milliseconds).

Business Process Examples

Example 1

The following example illustrates how the JMS 1.1 Receive Message service can be used in a business process. This example does not override any parameters in the Receive Service. It uses JMS 1.1 Acquire Connection And Session For Queue service, which is UI configured and preset with all the parameters.

<process name="jms11ReceiveFromQueueRegression">
   <sequence>
    <operation name="JMS11AcquireConnSessionService">
      <participant name="JMS11AcquireConnectionAndSessionForQueue"/>
      <output message="JMS11AcquireConnSessionServiceInputMessage">
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
    <operation name="JMS11ReceiveMessageService">
      <participant name="JMS11ReceiveMsg"/>
      <output message="JMS11RecvMessageServiceInputMessage">
        <assign to="." from="*"></assign>
             </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
    <operation name="JMS11ReleaseConnSessionService">
      <participant name="JMS11ReleaseConnectionAndSession"/>
      <output message="JMS11ReleaseConnSessionServiceInputMessage">
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
  </sequence> 
</process>

Example 2

This example shows by using the Receive service by specifying the Destination Name and Type and also setting other parameters like batch mode and receive time limit. When this business process is executed, four messages are received from the testDestination_Topic.

<process name="jms11SendToQueueRegression">
  <sequence>
    <operation name="JMS11AcquireConnSessionService">
      <participant name="JMS11AcquireConnectionAndSessionForQueue"/>
      <output message="JMS11AcquireConnSessionServiceInputMessage">
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation> 
<operation name="JMSRecieveMessageService">
      <participant name="JMS11ReceiveMsg"/>
      <output message="JMSRecieveMessageServiceInputMessage">
        <assign to="." from="*"></assign>
        <assign to="BATCH_MODE">4</assign>
        <assign to="DESTINATION_NAME_WFC">testDestination_Topic</assign>
        <assign to="DESTINATION_TYPE_WFC">Topic</assign>
        <assign to="RECEIVE_TIME_LIMIT">40000</assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
    <operation name="JMS11ReleaseConnSessionService">
      <participant name="JMS11ReleaseConnectionAndSession"/>
      <output message="JMS11ReleaseConnSessionServiceInputMessage">
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
  </sequence> 
</process>

Example 3

This example demonstrates the use of Durable Subscriber and the Message Selector. Here the durable subscriber testDurable gets created and it receives messages, which have a Correlation ID equals to “ABC”. While using the durable subscriber, the client ID must be set in JMS 1.1 Acquire Connection service.

<process name="jms11BatchSend">
  <sequence>
    <operation name="JMS11AcquireConnSessionService">
      <participant name="JMS11AcquireConnectionAndSessionForQueue"/>
      <output message="JMS11AcquireConnSessionServiceInputMessage">
    	 <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
 <operation name="JMSRecieveMessageService">
      <participant name="JMS11ReceiveMsg"/>
      <output message="JMSRecieveMessageServiceInputMessage">
        <assign to="." from="*"></assign>
         <assign to="DESTINATION_NAME_WFC">testDestination_Topic</assign>
        <assign to="DESTINATION_TYPE_WFC">Topic</assign>
    <assign to="DURABLE_SUBSCRIBER_NAME">testDurable</assign>
        <assign to="IS_DURABLE_SUBSCRIBER">Yes</assign>
        <assign to="MESSAGE_SELECTOR">JMSCorrelationID='ABC'</assign>
             </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
    <operation name="JMS11ReleaseConnSessionService">
      <participant name="JMS11ReleaseConnectionAndSession"/>
      <output message="JMS11ReleaseConnSessionServiceInputMessage">
        <assign to="." from="*"></assign>
      </output>
      <input message="inmsg">
        <assign to="." from="*"></assign>
      </input>
    </operation>
  </sequence> 
</process>

Example 4

The following example shows how to receive a message by using transactions and rollback in case transaction fails. You can also use other services that can use transactions like Lightweight JDBC in combination with the below and make them commit or rollback together. For example in the below mentioned workflow, LightweightJDBC service instance can be added before or after JMS 1.1 Receive Message service to ensure that if both receiving of message and successful execution of database query happens then only the transaction gets committed else the transaction is rolled back.

<process name="default">
    <sequence>
      <operation name="JMS 1.1 Acquire Connection and Session Service">
          <participant name="JMS11AcquireConnectionAndSessionForQueueRegression"/>
          <participant name="JMS11AcquireConnectionAndSessionForQueueRegression"/>
                  <output message="JMS11AcquireConnSessionServiceInputMessage">
                        <assign to="." from="*"></assign>
                  </output>
                  <input message="inmsg">
                       <assign to="." from="*"></assign>
                  </input>
            </operation>
      <operation name="Begin Transaction Service">
          <participant name="BeginTransactionService" />
          <output message="BeginTransactionServiceTypeInputMessage">
                        <assign to="." from="*"></assign>
                        <assign to="START_TRANSACTION">TRUE</assign>
                        <assign to="DISTRIBUTED">TRUE</assign>
                        <assign to="ON_FAULT">ROLLBACK</assign>
                  </output>
                  <input message="inmsg">
                       <assign to="." from="*"></assign>
                  </input>
         </operation>
       <operation name="JMS 1.1 Recieve Message Service">
             <participant name="JMS1.1ReceiveMessageService" />
                <output message="JMS11RecieveMessageServiceInputMessage">
                        <assign to="." from="*"></assign>
                 </output>
                 <input message="inmsg">
                       <assign to="." from="*"></assign>
                 </input>
        </operation>
      <operation name="End Transaction Service">
            <participant name="EndTransactionService" />
               <output message="EndTransactionServiceTypeInputMessage">
                     <assign to="." from="*"></assign>
                     <assign to="ROLLBACK_TRANSACTION">FALSE</assign>
                     <assign to="END_TRANSACTION">TRUE</assign>
               </output>
               <input message="inmsg">
                     <assign to="." from="*"></assign>
               </input>
          </operation>
      <operation name="JMS 1.1 Release Connection and Session Service">
             <participant name="JMS11ReleaseConnectionAndSessionRegression" />
             <output message="JMS11ReleaseConnSessionServiceInputMessage">
                     <assign to="." from="*"></assign>
             </output>
               <input message="inmsg">
                    <assign to="." from="*"></assign>
               </input>
         </operation>
   </sequence> 
</process>

If needed, refer to the Begin and End JTA transaction services for more details.

Example 5

The following example shows how a message received can be sent to a destination present in the ReplyTo destination of the header. The example assumes that no destination has been specified in the JMS 1.1 Acquire Connection and Session service or JMS 1.1 Send Message Service or JMS 1.1 Receive Message Service. Also the received message has a destination present in the replyTo header of the received message.

<process name="default">
     <sequence>
          <operation name="JMS 1.1 Acquire Connection and Session Service">
              <participant name="JMS11AcquireConnectionAndSessionFor
                       QueueRegression" />
              output message="JMS11AcquireConnSessionServiceInputMessage">
                        <assign to="." from="*"></assign>
              </output>
              <input message="inmsg">
                        <assign to="." from="*"></assign>
                  </input>
            </operation>
            <operation name="JMS 1.1 Recieve Message Service">
                  <participant name="JMS1.1ReceiveMessageService" />
                  <output message="JMS11RecieveMessageServiceInputMessage">
                        <assign to="." from="*"></assign>
                  </output>
                  <input message="inmsg">
                        <assign to="." from="*"></assign>
                  </input>
            </operation>
            <operation name="JMS 1.1 Send Message Service">
                  <participant name="JMS1.1SendMessageService" />
                  <output message="JMS11SendMessageServiceInputMessage">
                      <assign to="." from="*"></assign>
                        <assign to="MSG_TYPE">TextMessage</assign>
                  </output>
                  <input message="inmsg">
                        <assign to="." from="*"></assign>
                  </input>
            </operation>
            <operation name="JMS 1.1 Release Connection and Session Service">
                <participant name="JMS11ReleaseConnectionAndSession
                            Regression" />
                <output message="JMS11ReleaseConnSessionServiceInputMessage">
                        <assign to="." from="*"></assign>
                </output>
                 <input message="inmsg">
                        <assign to="." from="*"></assign>
                  </input>
            </operation>
      </sequence> 
</process>

Frequently Asked Questions

What if I do not receive a message within a given time?

If the message is not received by the JMS 1.1 receive message service, within the specified time-out, the business process completes successfully, but no document will be present.

How do I receive custom JMS Message properties?

All the custom message properties and headers present in the received message are appended to the primary document in the following format.

<?xml version="1.0" encoding="UTF-8"?> 
<ProcessData> 
<JMS>
    <Document SCIObjectID="server:node1:127f5dcff5e:2169">
      <JMSCustomProperty>CustomValue</ JMSCustomProperty >
    </Document>
  </JMS> 
</ProcessData>

What are the various levels where I can set destination override?

For the JMS 1.1 Receive Message service, the destination can be overridden at acquire as well as receive level.

How do I set up a durable subscription?

A durable subscription is only valid for topics (queues are always durable). To set up a durable subscription you need to provide the CLIENT ID in the JMS 1.1 Acquire Connection and Session service. You also need to specify the IS DURABLE SUBSCRIBER parameter and DURABLE SUBSCRIBER NAME in the JMS 1.1 Receive Message service.

The first time this business process runs, the durable subscription is set up, subsequent business processes run should be able pickup messages in the durable mode. To unsubscribe from this subscription you will need to manually shut down the durable subscription.

How can I unsubscribe from a durable subscription?

To unsubscribe from the durable subscription, run the following work flow:

Start >JMS 1.1 Release Connection and Session service > Stop

The parameters that need to be set in the JMS 1.1 Release Connection and Session service are:
  • RELEASE ACTION should be set as UNSUBSCRIBE DURABLE.
  • RELEASE DURABLE SUBSRIBER should be provided with the durable subscriber name that was provided in the JMS 1.1 Receive Message Service.
  • POOL NAME that was provided in the JMS 1.1 Acquire Connection and Session service when the JMS 1.1 Receive Message service was used.

What happens when the JMS provider goes down?

Since the JMS 1.1 Acquire Connection And Session service is responsible for getting the connection and session, the work flow will fail with an exception message in the creating connection.

How do I use transactions in JMS 1.1 Receive service?

The same way you use transactions in the JMS 1.1 Send Message service.

How do I receive multiple messages?

You can specify the parameter BATCH_LIMIT to specify the number of messages you want to receive. The service will be marked complete only after receiving that many messages or time out, whatever comes first.

What if I receive messages less than the specified batch number? Will I still be able to process the remaining messages and how will I figure out how many messages I am short of?

Basically it is like calling the receive in a loop with a timeout. You may or may not get a message within timeout. If you do, then we take the message and add a document tag with a number to the process data else not. You can find the number of document tags in the process data and see how many messages you are short.

Is the time-out parameter per message or overall time-out when receiving multiple messages?

Time-out is per message.

For example, if you have specified a batch size of 5 and have only 3 messages to receive, and the timeout is 1 minute. You start receiving first message, wait for 1 minute before giving up, then start with second wait another minute and so on.

What happens if the RECEIVE_TIME_LIMIT expires?

If message is not received within the given timeout by the JMS 1.1 receive message service the business process completes successfully but no document will be present.

The lack of a Document is the indicator if no message is received within a given time. You can automate this by checking if the Document Tag is present in the process data and has a value assigned to it. For example, process data when message is received:

<?xml version="1.0" encoding="UTF-8"?> 
<ProcessData> 
<JMS>
    <Document SCIObjectID="server:node1:127f5dcff5e:2169">
    </Document>
  </JMS> 
</ProcessData> 
Process data when message is received: 
<?xml version="1.0" encoding="UTF-8"?> 
<ProcessData> 
<JMS>
  </JMS> 
</ProcessData>

How do I prevent Japanese characters from being replaced by question marks when I send a message with Japanese characters?

Do one of the following:
  • If the default character set is en_US, change the character set to en_US.UTF-8.
  • If the default character set is en_US.UTF-8, change the character set to en_US.
You can change the character set at one of the following levels:
  • Current session.
    Attention: If you exit the session, the changed character set is undone.

    export LANG=en_US or export LANG=en_US.UTF-8

  • For a particular user, include the following line in .bash_profile:

    export LANG=en_US or export LANG=en_US.UTF-8

  • For all users on a particular machine, change the content of the /etc/sysconfig/i18n file from LANG="en_US.UTF-8" to LANG="en_US" or vice versa.