WebSphere MQ Suite Get Message Service

The WebSphere MQ Suite Get Message service gets or browses messages in a queue.

The WebSphere MQ Suite Get Message service is used as part of the WebSphere MQ Suite to open a queue. The following table provides an overview of the WebSphere MQ Suite Get Message service:

Category Description
System Name WSMQGetMessage
Graphical Process Modeler (GPM) categories) All Services, Messaging
Description Used as part of the WebSphere MQ Suite to get or browse messages in a queue.
Business usage Used with the other WebSphere MQ Suite services to send and/or receive messages from a WebSphere MQ server.
Usage example Used to “get” messages off a queue.
Preconfigured? Yes – a default instance is created during install, which can be used by all business processes. Default instance name is WSMQ_GetMessage.
Requires third-party files? com.ibm.mq.jar version 5.2.0 or higher and associated message catalog property files (i.e. mqji_en_US.property). These files need to be installed using install3rdParty.
Platform availability All supported Sterling B2B Integrator platforms
Related services
Related services:
  • WSMQOpenSession
  • WSMQCloseSession
  • WSMQOpenQueue
  • WSMQCloseQueue
  • WSMQPutMessage
  • WSMQCommit
  • WSMQBackout
Application requirements You must have a WebSphere MQ server.
Initiates business processes? No. This service does not invoke business processes. All data received is placed into process data.
Invocation Invoke the default instance in a business process and specify the appropriate parameters.
Business process context considerations Documents created by this service as a result of receiving messages are placed directly into process data. Use wsmq_metadata1 and/or wsmq_metadata2 to specify what metadata is included with the document from the message(s) that comprise the document.
Returned status values Returned status values:
  • Success – GetMessage service completed successfully.
  • Error – GetMessage service did not complete successfully.
Restrictions None
Persistence level Default
Testing considerations While testing this service, it is recommended to turn on debugging (wsmq_debug=Yes), which provides useful information if problems occur.

Implementing the WebSphere MQ Suite Get Message Service

There are no steps required for implementing this service. The default configuration, WSMQ_GetMessage, is ready for use as soon as Sterling B2B Integrator is installed. However, you can edit the service's parameter settings for specific business processes in the GPM.

Setting Up the Service in the GPM

Use the field definitions in the following table to set up the service configuration in the GPM:

