The top 15 WebSphere MQ best practices

This article simplifies this maze by listing 15 or so widely recognized best practices for using WebSphere MQ to implement message queuing. This article describes the most common best practices in designing, building, running, and maintaining WebSphere MQ solutions in order to achieve the full benefits of WebSphere MQ.

MQ File Transfer Edition Error and Trace Handling

MQ File Transfer Edition Error and Trace Handling

The following are the trace levels that can be specified:

1. off

2. flow

3. moderate

4. verbose

5. all

Step 1: Set Agent Trace Level

Run the following command on Agent AGT1WIN, select your specific trace level:

fteSetAgentTraceLevel -traceLevel all AGT1WIN

Step 2: View Trace file

Navigate to: *\WMQFTE\config\QM_COORD1\agents\AGT1WIN\logs

Optional is to enable trace only for specific criteria:

Only enable trace for a specific transfer:

fteCreateTransfer -trace “” -sa AGT1WIN -da AGT1LIN_XXX -dm QM_AGENTHOST2 -sd leave -t binary -de overwrite -dd “/tmp” “C:\student\*.jpg”

View the new trace by navigating to: *\WMQFTE\config\ QM_COORD1\agents\AGT1WIN\logs

Disable trace by setting trace level to off:

fteSetAgentTraceLevel -traceLevel off AGT1WIN

Setup Websphere MQ File Transfer Ant Script using Eclipse

Setup MQ File Transfer with Ant

Prerequistes confirm that an agent has been created and is running.

Step 1: Open Websphere MQ Explorer

Select Window à Preferences

Select the WebSphere MQ Explorer tab.

Select the radio button next to “in an Eclipse Workbench” under Startup. This will enable the WebSphere MQ Explorer to be used for other perspectives, such as Resource, Java, and the debug perspective.

Step 2: Now click on General Editors File Associations.

Step 3: Add New File Type

Press Default button

Press OK

Step 4: Change MQ Explorer Perspective -> Resource

Step 5: Modify Ant Runtime environment

Navigate to Windows -> Perference menu item

Expand the Ant folder.

Select the Runtime folder.

Select the Global Entries folder.

Press the Add External JAR’s… button.

Navigate to Navigate to *\WMQFTE\lib folder and add all the jars.

Step 6: Set Ant Home

(Follow on Step 5)Click the Ant Home button and navigate to *\WMQFTE\ant

Click OK to close the Preference window

Step 7: Import Ant Project

Select File->New->Other->Java Program from Exisiting Ant Build File

Step 8: Execute Ant File

<?xml version=’1.0′?>

<project xmlns:fte=”” name=”FTECOPY1″ default=”job” basedir=”.” >

<description> Simple FTE Transfer </description>

<!– set global properties for this FTE JOB –>

<target name=”init” description=”Set Global variables”>

<property name=”srcfile” value=”d:\Applications\disk1\File4.txt” />

<property name=”dstfile” value=”c:\File4.txt” />

<property name=”SNODE” value=”AGT1WIN@QM_AGENTHOST1″/>

<property name=”DNODE” value=”AGT1WIN@QM_AGENTHOST1″/>

<property name=”cmdqm” value=”QM_CMD1″/>

<property name=”jobName” value=”FTECOPY1″ />

<property name=”departId” value=”Demo” />

<fte:uuid length=”8″ property=”jobNumber” />


<target name=”step1″ depends=”init” description=”Transfer file”>

<fte:filecopy cmdqm=”${cmdqm}”

src=”${SNODE}” dst=”${DNODE}”






<fte:entry name=”departId” value=”${departId}” />

<fte:entry name=”jobNumber” value=”${jobNumber}” />


<fte:filespec srcfilespec=”${srcfile}” dstfile=”${dstfile}” overwrite=”true”/>



<target name=”check1″ depends=”step1″ description=”Check return code and set variables”>

<condition property=”step1-failed”>


<equals arg1=”${step1.result}” arg2=”0″ />



<fail if=”step1-failed”

message=”step1 transfer failed MAXRC=${step1.result}.”>


<echo message=”The FTE  transfer has succeeded!” />


<target name=”job” depends=”init, step1,check1″ />


Step 9: Run Ant File

Right click on ant xml file and select Run As -> Ant Build

An sucessful transfer output:

Setup Websphere MQ File Transfer Database Logger

Step 1. Run the following db2 command:

— drop if necessary and then create FTELOGDB

echo *******************************************************

echo the following command may fail because the database did

echo NOT previously exist, this is an acceptable error

echo *******************************************************

drop database FTELOGDB

echo — Creating database FTELOGDB

create database FTELOGDB

echo — Connect to FTELOGDB database

connect to FTELOGDB user esbuser using wesb4soa

— catalog FTELOGDB as a odbc data source

catalog system odbc data source FTELOGDB

list system odbc data sources

echo — now create the schemae, tables and views

echo — use this db2cmd command console

echo — it is already connected to the database

Step 2: Create the DB2 Schema Tables

