JMS 1.1 Send Message Service

The JMS 1.1 Send Message service creates a JMS Message Producer and sends a message to the specified destination.

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

System Name JMS 1.1 Send Message service
Graphical Process Modeler (GPM) categories) All Services
Description The JMS 1.1 Send Message service creates a JMS Message Producer and sends a message to the specified destination. The same service is used for both queue and topic.
Business usage The JMS 1.1 Send Message service creates a JMS Message Producer and sends a message to the specified destination. The same service is used for both queue and topic.
Usage example Use this service to send messages to 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 using the install3rdParty script
  • Load using the custom classloader
For JBoss and WebLogic, you must use the custom classloader as these vendor jars contain classes that already exist in system classloader.
Before you install the jar file, you need to know:
  • Remote JMS server context factory
  • URL (IP address and port)
  • Connection factory name
  • User name and password (if applicable)
  • Public key for the CA or trusted certificates (if used) from the trading partner for access to their JMS server or system certificate (if used)
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 service 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 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 Receive Message service is used to get messages from a JMS topic or queue.
Application requirements None
Initiates business processes? No. This service cannot be used outside of a business process.
Invocation None
Business process context considerations None
Returned status values None
Restrictions None
Persistence level Minimum
Testing considerations Enable JMS logging from the Admin Console by selecting Operations > System > Logs.

Configuring the JMS 1.1 Send Message Service

You need to create a configuration in the User Interface, and then you must specify field settings in 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 the group from the list.
  Config Select the name of the service configuration from the list.
  BATCH_ SEND_FILTER Indicates batch sending mode (sending multiple messages). Optional. Valid value is any string value.
  DESTINATION_NAME_WFC Specifies the Destination Name. If Destination Name is specified in JMS 1.1 Acquire Connection and Session Service, that value overrides the JMS 1.1 Send Message Service Destination Name. Optional. Valid value is any string value.
  DESTINATION_TYPE_WFC Specifies the Destination Type (QUEUE/TOPIC) in the JMS 1.1 Send Service. If Destination Type is specified in JMS 1.1 Acquire Connection and Session Service, that value overrides the JMS 1.1 Send Message Service Destination Type. Optional. Valid value is any string value.
  JMSCorrelationID Specifies the JMS Message Property Correlation ID. Optional. Valid value is any string value.
  JMSDeliveryMode Specifies the delivery mode. Optional. Valid values are:
  • NON PERSISTENT
  • PERSISTENT
  JMSDestination Specifies the JMS Message Property Destination. Optional. Valid value is a destination name.
  JMSExpiration Specifies the JMS Message Property Expiration. While sending the JMS message, you can use the value specified in this field and set it equal to time to live. The send message remains available in the destination until time to live expires. Optional. Valid value is a long string value.
  JMSMessageID Specifies the JMS Message Property Message ID. Optional. Valid value is any string value.
  JMSPriority Specifies the JMS Message Property priority. Optional. Valid values are 0 to 9.
  JMSRedelivered Specifies the JMS Message Property redelivery flag. Optional. Valid value is true or false.
  JMSTimestamp Specifies the JMS Message Property timestamp. Optional. Valid value is a long string value.
  JMSType Specifies the JMS type. Optional. Valid value is any string value. Some JMS providers use a message repository that contains the definitions of messages sent by applications. The JMSType header field may reference a message's definition in the provider's repository. WebLogic JMS currently does not have a message definition repository. If the message will not be forwarded to a foreign vendor, the JMSType can be used to store an arbitrary value, similar to the usage for JMSCorrelationID.
  JMSetProperty Specifies custom JMS Message headers. Optional.
The following structure is used to define the list of additional headers:
<ProcessData>
   <JMSetProperty>
       <header1>value1</header1>
       <header2>value2</header2>
   </JMSetProperty>
</ProcessData>
  MSG_TYPE Describes the payload type. Required. Valid values are:
  • Bytes Message
  • Object Message
  • Text Message
  • Stream Message
No default value.
  MQ_Doc_Encoding Specifies the document Encoding format. Use supported encoding standards, else the following error is displayed UnsupportedEncodingException.

For example: UTF-8

