Websphere Message Broker JMS flow

Below is a basic Websphere Message Broker JMS flow using Websphere MQ JMS.

Setup of Websphere MQ for JMS flow:

Step 1: Create JMS Initial Context

Step 2: Create Connection Factory

Specify the WMB Queue Manager as the JMS Queue Manager

Easy way to JMS Queues it to create a Lcoal Queue and right clicking on it and selecting ‘Create JMS Queue’

Step 3: Specify a JMS Destination

Step 4: Deploy and Test the flow

JMS flow is great for integrating with Websphere Application Server where an application executes code and put the result on a JMS queue, the JMS picks the information up and processes by doing validation, transformation and mediation.

Important to note is that Websphere Message Broker only supports Websphere JMS and no other JMS provider.

Websphere Transformation Extender with Websphere MQ

How do you set a input or Output Card to post the transformed or incoming file to a Websphere MQ queue?

This will show how WTX can GET or PUT a untransformed or transformed input or output to a MQ queue.

Step 1: Open up WTX Design Studio and create a Transformation map with input and output card.

Step 2:  Specify the Map Location for the WTX input or output card (depending if you want the message to come from MQ or to put a transformed data to an MQ queue)

Step 3: Select the source to be Websphere MQ (server) and specify the Queue Manager name and Queue you want to place or put the message:

-QMN YOUR_QUEUE_MANAGER_NAME -QN YOUR_QUEUE_NAME

Test this by putting a message on that queue and running the transformation map.

RFH2 Header transform with Datapower

Below is the RFH2 Transform xsl to convert a message to Websphere MQ format and append userid, ipaddress, filename and filepath for dynamic routing of messages.

<?xml version=”1.0″ encoding=”UTF-8″?>

<xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform&#8221; version=”1.0″
extension-element-prefixes=”dp”
exclude-result-prefixes=”dp func ag”>
<xsl:template match=”/”>
<xsl:variable name=”userid” select=”dp:auth-info(‘basic-auth-name’)”/>
<xsl:variable name=”ipaddress” select=”dp:request-header(‘X-Client-IP’)”/>
<xsl:variable name=”filename” select=”ag:substring-after(dp:variable(‘var://service/URI’),’/’)”/>
<xsl:variable name=”filepath” select=”substring(dp:variable(‘var://service/URI’),1,string-length(dp:variable(‘var://service/URI’)) – string-length($filename))”/>
<xsl:variable name=”MQMD”>
<MQMD>
<Format>MQHRF2</Format>
<Persistence type=”MQLONG”>0</Persistence>
</MQMD>
</xsl:variable>
<xsl:variable name=”RFH2″>
<MQRFH2>
<StrucId>RFH</StrucId>
<Version>2</Version>
<Format>MQSTR</Format>
<NameValueData>
<NameValue>
<usr>
<userid><xsl:value-of select=”$userid”/></userid>
<filePath><xsl:value-of select=”$filepath”/></filePath>
<fileName><xsl:value-of select=”$filename”/></fileName>
<ipaddres><xsl:value-of select=”$ipaddress”/></ipaddres>
</usr>
</NameValue>
</NameValueData>
</MQRFH2>
</xsl:variable>
<xsl:variable name=”mqmdStr”>
<dp:serialize select=”$MQMD” omit-xml-decl=”yes”/>
</xsl:variable>
<xsl:variable name=”rfh2Str”>
<dp:serialize select=”$RFH2″ omit-xml-decl=”yes”/>
</xsl:variable>
<dp:set-request-header name=”‘MQMD'” value=”$mqmdStr”/>
<dp:set-request-header name=”‘MQRFH2′” value=”$rfh2Str”/>
</xsl:template>
<func:function name=”ag:substring-after”>
<xsl:param name=”string”/>
<xsl:param name=”delimiter”/>
<xsl:choose>
<xsl:when test=”contains($string,$delimiter)”>
<func:result select=”ag:substring-after(substring-after($string,$delimiter),$delimiter)”/>
</xsl:when>
<xsl:otherwise>
<func:result select=”$string”/>
</xsl:otherwise>
</xsl:choose>
</func:function>
</xsl:stylesheet>

<?xml version=”1.0″ encoding=”UTF-8″?><xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform&#8221; version=”1.0″    xmlns:dp=”http://www.datapower.com/extensions”    xmlns:func=”http://exslt.org/functions”    xmlns:ag=”http://demo.ibm.com/functions”    extension-element-prefixes=”dp”    exclude-result-prefixes=”dp func ag”>        <xsl:template match=”/”>                <xsl:variable name=”userid” select=”dp:auth-info(‘basic-auth-name’)”/>        <xsl:variable name=”ipaddress” select=”dp:request-header(‘X-Client-IP’)”/>        <xsl:variable name=”filename” select=”ag:substring-after(dp:variable(‘var://service/URI’),’/’)”/>        <xsl:variable name=”filepath” select=”substring(dp:variable(‘var://service/URI’),1,string-length(dp:variable(‘var://service/URI’)) – string-length($filename))”/>                <xsl:variable name=”MQMD”>            <MQMD>                <Format>MQHRF2</Format>                <Persistence type=”MQLONG”>0</Persistence>            </MQMD>        </xsl:variable>                        <xsl:variable name=”RFH2″>            <MQRFH2>                <StrucId>RFH</StrucId>                <Version>2</Version>                <Format>MQSTR</Format>                <NameValueData>                    <NameValue>                        <usr>                            <userid><xsl:value-of select=”$userid”/></userid>                            <filePath><xsl:value-of select=”$filepath”/></filePath>                            <fileName><xsl:value-of select=”$filename”/></fileName>                            <ipaddres><xsl:value-of select=”$ipaddress”/></ipaddres>                                                    </usr>                    </NameValue>                </NameValueData>            </MQRFH2>        </xsl:variable>                <xsl:variable name=”mqmdStr”>            <dp:serialize select=”$MQMD” omit-xml-decl=”yes”/>        </xsl:variable>                <xsl:variable name=”rfh2Str”>            <dp:serialize select=”$RFH2″ omit-xml-decl=”yes”/>        </xsl:variable>                <dp:set-request-header name=”‘MQMD'” value=”$mqmdStr”/>        <dp:set-request-header name=”‘MQRFH2′” value=”$rfh2Str”/>            </xsl:template>        <func:function name=”ag:substring-after”>        <xsl:param name=”string”/>        <xsl:param name=”delimiter”/>        <xsl:choose>            <xsl:when test=”contains($string,$delimiter)”>                <func:result select=”ag:substring-after(substring-after($string,$delimiter),$delimiter)”/>            </xsl:when>            <xsl:otherwise>                <func:result select=”$string”/>            </xsl:otherwise>        </xsl:choose>    </func:function>    </xsl:stylesheet>