Field Description
Config Select the name of the service configuration from the list.
Browse Lock Options (wsmq_browselock) Only valid when browsing messages. Optional. Valid values are:
  • Lock message (to use in code, specify LOCK)
  • Unlock message ((to use in code, specify UNLOCK)
Buffersize override (wsmq_buffersize) If specified, overrides the default buffersize used when streaming data. Valid values are 0-999999999. Optional.
Document Name (wsmq_docName) The document name to associate with the data received. Default is %^.dat. Optional.
Document tracking (wsmq_docTracking) Specifies whether to perform document tracking. Valid values are Yes and No. Default is No. Optional.
Error Status For MQException (wsmq_errorOnMQException) Normally when an MQException occurs, the workflow status is set to error but this allows it to be set to success so that the workflow can perform its own error process or retry logic. Valid values are Yes and No. Default is Yes. Optional.
Group messages (wsmq_groupBy) Selects which identifier to use when grouping messages. Only used if the wsmq_msgHandling parm is set to GROUP. Optional. Valid values are:
  • With the same group identifier (GRPID)
  • With the same message identifier (MSGID)
  • With the same correlation identifier (CORID)
Group messages even when the identifier is MQ*_NONE? (wsmq_groupMsgWhenIdNone) Determines if messages will be grouped even if the identifier equals MQ*_NONE. Valid values are Yes and No. Default is Yes. Optional.
Convert wsmq_MQMO_corId from hex to byte array (wsmq_hexToByte_corId) Select Yes to invoke the conversion from hex to byte array. Valid values are Yes and No. Default is No. Optional.
Convert wsmq_MQMO_grpId from hex to byte array (wsmq_hexToByte_grpId) Select Yes to invoke the conversion from hex to byte array. Valid values are Yes and No. Default is No. Optional.
Convert wsmq_MQMO_msgId from hex to byte array (wsmq_hexToByte_msgId) Select Yes to invoke the conversion from hex to byte array. Valid values are Yes and No. Default is No. Optional.
Metadata1 To Include (wmq_metadata1) Specifies which metadata fields (add values together for multiple fields) from the message to include with the document created in process data. Optional. Valid values are:
  • 0 – no metadata fields (default)
  • 1 – msgId
  • 2 – corId
  • 4 – grpId
  • 8 – msgType
  • 16 – replyToQM
  • 32 – replyToQ
  • 64 – acctToken
  • 128 – ApplIdData
  • 256 – ApplOrigin
  • 512 – Format
  • 1024 – Report
  • 2048 – Feedback
Metadata2 To Include (wmq_metadata2) Specifies which metadata fields (add values together for multiple fields) from the message to include with the document created in process data. Optional. Valid values are:
  • 0 – no metadata fields (default)
  • 1 – groupStatus
  • 2 – encoding
  • 4 – charset
  • 8 – expiry
  • 16 – putDateTime
  • 32 – putApplName
  • 64 – putApplType
  • 128 – msgFlags
  • 256 – msgSeqNum
  • 512 – offset
  • 1024 – persistence
  • 2048 – priority
MQGMO_ALL_MSGS_AVAILABLE (wsmq_MQGMO_allmsgavail) Select Yes to include this Get Message Option. Valid values are Yes and No. Default is Yes. Optional.
MQGMO_ALL_SEGMENTS_AVAILABLE (wsmq_MQGMO_allsegavail) Select Yes to include this Get Message Option. Valid values are Yes and No. Default is Yes. Optional.
MQGMO_COMPLETE_MSG (wsmq_MQGMO_completemsg) Select Yes to include this Get Message Option. Valid values are Yes and No. Default is Yes. Optional.
MQGMO_CONVERT (wsmq_MQGMO_convert) Select Yes to include this Get Message Option. Valid values are Yes and No. Default is No. Optional.
MQGMO_FAIL_IF_QUIESCING (wsmq_MQGMO_failifquiescing) Select Yes to include this Get Message Option. Valid values are Yes and No. Default is Yes. Optional.
MQGMO_LOGICAL_ORDER (wsmq_MQGMO_logicalorder) Select Yes to include this Get Message Option. Valid values are Yes and No. Default is Yes. Optional.
MQGMO_SYNCPOINT (wsmq_MQGMO_syncpoint) Select Yes to include this Get Message Option. Valid values are Yes and No. Default is Yes. Optional.
Note: When using the BROWSE functions for Get Type (wsmq_type), the MQGMO_SYNCPOINT (wsmq_MQGCO_syncpoint) parameter must be set to No.
MQGMO_WAIT (wsmq_MQGMO_wait) Select Yes to include this Get Message Option. Valid values are Yes and No. Default is No. Optional.
Wait Interval (milliseconds) (wsmq_MQGMO_waitInterval) The wait interval specified in milliseconds. Must select Yes on wsmq_MQGMO_wait for this value to be used. Valid values are 1-9999999999. Optional.
MQMO_MATCH_CORREL_ID (wsmq_MQMO_corId) Sets the MQMO_MATCH_CORREL_ID option to this value. Optional.
MQMO_MATCH_GROUP_ID (wsmq_MQMO_grpId) Sets the MQMO_MATCH_GROUP_ID option to this value. Optional.
MQMO_MATCH_MSG_ID (wsmq_MQMO_msgId) Sets the MQMO_MATCH_MSG_ID. Optional.
Message Handling (wsmq_msgHandling) Select the type of message handling to be used. Optional. Valid values are:
  • Receive one message as one document (ONE) (default)
  • Receive all messages in a logical group as one document (GROUP)
  • Receive all messages available as one document (ALL)
  • Combine all messages with the same msgID and trigger using msgType (SPEC1)
Queue Name (wmq_qname) The name of a previously opened queue used to PUT messages. Required.
Receive Message Limit (wsmq_rcvMsgLimit) Used with GETALL or BROWSEALL to limit the number of messages received. Valid values are 0-999999999. Default is 0 (unlimited). Optional.
Use the group status flag to determine end-of-group? (wsmq_useGroupStatus) Specifies whether to use the group status to determine end of a group or to receive until no more messages are available. Valid values are Yes and No. Default is No. Optional.
Get Type (wsmq_type) Specifies the type of Get to perform. These types are better defined below. Optional. Valid values are (the following are codes only):
  • GETONE – Destructively gets the first message in the queue that satisfies the selection criteria. (default)
  • GETALL – Destructively gets all messages in the queue that satisfy the selection criteria.
  • GETUNDERCURSOR – Destructively gets the message pointed to by the browser cursor regardless of the selection criteria.
  • BROWSEALL – Non-destructively gets all messages in the queue that satisfy the selection criteria (cannot use lock). The following BPML is a sample of how you could use BROWSEALL:
<operation name="GET message(s)">
 <participant name="WSMQ_GetMessage"/>
  <output message="toService">
   <assign to="wsmq_metadata1">4095</assign>
   <assign to="wsmq_metadata2">4095</assign>
   <assign to="wsmq_qname">qname</assign>
   <assign to="wsmq_type">BROWSEALL</assign>
   <assign to="wsmq_MQGMO_syncpoint">No</assign>
   <assign to="wsmq_rcvMsgLimit">3</assign>
   <assign to="wsmq_sessionid" from="string(wsmq_sessionid)">
   </assign>
  </output>
  <input message="fromService">
   <assign to="." from="*"></assign>
  </input> 
</operation>
  • BROWSENEXT – Non-destructively gets the next message in the queue that satisfies the selection criteria.
  • BROWSEFIRST – Non-destructively gets the first message in the queue that satisfies the selection criteria.
  • BROWSEUNDERCURSOR – Non-destructively gets the message currently under the browse cursor regardless of the selection criteria.
Note: When using the BROWSE functions for Get Type (wsmq_type), the MQGMO_SYNCPOINT (wsmq_MQGCO_syncpoint) parameter must be set to No.

Process Data Example

The following example illustrates how process data would look if you specified the value 4095 for the parameters wsmq_metadata1 and wsmq_metadata2. (4095 is the sum of all the available values for the metadata fields: 1+2+4+8+16+32+64+128+256+512+1024+2048 = 4095):

<ProcessData> 
 <WSMQ> 
    <DocumentCount>1</documentCount> 
   <Document1 SCIObjectID="df8f5e:102fa5a6c8f:-7414"> 
     <messageId>414D5120514D5F6761727931303030205D624C4220000502</messageId> 
     <correlationId>000000000000000000000000000000000000000000000000
     </correlationId> 
     <groupId>000000000000000000000000000000000000000000000000</groupId> 
     <accountingToken>16010515000000B5E512BBA14EC030000000000000000B
     </accountingToken> 
     <replyToQueueManagerName>QM_test1000</replyToQueueManagerName>
      <replyToQueueName/> 
     <applicationIdData/> 
      <applicationOriginData/> 
     <messageType verbose="Datagram">8</messageType> 
     <format>MQSTR   </format> 
     <report>0</report> 
      <feedback>0</feedback> 
     <groupStatus/> 
      <encoding>273</encoding> 
     <characterSet>819</characterSet> 
     <expiry>-1</expiry> 
      <putDateTime>03-31-2005 15:58:18</putDateTime> 
      <putApplicationName>MQSeries Client for Java </putApplicationName> 
     <putApplicationType>28</putApplicationType> 
     <messageFlags>0</messageFlags> 
     <messageSequenceNumber>1</messageSequenceNumber> 
     <offset>0</offset> 
      <persistence>0</persistence> 
     <priority>0</priority> 
    </Document1> 
 </WSMQ> 
</ProcessData> 

Parameters Passed From Service to Business Process

The following table contains the parameters passed from the WebSphere MQ Suite Get Message service to the business process:

Parameter Description
accountingToken The accounting token of this message. Because this value could contain embedded nulls, it is a hex representation of the string so that no characters are lost.
applicationIdData The application identifier data of this message.
applicationOriginData The application origin data of this message.
characterSet The character set of this message.
correlationId The correlation identifier of this message. Because this value could contain embedded nulls, it is a hex representation of the string so that no characters are lost.
DocumentX Documents received using this service are always created sequentially starting with “1” (for example, Document1, Document2, Document3).
DocumentCount The number of documents created in ProcessData.
encoding The message encoding.
expiry The message expiry of this message.
feedback The message feedback of this message.
format The format of this message.
groupId The group identifier of this message. Because this value could contain embedded nulls, it is a hex representation of the string so that no characters are lost.
groupStatus The message group status of this message.
messageFlags The message flags of this message
messageId The message identifier of this message. Because this value could contain embedded nulls, it is a hex representation of the string so that no characters are lost.
messageSequenceNumber The message sequence number of this message.
messageType The type of message received.
offset The current message offset.
persistence The persistence setting for this message.
priority The priority setting for this message.
putApplicationName The put application name of this message.
putApplicationType The put application type of this message.
putDateTime The put date and time of this message in the format “MM-dd-yyyy HH:mm:ss”.
replyToQueueManagerName The reply to queue manager of this message.
replyToQueueName The reply to queue of this message.
report The contents of the report field of this message.
WSMQ/CompletionCode Only set if an MQException occurs and indicates the completion code.
WSMQ/ReasonCode Only set if an MQException occurs and indicates the reason code.

Parameters Passed From Business Process to Service

The following table contains the parameters passed from the business process to the WebSphere MQ Suite Get Message service:

Parameter Description
All GPM parameters See Setting Up the Service in the GPM.
wsmq_sessionid The session identifier to use from a previously established session. Valid value is the value from a previously opened session. Required.

Business Process Example

The following example illustrates how the WebSphere MQ Suite Get Message service can be used in a business process:

<process name = "GETexample">  
  <sequence name="OpenSession"> 
   <operation name="Open Session"> 
     <participant name="WSMQ_OpenSession"/> 
     <output message="toService"> 
       <assign to="." from="*"/> 
        <assign to="wsmq_hostname">some_host_name</assign> 
       <assign to="wsmq_channel">some_channel_name</assign> 
       <!-- <assign to="wsmq_debug">Yes</assign> --> 
     </output> 
      <input message="fromService"> 
       <assign to="." from="*"/> 
     </input> 
    </operation> 
 
   <sequence name="SessionOpened"> 
     <operation name="Open Queue"> 
       <participant name="WSMQ_OpenQueue"/> 
       <output message="toService"> 
         <assign to="wsmq_sessionid" from="string(wsmq_sessionid)"/> 
         <assign to="wsmq_qname">some_queue_name</assign> 
         <assign to="wsmq_MQOO_type">PUT</assign> 
         <assign to="wsmq_MQOO_failifquiescing">Yes</assign> 
       </output> 
        <input message="fromService"/> 
     </operation> 
 
     <operation name="GET message(s)"> 
       <participant name="WSMQ_GetMessage"/> 
       <output message="toService"> 
         <assign to="wsmq_sessionid" from="string(wsmq_sessionid)"/> 
         <assign to="wsmq_qname" from="some_queue_name"/> 
         <assign to="wsmq_metadata1">4095</assign> 
         <assign to="wsmq_metadata2">4095</assign> 
         <assign to="wsmq_type">GETALL</assign> 
       </output> 
        <input message="fromService"> 
         <assign to="." from="*"/> 
       </input> 
      </operation> 
 
     <operation name="Commit the GET"> 
       <participant name="WSMQ_Commit"/> 
       <output message="toService"> 
         <assign to="wsmq_sessionid" from="string(wsmq_sessionid)"/> 
       </output> 
        <input message="fromService"/> 
     </operation> 
 
     <operation name="Close Queue"> 
       <participant name="WSMQ_CloseQueue"/> 
       <output message="toService"> 
         <assign to="wsmq_sessionid" from="string(wsmq_sessionid)"/> 
         <assign to="wsmq_qname">some_queue_name</assign> 
       </output> 
        <input message="fromService"/> 
     </operation> 
 
     <sequence name="CloseSession"> 
       <operation name="Close Session"> 
         <participant name="WSMQ_CloseSession"/> 
         <output message="toService"> 
           <assign to="." from="*"/> <!—wsmq_sessionid passed by default --> 
          </output> 
         <input message="fromService"/> 
       </operation> 
      </sequence> 
 
     <onFault> 
        <operation name="Make sure session is closed"> 
          <participant name="WSMQ_CloseSession"/> 
          <output message="toService"> 
            <assign to="wsmq_sessionid" from="string(wsmq_sessionid)"/> 
         </output> 
          <input message="fromService"/> 
        </operation> 
     </onFault> 
    </sequence> <!-- end of SessionOpened sequence --> 
  </sequence> <!-- end of OpenSession sequence --> 
</process>