Note:
  • If an encoding type is mentioned in the business process, the data is read using this encoding standard.
  • If an encoding type is not mentioned in the business process and the document encoding is mentioned while uploading the file, then the data is read using this encoding standard.
  • If an encoding type is not mentioned in the business process and the document encoding is not mentioned while uploading the file, then the data is read using the native file encoding standard.
  MQ_CCSID Specifies the CCSID value. Use valid supported CCSID values.
  fix_encoding Specifies the fix_encoding value. Use valid values either true or false.
Note: Fix_encoding is false by default and the fix_encoding property needs to be set to true to be used. The intent behind introducing this property is that if the data being used is already using the correct encoding then, you do not need to go the through code for using MQ_Doc_Encoding and/or MQ_CCSID.

Parameters Passed From Business Process to Service

The following parameters (GPM field names) are passed from the business process to the JMS 1.1 Send Message service:
  • DESTINATION_NAME_WFC
  • DESTINATION_TYPE_WFC
  • MSG_TYPE
  • BATCH_SEND_FILTER
  • JMSCorrelationID
  • JMSDestination
  • JMSExpiration
  • JMSMessageID
  • JMSPriority
  • JMSRedelivered
  • JMSTimestamp
  • JMSType
  • JMSetProperty
  • JMSDeliveryMode
  • MQ_Doc_Encoding
  • MQ_CCSID
  • fix_encoding

Business Process Examples

Example 1

The following example does not override any parameters in the Send Service and only sets the mandatory parameters. It uses JMS11AcquireConnectionAndSessionForQueue service which is UI configured and preset with all the parameters.

<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="JMS11SendMessageService">
      <participant name="JMS11SendMsgRegression"/>
      <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="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

The following example shows how to use the Send service by specifying the Destination Name and Type and also setting JMS Headers. When this business process is run, the message is sent to “SOMEQUEUENAME” with Correlation ID as “testCorrID” irrespective of what the Destination Name and Type were set in the Acquire Connection Service.

<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="JMS11SendMessageService">
      <participant name="JMS11SendMsgRegression"/>
      <output message="JMS11SendMessageServiceInputMessage">
        <assign to="." from="*"></assign>
       <assign to="DESTINATION_NAME">SOMEQUEUENAME</assign>
       <assign to="DESTINATION_TYPE">QUEUE</assign>
       <assign to="JMSCorrelationID">testCorrID</assign>
 <assign to="MSG_TYPE">TextMessage</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

The following example demonstrates batch sending mode. The File System adapter is used to collect multiple documents which are sent via batch sending mode.

<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="BatchCollect">
      <participant name="JMS11FSA"/>    
      <output message="xout">
        <assign to="Action">FS_COLLECT</assign>
        <assign to="collectionFolder">path to collect the files </assign>
        <assign to="bootstrap">false</assign>
        <assign to="collectMultiple">true</assign>
        <assign to="fileModTimeThreshold">0</assign>
        <assign to="deleteAfterCollect">false</assign>
        <assign to="fsa_debug">true</assign>
      </output>
      <input message="xin">
        <assign to="." from="*"/>
      </input>
    </operation>
    <operation name="JMS11SendMessageService">
      <participant name="JMS11SendMsg"/>
     <output message="toService">
      <assign to="." from="*"/>
      <assign to="BATCH_SEND_FILTER">FSA*</assign>
        <assign to="MSG_TYPE">TextMessage</assign>
      </output>
      <input message="fromService">
        <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 send a message using transactions and rollback if the transaction fails. You can also use other services that can use transactions like the 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 Send Message service to ensure that if both sending 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="JMS11AcquireConnectionAndSessionFor
                        QueueRegression" />
                 <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 Send Message Service">
                  <participant name="JMS1.1SendMessageService " />
                  <output message="JMS11SendMessageServiceInputMessage">
                        <assign to="MSG_TYPE">TextMessag</assign>e
                               <assign to="MSG_TYPE">TextMessage</assign>
                        <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="JMS11ReleaseConnectionAndSession
                         Regression" />
                  <output message="JMS11ReleaseConnSessionServiceInputMessage">
                        <assign to="." from="*"></assign>
                  </output>
                  <input message="inmsg">
                        <assign to="." from="*"></assign>
                  </input>
            </operation>
      </sequence> 
</process>

If you need more information on the Begin and End JTA transaction services, see the Begin and End JTA transaction services documentation.

Frequently Asked Questions