Navigate to: C:\Program Files\IBM\WMQFTE\tools\sql

Execute the following command:

db2 –v -t –f ftelog_tables_db2.sql

Step 3: Configure the Database Logger Properties File

Navigate to: *\WMQFTE\config

Open file in Notepad:

Edit the following values:


(Coordinator Queue Manager Name)

(Database Name created in Step 1)


(DB2 Driver Path)


(Library Path to DB2)

Step 4: Setup the transaction manager

Open MQ Explorer right click on the Coordinator Queue Manager and select Properties. Under XA Resource Manager click the ‘Add’ button.

Enter FTELOGDB as the Name.

Enter jdbcdb2.dll as the SwitchFile.

Enter db=FTELOGDB,uid=db2admin,pwd=db8admin,toc=p,tpm=mq as the XAOpenString.

Make sure the ThreadOfControl is set to Process.

Press the OK button to add the XA resource manager to the queue manager.

Click OK

Step 5: Copy the jdbcdb2.jar to the existing folder

Navigate to *\IBM\WebSphere MQ

execute the following command to copy the jdbcdb2.jar file: copy java\lib\jdbc\jdbcdb2.dll exits

Step 6: Execute a Controlled Stop of the Coordinator Queue Manager

Step 7: Start the Database Logger

Execute the following command in *\MQFTE\tools\bin: fteStartDatabaseLogger –F

Step 8: Run a new Transfer

Navigate to ‘Manage File Transfer’ and connect the Coordinator Queue Manager and right click on Transfer Log and select ‘New Transfer’

Select a Agent, file to transfer and Click Next till you see the following window:

Add two metadata attribute value pairs:

Click Next and Finish to start file transfer

Step 9: Open DB2 Control Panel to View the Database Logger Table

Navigate to your Database Logger Database -> Views -> Basic_Transfer_Details.

Navigate to your Database Logger Database -> Tables -> Metadata.

Optional Stop Database Logger:

Navigate to *\MQFTE\tools\bin\fteStopDatabaseLogger.cmd

Database Logger will stop succesfully else see result of error.

WebSphere MQ File Transfer Edition – Definition File

FTE Definition File Transfer

Transfer definition files enable the creation of complex transfer requests. The transfer definition file is a XML file that describes the source and destination directories or files or datasets.

Step 1: Create a Definition Transfer File (below is an example):

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




<item checksumMethod=”none” mode=”text”>

<source recursive=”false” disposition=”leave”>



<destination type=”directory” exist=”overwrite”>




<item checksumMethod=”none” mode=”binary”>

<source recursive=”false” disposition=”leave”>



<destination type=”directory” exist=”overwrite”>





Step 2: fteCreateTransfer -sa AGT1WIN -da AGT1LIN -dm QM_AGENTHOST2 -td E:\student\GroupTransferSpecification.xml

– sa is the source agent name

-da is the destination agent name

-dm is the destination Queue Manager

-td is the XML Definition File

Types of Websphere MQ queues

Local queue object
A local queue object identifies a local queue belonging to the queue manager to which the application is connected. All queues are local queues in the sense that each queue belongs to a queue manager and, for that queue manager, the queue is a local queue.
Remote queue object
A remote queue object identifies a queue belonging to another queue manager. This queue must be defined as a local queue to that queue manager. The information you specify when you define a remote queue object allows the local queue manager to find the remote queue manager, so that any messages destined for the remote queue go to the correct queue manager.Before applications can send messages to a queue on another queue manager, you must have defined a transmission queue and channels between the queue managers, unless you have grouped one or more queue managers together into a cluster. For more information about clusters, see Remote administration using clusters

Alias queue object
An alias queue allows applications to access a queue by referring to it indirectly in MQI calls. When an alias queue name is used in an MQI call, the name is resolved to the name of either a local or a remote queue at run time. This allows you to change the queues that applications use without changing the application in any way; you merely change the alias queue definition to reflect the name of the new queue to which the alias resolves.An alias queue is not a queue, but an object that you can use to access another queue. 

Model queue object
A model queue defines a set of queue attributes that are used as a template for creating a dynamic queue. Dynamic queues are created by the queue manager when an application issues an MQOPEN request specifying a queue name that is the name of a model queue. The dynamic queue that is created in this way is a local queue whose attributes are taken from the model queue definition. The dynamic queue name can be specified by the application, or the queue manager can generate the name and return it to the application.Dynamic queues defined in this way can be temporary queues, which do not survive product restarts, or permanent queues, which do. 

Lightweight Publish/subscribe messaging protocol

The mqtt protocol is based on the principle of publishing messages and subscribing to topics, or “pub/sub”. Multiple clients connect to a broker and subscribe to topics that they are interested in. Clients also connect to the broker and publish messages to topics. Many clients may subscribe to the same topics and do with the information as they please. The broker and mqtt act as a simple, common interface for everything to connect to. This means that you if you have clients that dump subscribed messages to a database, to twitter, pachube or even a simple text file, then it becomes very simple to add new sensors or other data input to a database, twitter or so on.