IBM MQ Message Duplication

IBM Support has a technical note labeled Does MQ have a feature to generate automatically a duplicate message?.

The options listed on that page are to use Pub/Sub or programs qload and dmpmqmsg. You can also use MQ Visual Edit and MQ Batch Toolkit to get messages from a queue and write the message to a file. You can even use the open source programs Message Multiplexer (MMX) and/or Msg2File to do it too.

The problem with these programs is that if there are getters (applications performing MQGET API calls) then those programs will NOT capture all of the messages flowing through the queue.

The Pub/Sub solution is ok IF the user does not care about duplicating the message’s MQMD fields. The instructions on this page labeled MQ: You want to put a message into a queue and you want to generate duplicate messages into other queues has the following warning:

NOTE: Strictly speaking, the messages received by Q1 and Q2 are NOT truly identical. Even though they will have the same payload (text string ‘TEST’) and same characteristics, each message will have its own unique message-id.

Notice that the only differences in this particular example are the last 2 characters from “MsgId” and CorrelId”.

The only true solution to EXACTLY replicate a message and its MQMD fields is Capitalware’s MQ Message Replication (MQMR). MQMR will duplicate/clone messages being written (via MQPUT or MQPUT1 API calls) to an application’s output queue and MQMR will write the exact same messages to ‘n’ target queues (‘n’ can be up to 100). When MQMR replicates a message both the message data and the message’s MQMD structure will be cloned. This means that the fields of the MQMD structure (i.e. PutTime, MessageId, CorrelId, UserId, etc..) will be exactly the same as the original message’s MQMD structure.


MQMR can clone messages being written to any MQ queue type. i.e. local, alias, remote and/or cluster queues (including transmission queues).

Existing applications do not need to be modified or updated nor is it necessary to set up Publish/Subscribe to use MQMR. MQMR is deployed and configured at the queue manager level; hence, no application changes are required.

MQMR includes 2 auxiliary programs to help with the management of the cloned/replicated messages:

  • MQ Queue To SQLite DB (MQ2SDB) program will offload MQ messages to an SQLite database.
  • SQLite DB To MQ Queue (SDB2MQ) program will load SQLite database rows into messages in an MQ queue.

Capitalware offers free trials of MQMR including free support, so if anyone would like to try out MQMR then send the email to support@capitalware.com

Regards,
Roger Lacroix
Capitalware Inc.

Capitalware, IBM i (OS/400), IBM MQ, Linux, MQ Message Replication, Raspberry Pi, Unix, Windows Comments Off on IBM MQ Message Duplication

Interesting Blog Item: IBM Knowledge Center – LATEST!

Morag Hughson of MQGem has a new blog posting called IBM Knowledge Center – LATEST! regarding a new feature in the IBM Knowledge Center.

Instead of providing a link with the MQ version number, you can swap the version number for the word “latest”. This is a cool feature for putting links in a blog posting or forums on the internet. The only “gotcha” is that you have to manually edit the link yourself which of course can lead to typos hence an invalid link.

IBM should add a “Latest Link” link on the button bar on each page next to “Print PDF Help” buttons, so that you don’t have to manually edit the link.

Regards,
Roger Lacroix
Capitalware Inc.

HPE NonStop, IBM i (OS/400), IBM MQ, IBM MQ Appliance, Linux, macOS (Mac OS X), Programming, Security, Unix, Windows, z/OS Comments Off on Interesting Blog Item: IBM Knowledge Center – LATEST!

IBM MQ End of Service Dates

So, what version of IBM MQ (aka WebSphere MQ & MQSeries) are you running? Are you behind in upgrading your release of MQ?

Everybody “should be” running IBM MQ v9.0, v9.1 or v9.2, if you want support from IBM.

In case it has slipped your mind, here is a list of IBM MQ releases and there end of service dates:

Note: IBM v9.1 and v9.2 do not yet have end of service dates.

Regards,
Roger Lacroix
Capitalware Inc.

IBM i (OS/400), IBM MQ, IBM MQ Appliance, Linux, Unix, Windows, z/OS Comments Off on IBM MQ End of Service Dates