How can I set reply to header as temporary destination?

To specify a temporary destination use temporaryQueue// or temporaryTopic// in the reply to field of the JMS 1.1 Send Message Service rather than specifying a destination name.

How do I set custom JMS Message properties?

In addition to the message headers provided in the JMS 1.1 Send Message service, several other properties can be added to the message header by using assigns. By using the assigns feature, these headers can be used with message selectors to filter what messages to receive, what messages to ignore, and can be used for routing in many Enterprise Application Integration (EAI) patterns. If the message selector is blank, then all of the messages are candidates to receive irrespective of any header value.

Example: Consider a bookstore that sends messages to a queue whenever it runs out of inventory. There are several vendors that are listening on this queue which are capable of supplying this inventory to this bookstore. The criterion on which a particular vendor is selected depends on the amount of order (order quantity needed).

This can be achieved easily by sending a message with a custom header specifying the minimum quantity, and each of the vendors can have a message selector that reads this header and depending on this header picks up the message.

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

There are three levels of destination overrides. You can specify the destination to send the message to:
  • JMS 1.1 Acquire Connection and Session service level
  • JMS 1.1 Send Message Service level
  • Both the JMS 1.1 Acquire Connection and Session service level and the JMS 1.1 Send Message Service level. When both are specified, the JMS 1.1 Send Message Service level destination takes precedence. This provides the ability to make where you send a message dynamic (a variable that can be passed into the business process versus being hardcoded).

The advantage of specifying at the send level is that same acquire service can be reused in multiple work flows. This is useful when send message service is running in a loop.

In addition, if the destination is not specified at both these levels but if there is a JMS 1.1 Receive Message service in the work flow that receives a message with a Reply To header set in it, the JMS 1.1 Send Message Service can send the message to the destination in the Reply To header. This is given the last precedence. The following is an example workflow:

Start > JMS 1.1 Acquire Connection And Session Service > JMS 1.1 Receive Message Service (receiving a message from some destination with message having reply to header set on it) > JMS 1.1 Send Message Service (with destination not specified at either acquire or send level but will pick the destination in the reply to header of the received message) > JMS 1.1 Release Connection And Session Service

What are the various modes to send bulk messages?

You can send bulk messages using the batch mode or you can loop the JMS 1.1 Send Message Service. Sending messages in batch mode is not a part of JMS 1.1 specification, but is provided by Sterling B2B Integrator to enable customers to send multiple messages simultaneously.

For example, you may need to send all the documents in a folder as messages. You can accomplish this by either picking one document at a time, sending it as a message or by using the Batch mode. In Batch mode, you can pick all the messages simultaneously and then send them. Batch mode prevents the overhead of creating a new producer, new session, and returning them for each message as the same producer and session can be used to send all the messages.

In addition, when using Batch mode with transactions, the session only has to be committed once. This is similar to running multiple database queries and calling the database commit only once.

Batch mode provides better performance results as compared to single message mode.

What happens when the JMS provider goes down?

As the JMS 1.1 Send Message service is preceded by JMS 1.1 Acquire Connection and Session service that carries out the work to create a connection and session, if the provider is down, the work flow fails with an unable to set up the connection exception.

What happens when a business process fails with an exception (say JMS or some other exception) before Release connection and Session component is called, will our JMS adapter release the connections automatically or do you need to code the exception block in business process to release the connections manually during an exception scenario?

Even in this scenario, connections and sessions are returned back to the pool.

How do I use transactions in JMS 1.1 Send Service?

Transactions can be used when sending messages, as they ensure high throughput when sending bulk messages. You will need to call the End Transaction service before JMS 1.1 Release Connection and Session service.

How can I send messages to temporary destination and receive it?

To send a message to a temporary queue, select the destination type as temporary queue. To receive a message sent to a temporary destination by send message service, the JMS 1.1 Receive Message service should be used in this order:

Start > JMS 1.1 Acquire Connection And Session Service > JMS 1.1 Send Message Service (with destination type as temporary queue or topic and no destination name specified) > JMS 1.1 Receive Message Service (with destination type as temporary queue or topic and no destination name specified and it should be placed between the same acquire and release service) > JMS 1.1 Release Connection And Session Service

This workflow is required as the JMS 1.1 specification provides that a message can be received from a temporary destination by the same connection that sends the message.