White Papers
Abstract
IBM WebSphere DataPower SOA Appliances are purpose built computing devices that provide many integration end points for backend services. WebSphere MQ is one of the services used with DataPower to process messages in the enterprise. The integration of DataPower application with MQ requires an understanding of many configuration objects and its settings. This tutorial presents best practices for configuring these objects to integrate with MQ, improve performance in message processing, and protect it from overutilization of resources such as CPU, memory, and connections.
Content
IBM WebSphere DataPower SOA Appliances (hereafter called DataPower) are purpose built computing devices that provide integration end points for many services. Such services include WebSphere MQ, WebSphere Service Integration Bus using Java DataPower provides a programming model for developing configuration artifacts. These artifacts include controls such as service objects, processing policies, rules, actions, client side protocol handlers, and URL openers that create business applications easily using the web graphical user interface (webGUI). For example, you can configure the Multi-Protocol Gateway (MPGW) service to implement security policies by accessing a centralized LDAP service, or messages that can be processed by using MPGW services that use MQ Queue Manager (mq-qm) object and MQ front side handlers (FSH) for the backend MQ server. These DataPower objects need configurations that can provide optimal performance as well as protection from over using resources such as CPU, memory, and connections in the appliance. This tutorial discusses best practices for integrating DataPower objects with the MQ server to effectively handle various traffic patterns. The MQ integration end points in DataPower are provided via the MQ Queue Manager Object "mq-qm" and MQ Front side handler objects. Therefore, it is necessary to present these objects and provide configuration settings for various attributes of these objects that are consistent with best practices for product integration with MQ. The mq-qm object is the primary component that provides connectivity capabilities for MQ. It manages the connection pool size and idle timeouts. It retries the behavior when the connection is not established to the backend MQ server and sync point flow. Figure 1 presents various attributes of the mq-qm object. The required attributes are marked with an asterisk that can provide connectivity to the MQ server. However, the critical attributes are identified in red, which should not use the default settings. If these attributes are configured with values as suggested by the best practices, it will provide protection as well as performance improvements for the appliance. You can use the mq-qm object with the Multi-Protocol Gateway or Webservice-Proxy service to process the MQ traffic. The main tab provides several required fields, which must be provided to connect the mq-qm object with the backend MQ server. However, there are few attributes that need special consideration to configure this mq-qm object: Note: The Cache Timeout attribute is the only way to configure a timeout value for the DataPower appliance. No other configuration setting on the DataPower appliance can time out an MQ connection. Note: If units-of-work is set to 1, the Automatic Backout should be configured as "on" with its associated Backout Threshold and Backout Queue attributes specified in the mq-qm object. Note: If the MQ FSH is configured with the concurrent MQ connections, which is greater than 1, this value should be set at a number equal to the concurrent MQ connections + 1 so as to force the roll back message to the input queue. Otherwise, the roll back message will be routed to Backout queue. If multiple devices are consuming messages from a common input queue in the MQ server and one of the devices reloads, the message that was rolled back due to this failure can be reprocessed by the MQ FSH of another active device. Note: This attribute is the only mechanism that can increase or decrease the connection pool size. While increasing this value, care should be taken to verify that the backend MQ server is provisioned to accommodate all client connections. The "MaxChannel" value should be checked in the respective MQ server to make sure the value is greater than the number of connections from all DataPower and non-DataPower clients for this MQ server. Note: This approach is useful when more than one of the Network Interfaces is configured with default routes and the MQ Queue Manager Group (mq-qm-group) is used as the fail-over mechanism for MQ traffic in the DataPower appliance. WebSphere MQ V7.0 and later releases provide sharing conversations (SHARECNV) attribute on SVRCONN channel that specifies the maximum number of conversations that can share each TCP/IP channel instance. This feature can be configured in DataPower as it uses client connection with queue manager SVRCONN channel. The default setting of sharing conversations (SHARECNV) value is zero in the DataPower mq-qm object. The same default value for MQ SVRCONN channel is 10. The sharing conversations value is negotiated between MQ server and DataPower and the lower value takes effect. However, in current versions of the DataPower firmware, the sharing conversations setting of 1 is treated as 0 when negotiating with MQ server. There are three use cases to configure sharing conversations in a DataPower mq-qm object: Set a value of 0 or 1 on the Sharing Conversations attribute of the mq-qm object in DataPower to disable sharing conversations, regardless of the MQ SVRCONN setting. Set a value of 2 or more on the Sharing Conversations attribute of the mq-qm object in DataPower and on the MQ SVRCONN channel. On average, the processing of messages from client applications is 15 percent slower when using SHARECNV(10) as compared to SHARECNV(0). Refer to Performance Implications of Sharing Conversations on Client-connection Channels. The MQ Front Side Handler (FSH) object is configured to process the client side GET and PUT operations from the MQ server queues. Figures 3 and 4 present the critical attributes highlighted in red that require user consideration while configuring this object. The MQ FSH polls the input queue based on the polling interval. It allows to Get and Put messages to the designated queues. This object is also known as the source MQ hander and needs consideration for configuring various parameters. The MQ FSH polls for messages with the MQ connection (hereafter referred to as C1). After the message is returned from the GETQ, DataPower starts processing the message, which may involve MQPUT. This takes additional connection if MQ FSH and the backend MQ URL use different mq-qm objects. However, the connection (C1) will be shared with the backend MQ URL if both front side and backend use the same mq-qm object with units-of-work configured. In the meantime, the MQ FSH will continue MQGET(s), which may remain in pending states. This increases the number of concurrent connections for the MQ FSH greater than 1. After processing all the messages, this value will become 1 on the expiration of the cache timeout that is specified in the mq-qm object. Note that even setting the concurrent MQ connection as 1, MQ FSH still can use at least two MQ connections (C1 is used for transaction processing, C2 is used to poll for an input queue). Under an extreme condition, if transaction processing takes longer than the front side time-out and there are many messages in the GETQ, then the MQ FSH can use as many connections as it is allowed by the connection pool (configured in the mq-qm object's total connection limit) to process these messages. In other words, if the request messages arrive at the GETQ with a slow rate, then MQ FSH will keep a lower number of used connections. If the request messages arrive at a higher rate, MQ FSH will use a large number of connections. In most use cases, a default value of 1 is sufficient. Setting it to a value greater than 1 may yield some performance gain, but the difference is marginal. If message ordering is required, then it must use a value of 1 as multiple MQGETs will break the message ordering. The best practice is to use the default value of 1 for most uses cases. For high volume traffic scenarios, you can use a value of 2-5 connections for this attribute in the MQ FSH configuration. When disabled, the default does not retrieve backout settings from the MQ server. If these properties already exist in the mq-qm object, the handler uses those values. The best practice is to use the default value of "off". If there is a need to use this feature, care should be taken to make sure that queues in the MQ server are configured with the backout queue name and backout count threshold. Note: When the setting of Retrieve Backout Settings is "on", it can cause performance degradation due to additional MQ API calls for each MQGET operation. For high volume MQ traffic, the best practice is to use the default value of "off". Configure Automatic Backout as "on" and provide its associated Backout Threshold value and Backout Queue Name in the mq-qm object when units-of-work is enabled for handling message ROLLBACK. The MQ URL opener is used to route the message to its destination. The best practice is to use the "Build a MQ URL" helper available in the Multi-Protocol Gateway (MPGW) service. Figure 5 shows the highlighted fields that contain values to construct a valid MQ URL for the backend destination. Example of a backend static MQ URL for Datagram traffic: Example of a backend static MQ URL for Request/Reply traffic: Syntax for a static URL to send a message: Syntax for a static URL to retrieve a message: Syntax for a dynamic URL to send or retrieve a message: To strip the headers from the back side, use the MQ URL parameter of "ParseHeaders" or its alias "ExcludeHeaders". It excludes all the headers from the payload. Note: The use of the "ParseHeaders" tag in the MQ URL is useful when the reply message contains MQRFH2 headers and these extra headers need to be removed from the payload to make it a well-formed XML payload. To overwrite the service backside timeout, use the Note: The MQ URL "TimeOut" takes precedence over the Gateway backside timeout setting. The best practice is to configure this value lower than the configured Gateway service backside timeout value. For more details, see the syntax of the MQ URL in this Information Center topic. DataPower processes MQ headers such as MQ Message Descriptor (MQMD) and MQ Rules Formatting Headers 1 and 2 (MQRFH & MQRFH2) in the processing policy. When a request message is processed in the request rule, MQMD is not altered by the Gateway service. However, MQMD can be manipulated with a specific transformation (xform or xformbin) action in the processing rule. There are two methods to manipulate MQ headers: using the header injection or using the custom stylesheet. When the MQ headers are static for request and reply messages, this method is suitable as each message type can add the necessary headers whose values do not change across multiple request or reply messages. In other words, the same MQ header values are populated for each request or reply message. Using the Gateway service's header tab, the following examples are used to populate MQ headers: Adding a new header injection parameter Using the stylesheet method Listing 1 shows the complete MQMD header with values. Listing 2 shows the stylesheet that manipulates the MQMD header. When the header injection or stylesheet method does not inject a full MQMD header, DataPower adds the missing MQMD fields with default values to construct a complete MQMD. In order to populate new values for full MQMD header fields, create the structure with the respective headers and its associated values and inject it using the stylesheet method. There are few exceptions where the above MQ header injection method does not work. In situations where the MQ URL is being used in the destination box of the Result Action, the MQMD should be injected using the "context" variable method. For example, the request rule has a need to log the MQ message with the MQMD.Expiry header being set. The message is routed using the Result Action with the MQ URL configured in the destination box. In this situation, use the "context" variable method to inject relevant MQMD headers as shown in Listing 3. Make sure that the Result Action's INPUT context is set as "EVENTS", the preceding Transform (xform) Action's OUTPUT context is defined as "EVENTS", and the above code snippet is executed using the stylesheet. There are configuration requirements for processing the MQ Datagram and Request/Reply traffic. For the Datagram traffic, the following best practice configurations are suggested: If units-of-work is enabled in the mq-qm object, the service variable "var://service/error-ignore" should be set as "1" in the Error rule to handle ROLLBACK. Listing 4 shows the code snippet to capture the response code, and then to execute "dp:reject" if the response code is "2xxx" for the MQ traffic. When units-of-work is enabled, additional tags of "Transactional=true;Sync=true" must be specified in the same MQ URL. Note that the "Sync=true" tag is used to commit the request message so that MQ application can consume this message to prepare the reply message for the "ReplyQueue". Without this "Sync=true" tag, the message in the "RequestQueue" will not be visible as it is under the sync point flow. The service variable "var://service/error-ignore" should be set as "1" in Error rule to handle ROLLBACK. Note: Make sure that the application, which prepares the reply message, injects "Request.MQMD.Msgid in Reply.MQMD.CorrelId". Otherwise, DataPower does not fetch the reply message in its response rule. Listing 5 shows the stylesheet example to save the "ReplyToQ" and "ReplyToQMgr" values in the Request rule and to inject those values in the Response rule using the MQOD structure. Note: If the backend MQ server is using a cluster, the injection of MQMD.ReplyToQMgr in MQOD is not needed. However, if the work load management feature is enabled, MQMD.ReplyToQMgr should be injected so that the MQ cluster can route the message to an alternate qmgr when the designated remote qmgr is busy. When the DataPower mq-qm object is enabled with units-of-work, it supports a one-phase COMMIT. In order to provide a guaranteed message delivery, the following conditions must be met: These two scenarios are: Based on best practice configurations, DataPower applications can provide improved performance for MQ message processing. It creates safe guards for overutilization of appliance resources such as CPU, memory, and connections. This tutorial provided configurations to integrate DataPower services with MQ with various traffic patterns that involve the Datagram and Request/Reply traffic. If the applications are configured with these best practices, they can help appliances from reloads if the MQ server is not available during downtime and can reduce connection errors for the backend MQ server. Many of our IBM colleagues in the WebSphere DataPower SQA, Development, and Support teams assisted in the preparation of this tutorial. The author would like to extend special thanks to Daniel HT Shih and John Rasmussen for their review of this tutorial.Introduction
Configuring the DataPower mq-qm object


Set a value of 2 on the Sharing Conversations attribute of the mq-qm object in DataPower and a value of 1 on the MQ SVRCONN setting.Configuring the DataPower MQ Front Side Handler object


Configuring the DataPower MQ URL opener

dpmq://LNX-DP1/?RequestQueue=QUEUE1 (Without units-of-work)dpmq://LNX-DP1/?RequestQueue=QUEUE1;Transactional=true (With units-of-work)
dpmq://LNX-DP1/?RequestQueue=QUEUE1;ReplyQueue=QUEUE2;SetReplyTo=true (Without units-of-work)dpmq://LNX-DP1/?RequestQueue=QUEUE1;ReplyQueue=QUEUE2;Transactional=true;Sync=true;SetReplyTo=true (With units-of-work) dpmq://mqQueueManagerObject/URI?RequestQueue=requestQueueName;queryParameters
dpmq://mqQueueManagerObject/URI?ReplyQueue=replyQueueName;queryParameters
mq://host:port?QueueManager=queueManager;UserName=userName;Channel=channelName;ChannelTimeout=channelTimeout; channelLimit=channelLimit;Size=maxMsgSize; MQCSPUserId=MQCSPUserID;MQCSPPassword=MQCSPPassword;queryParameters
TimeOut=<value in milliseconds> tag in the MQ URL. The best practice is to configure the "TimeOut" when the MQ URL contains the "replyQueue" tag. By using this "TimeOut" parameter in the MQ URL, the backend connection will wait for the response message until this timeout expires. If the reply is not received by the specified timeout, the backend MQ URL returns a code of 2033, indicating that there is no reply message available within the timeout period.Manipulating the MQ header in DataPower
Using the header injection method
Back (or Backend MQPUT)MQMD<MQMD><Format>MQSTR</Format><Persistence>1</Persistence></MQMD> <MQMD> <StrucId>MD </StrucId> <Version>1</Version> <Report>0</Report> <MsgType>8</MsgType> <Expiry>-1</Expiry> <Feedback>0</Feedback> <Encoding>546</Encoding> <CodedCharSetId>819</CodedCharSetId> <Format>MQSTR</Format> <Priority>0</Priority> <Persistence>0</Persistence> <MsgId>414d5120454d42444954312020202020d724c84199990002</MsgId> <CorrelId>000000000000000000000000000000000000000000000000</CorrelId> <BackoutCount>0</BackoutCount> <ReplyToQ>ADAPTERTEST.POSTFORMAT02 </ReplyToQ> <ReplyToQMgr>EMBDIT2 </ReplyToQMgr> <UserIdentifier>MUSR_MQADMIN</UserIdentifier> <AccountingToken> 16010515000000271d19306f0b7216262a1345eb03000000000000000000000b </AccountingToken> <ApplIdentityData></ApplIdentityData> <PutApplType>28</PutApplType> <PutApplName>Websphere MQ Client for Java</PutApplName> <PutDate>20061005</PutDate> <PutTime>18401655</PutTime> <ApplOriginData></ApplOriginData> <GroupId>000000000000000000000000000000000000000000000000</GroupId> <MsgSeqNumber>1</MsgSeqNumber> <Offset>0</Offset> <MsgFlags>0</MsgFlags> <OriginalLength>-1</OriginalLength> </MQMD>
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp" exclude-result-prefixes="dp"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:variable name="newMQMDStr"> <MQMD> <Format>MQSTR</Format><Persistence>1</Persistence> </MQMD> </xsl:variable> <xsl:variable name="mqmdStr"> <dp:serialize select="$newMQMDStr" omit-xml-decl="yes"/> </xsl:variable> <xsl:message dp:priority="debug"> <xsl:value-of select="concat('The New MQMD : ', $mqmdStr)"/> </xsl:message> <!-- for request rule --> <dp:set-request-header name="'MQMD'" value="$mqmdStr"/> <!-- for response rule --> <!-- <dp:set-response-header name="'MQMD'" value="$mqmdStr"/> --> <!-- adding MQ header when MQ URL open call is usedfor MQPUT--> <!-- <xsl:variable name="mqHeaders"> <header name="MQMD"><xsl:value-of select="$mqmdStr"/></header> </xsl:variable> <xsl:variable name="sendmessage"> <dp:url-open target="dpmq://DP4/?RequestQueue=QUEUE6" http-headers="$mqHeaders" response="responsecode-ignore"> <xsl:copy-of select="." /> </dp:url-open> </xsl:variable> --> </xsl:template> </xsl:stylesheet> <xsl:variable name="MQMDStr"> <MQMD> <Expiry>8000</Expiry> <Priority>0</Priority> <Format>MQSTR</Format> </MQMD> </xsl:variable> <xsl:variable name="MQMDStr2"> <dp:serialize select="$MQMDStr" omit-xml-decl="yes"/> </xsl:variable> <dp:set-variable name="'var://context/EVENTS/_extension/header/MQMD'" value="$MQMDStr2"/>
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp" exclude-result-prefixes="dp" version="1.0"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:variable name="mqrc" select="dp:response-header('x-dp-response-code')"/> <xsl:variable name="ecode" select="dp:variable('var://service/error-code')"/> <xsl:variable name="errMsg" select="concat('** The Response Code ** : ', $mqrc, ' and ** Error Code ** :', $ecode )"/> <xsl:choose> <xsl:when test="(starts-with($mqrc, '2') and (string-length(normalize-space($mqrc))= 4)) or ($ecode != '0x00000000')"> <xsl:message dp:priority="debug"> <xsl:value-of select="$errMsg"/> </xsl:message> <dp:set-variable name="'var://context/ERROR/err-msg'" value="$errMsg"/> <dp:reject override="true"><xsl:value-of select="$errMsg"/></dp:reject> </xsl:when> <xsl:otherwise> <xsl:message dp:priority="debug"> <xsl:value-of select="$errMsg"/> </xsl:message> <dp:accept/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
<dp:set-response-header name="'ReplyToQ'" value="''"/>.
<dp:set-response-header name="'ReplyToQ'" value="''"/>.<dp:set-response-header name="'ReplyToQM'" value="''"/>. <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" extension-element-prefixes="dp" exclude-result-prefixes="dp"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:variable name="rule-type" select="dp:variable('var://service/transaction-rule-type')"/> <xsl:choose> <!-- Request Rule only --> <xsl:when test="$rule-type = 'request'"> <xsl:variable name="entries" select="dp:request-header('MQMD')"/> <xsl:variable name="header" select="dp:parse($entries)"/> <!-- save ReplyToQ and ReplyToQMgr values --> <dp:set-variable name="'var://context/MYMQMD/ReplyToQ'" value=""$header//ReplyToQ"/> <dp:set-variable name="'var://context/MYMQMD/ReplyToQMgr'" value=""$header//ReplyToQMgr"/> <xsl:message dp:priority="debug"> <xsl:value-of select="concat ('Request MQMD : ', dp:request-header('MQMD'))"/> </xsl:message> </xsl:when> <!-- Response rule only --> <xsl:when test="$rule-type = 'response'"> <xsl:variable name="custMQODStr"> <MQOD> <Version>2</Version> <ObjectName> <xsl:value-of select="dp:variable('var://context/MYMQMD/ReplyToQ')"/> </ObjectName> <ObjectQMgrName> <xsl:value-of select="dp:variable('var://context/MYMQMD/ReplyToQMgr')"/> </ObjectQMgrName> </MQOD> </xsl:variable> <xsl:variable name="mqodStr"> <dp:serialize select="$custMQODStr" omit-xml-decl="yes"/> </xsl:variable> <xsl:message dp:priority="debug"> <xsl:value-of select="concat('Response MQOD : ', $mqodStr)"/> </xsl:message> <dp:set-response-header name="'MQOD'" value="$mqodStr"/> </xsl:when> </xsl:choose> </xsl:template> </xsl:stylesheet> One-phase COMMIT requirements
Conclusion
Acknowledgments
IBM WebSphere DataPower SOA Appliances product documentation IBM Redbook: WebSphere DataPower SOA Appliance Handbook IBM Redbook: Strategic overview of WebSphere Appliances IBM Redbook: DataPower SOA Appliance Administration, Deployment, and Best Practices IBM RedBook: DataPower SOA Appliance Service Planning, Implementation, and Best Practices DataPower integration with WebSphere MQ Resource management and analysis best practices for WebSphere DataPower WebSphere Technical Exchange: Enabling WebSphere MQ Traffic with WebSphere DataPower - Use Case Scenarios Integrating WebSphere MQ V7 Publish/Subscribe Feature with WebSphere DataPower WebSphere DataPower discussion forum DataPower does not inject MQMD.CorrelId in fault message in error rule when request MQMD.CorrelId contains non-zero values for the traffic pattern of MQ-to-HTTP How to configure DataPower dynamic MQ URL to use MQ SSL channel Configuring DataPower MQ client to use SSL in mutual authentication mode using Key Database (KDB) Method The number of concurrent MQ connections in DataPower's MQ front-side handler (FSH) When to enable Conversation Sharing in DataPower MQ Queue Manager (mq-qm) object WebSphere DataPower spikes with high CPU when WebSphere MQ connection is unavailable Gathering WebSphere DataPower CPU and memory information WebSphere DataPower SOA Appliance statistics gathering How does the front side timeout work? What IBM DataPower timeouts are used in specific configuration methods
Was this topic helpful?
Document Information
Modified date:
08 June 2021
UID
ibm11109661