Saturday, February 10, 2018

The WebSphere MQ Queue Load / Unload Utility

Backup all the messages in the queue.
qload –I <QName> -m <QmgrName> -dA –f <FilePath>

Backup first message.
qload -i<QName> -m <QmgrName> -dA –r 1 –f <FilePath>

Remove first message with taking a backup.
qload –I <QName> -m <QmgrName> -dA –r 1 –f <FilePath>

Cleanup the queue after taking backup of all the messages is queue:
qload -I<QName> -m<QmgrName> -dA –f  <FilePath>

Example:-

To backup all msgs
./qload –I TELEXQueue -m QM1  -dA -f /tmp/ TELEXQueue.all.20140327.txt

To backup and remove the message
./qload -I TELEXQueue -m QM1  -dA -f /tmp/ TELEXQueue _3.all.20140805_1940.txt

To backup and remove first 15 MSGS
./qload -I TELEXQueue -m QM1  -r#15 –f /tmp/ TELEXQueue _15_7PM.txt
  
To backup and remove first message
./qload -I TELEXQueue -m QM1  -r1 –f /tmp/ TELEXQueue.txt

How to Load/UnLoad messages from Websphere MQ Queues Using Qload & Unload Utility

The WebSphere MQ Queue Load / Unload Utility allows the user to copy or move the contents of a queue, its messages, to a file. This file can be saved away as required and used at some later point to reload the messages back onto the queue. This file has a specific format understood by the utility, but is human-readable, so that it can be updated in an editor before being reloaded.

Create Queue Manager:
 crtmqm QM1
start Queue mqnqger:
strmqm QM1
Create local queues:
runmqsc QM1
DEFINE QLOCAL(Q1)
DEFINE QLOCAL(Q2)

Put 10 messages into queue1

Sample Commands :

1. Backup messages from a Queue to a file:
 qload –m QM1 –i Q1 –f /tmp/bkpmsg

2. import messages from a file to the queue:
qload –m QM1 –o LQ1 –f /tmp/bkpmsg

3. Copying messages from a queue to another queue:
qload –m QM1 –i Q1 –o Q2

4. Copying certain number of messages from a queue to another queue:
(e.g) we need to copy first 15 messages from a Q1 to Q2
qload –m QM1 –i Q1 –o Q2 –r#20

“-r” Parameter:
x  =  Process x messages only
x..y  =  Process messages between x and y
X#y  =  Process messages from x to y count
#y  =  Process first y count of messages (just like in e.g)

5. Move entire message from a queue to another queue:
qload –m QM1 –i Q1 –o Q2

6. Unload and remove 10 messages, starting at message 530:

qload –m QM1 –I Q1 –f /tmp/bkpmsg –dA –r53#10

7.Unload and remove messages from 43 to 52:

qload –m QM1 –I Q1 –f /tmp/bkpmsg –dA –r43..52

No messages are removed from the queue as the lower case “i” instructs qload to use browse.

8.Unload and remove first message on queue Q1, with deletion:

qload –m QM1 –I Q1 –f /tmp/bkpmsg –dA –r1




No comments:

Post a Comment