Reasons MQSC Commands for an AMQP Channel May Not Work

IBM has posted a support document describing the various reasons why an MQSC command may not work for an AMQP channel.
https://www.ibm.com/support/pages/node/6411487

Regards,
Roger Lacroix
Capitalware Inc.

Education, IBM MQ, IBM MQ Appliance, Linux, Unix, Windows Comments Off on Reasons MQSC Commands for an AMQP Channel May Not Work

Using Loki and Grafana with MQ Logs

Mark Taylor of IBM has posted a blog item on using Loki and Grafana software to parse and display information from MQ logs.
https://marketaylor.synology.me/?p=838

Regards,
Roger Lacroix
Capitalware Inc.

IBM MQ, IBM MQ Appliance, Linux, Unix, Windows Comments Off on Using Loki and Grafana with MQ Logs

Local Transactions Using IBM MQ and the JMS API

Olja Rastic-Dulborough has written an article that introduces the user to the concepts of local transactions using IBM MQ and JMS.
https://developer.ibm.com/components/ibm-mq/articles/an-introduction-to-local-transactions-using-mq-and-jms/

Regards,
Roger Lacroix
Capitalware Inc.

Education, HPE NonStop, IBM i (OS/400), IBM MQ, IBM MQ Appliance, Java, JMS, Linux, macOS (Mac OS X), Programming, Raspberry Pi, Unix, Windows, z/OS Comments Off on Local Transactions Using IBM MQ and the JMS API

Join Microsoft and the Java developer community at Devnexus 2021

Microsoft is sponsoring and participating in Devnexus 2021, you can read more about it here:
https://techcommunity.microsoft.com/t5/apps-on-azure/join-microsoft-and-the-java-developer-community-at-devnexus-2021/ba-p/2114247?WT.mc_id=appsonazure-twitter-shboyer

Microsoft is excited to be sponsoring and participating in Devnexus 2021, and you might be wondering—what is Microsoft doing with Java? Quite a bit actually! We’ve been busy releasing new features and functionality to support Java apps on Azure, contributing to open-source projects, and improving our developer tools experience. Read on to find out more about Java at Microsoft and a get a preview of our sessions at Devnexus this year.

Java on Azure

Regards,
Roger Lacroix
Capitalware Inc.

Education, Java, JMS, Programming, Windows Comments Off on Join Microsoft and the Java developer community at Devnexus 2021

Part 2: Customer Question Regarding Automation with MQ Visual Edit

So, continuing with the customer, after they successfully tested MQ Batch Toolkit on Windows with a scheduled Windows batch script, they had a new question:

how can we be sure that the file.txt are send in the proper order ( chronological) from the 1 to last ( by time)

So, here are the batch/scripts files from this blog posting updated to handle getting a list of files by sorted date.

Windows Batch File:

@echo off
setlocal

cd /D C:\Capitalware\MQBT\

for /F %%f in ( 'dir C:\app\some\place\*.txt  /A-D-H /O:D /B' ) do (
  mqbt insert -p MQWT1 -q TEST.Q1 -S -f %%f
  move /Y %%f C:\app\some\place\backup\
)

endlocal

Notes:
– The “/A-D-H” parameter says do not include directories or hidden files.
– The “/O:D” parameter says sort by date.
– The “/B” parameter says only output the file name.

Linux/macOS/Raspberry Pi Script:

#!/bin/sh

PATH="/home/mqm/Capitalware/MQBT:$PATH"
export PATH

cd /home/mqm/Capitalware/MQBT/

ls -tr /app/some/place/*.txt | while read entry
do
  if [ -f "$entry" ];then
     mqbt insert -p MQWT1 -q TEST.Q1 -S -f "$entry"
     mv -f "$entry" /app/some/place/backup/
  fi
done

Notes:
– The “-tr” parameter of the ls command says sort files by time oldest first.

Hope that helps.

Regards,
Roger Lacroix
Capitalware Inc.

Capitalware, IBM MQ, IBM MQ Appliance, Linux, macOS (Mac OS X), MQ Batch Toolkit, MQ Visual Edit, Programming, Raspberry Pi, Windows Comments Off on Part 2: Customer Question Regarding Automation with MQ Visual Edit

Video: How to boost your business with IBM MQ

Marcus Kaye of IBM has created and posted a video on IBM MQ titled: “How to boost your business with IBM MQ

Regards,
Roger Lacroix
Capitalware Inc.

HPE NonStop, IBM i (OS/400), IBM MQ, IBM MQ Appliance, Linux, Unix, Windows, z/OS Comments Off on Video: How to boost your business with IBM MQ

Customer Question Regarding Automation with MQ Visual Edit

Yesterday, I got the following question from a customer:

We have a system that generates files every couple of minutes, they are stored in a folder. Can we send those message contents using MQ visual edit to an mq server as soon as they become available in that folder?

My answer to the customer was:

MQ Visual Edit is a GUI program and does not have any scripting abilities.

We have another program called MQ Batch Toolkit that is a command-line version of MQ Visual Edit (so to speak). You could create a schedule event for every minute or 2 which would list the files of the directory and pass each file to MQ Batch Toolkit for processing. After processing the script can move or delete the file.

The reason I decided to write about this question is because the question and answer seem super simple to implement but the devil is always in the details. The gotcha that some people may not think about is the timing issue when using wildcards for path and file names.

Example script/batch file:

mqbt import -p MQWT1 -q TEST.Q1 -f /app/some/place/*
mv /app/some/place/* /app/some/place/backup/

The script file seems to do the job. First, it will load each file in the directory as a (separate) message to a queue then it will move all files in that directory to a backup directory.

Here’s where support will get that 2:00AM phone call about missing messages. It doesn’t matter the tool/solution you are using, like MQBT, when they are invoked, they will retrieve a directory listing then iterate over that list of files, putting each file as a message to a queue. BUT what happens if 1 or more files arrive after the tool gets the directory listing and before the move command is executed? Well, the tool will not see the file but when the move command is executed, it will see the file and move it.

The other issue is what happens if the program writing the files to the directory is in the middle of writing a file when the script/batch file is started. You don’t want half a file to be put as a message to a queue!!!

Note: What if the script didn’t use a move command but rather a delete command? The evidence of what happened would be gone and of course, people would start claiming that MQ lost their message!!!

Sometimes the simplest solution is what is required. Have the script/batch file processor feed the programs 1 file at a time (the same file).

Solution: The issue with the putting of a partial file can be solved by having the other program write the file to a temporary directory and when it is done writing, move the file to the watched directory.

The examples below will have the script/batch processor retrieve a list of files that have a file extension of “txt” and on the MQPUT, MQBT will set the MQMD Format field as string (i.e. MQSTR) because of the ‘-S’ parameter. For a full list of MQBT parameters, see the MQ Batch Toolkit Installation and Operation manual.

Windows Batch File:

@echo off
setlocal

cd /D C:\Capitalware\MQBT\

for %%f in (C:\app\some\place\*.txt) do (
  mqbt insert -p MQWT1 -q TEST.Q1 -S -f %%f
  move /Y %%f C:\app\some\place\backup\
)

endlocal

Linux/macOS/Raspberry Pi Script:

#!/bin/sh

PATH="/home/mqm/Capitalware/MQBT:$PATH"
export PATH

cd /home/mqm/Capitalware/MQBT/

for entry in "/app/some/place/"*.txt
do
  if [ -f "$entry" ];then
     mqbt insert -p MQWT1 -q TEST.Q1 -S -f "$entry"
     mv -f "$entry" /app/some/place/backup/
  fi
done

Hope that helps.

Regards,
Roger Lacroix
Capitalware Inc.

Capitalware, IBM MQ, IBM MQ Appliance, Linux, macOS (Mac OS X), MQ Batch Toolkit, MQ Visual Edit, Programming, Raspberry Pi, Windows Comments Off on Customer Question Regarding Automation with MQ Visual Edit