How to Automate Dead
Letter Handler Mechanism using Triggering setup.
Make Inter communication between
the 2 Queue managers (example A & B).
Change
Destination Queue manager DEADQ(DEADQ)
ALTER
QMGR DEADQ(DEADQ)
Create a
local queue and assign SYSTEM.DEAD.LETTER.QUEUE attributes.
DEFINE
QLOCAL (DEADQ) LIKE(SYSTEM.DEAD.LETTER.QUEUE)
Dead Letter Handler
Techniques:
Scenario 1: Configuring the DLQ
Handler as a server service object.
If the receiver channel is not
able to put the message in the destination queue, then those messages are
be placed in the DLQ of the
remote WebSphere MQ queue manager, provided a DLQ is defined for it.
The DLQ Handler is kept waiting
for incoming messages on the DLQ. You specify the DLQ to accept
undelivered messages using the
queue manager menu option Properties => Default dead queue. For
example, in Figure 1, the name of
the DLQ for undelivered messages for the IBMQMR queue manager is specified as
DEADQ:
1.
Check
the Dead Letter queue is presented or Not.
To run
the DLQ handler as a service, you need to define a server service object in
that queue manager. This example uses a batch file and rules table for the DLQ
Handler.
2.
Create dlqhandler.bat
and copy the below details into the file and copy this file into D:\MQ\ dlqhandler.bat
cd "C:\Program
Files\IBM\WebSphere MQ\bin"
runmqdlq %1 %2 %3 %4
Ex:
The
rules table should be defined with some REASON and ACTION sequence and WAIT
(YES), which means that the DLQ Handler waits indefinitely for further messages
to arrive on the DLQ
Rule Table Definition:
RULETBL.RUL:
The
content of rule table definition:
INPUTQ('DEADQ')
INPUTQM(A) RETRYINT(45) WAIT(YES)
REASON(MQRC_Q_FULL)
ACTION(FWD) FWDQ(BLOCAL) FWDQM(B)
Listing 3 Define server service object for DLQ Handler.
DEFINE
SERVICE(dlqhandler) +
SERVTYPE(SERVER)
+
CONTROL(MANUAL)
+
STARTCMD('C:\IBM\WebSphere\MQ\dlqhandler.bat')
+
DESCR('dead
letter queue handler as server service') +
STARTARG('DEADQ
IBMQMR < C:\IBM\WebSphere\MQ\RULETBL.RUL') +
STDOUT('C:\IBM\WebSphere\MQ\Log.txt')
+
STDERR('C:\IBM\WebSphere\MQ\Err.txt')
+
REPLACE
The
value of STARTCMD is the absolute path of the executable file dlqhandler.bat
(on Windows), asshown above in the Listing 3. After you have defined the server
service object for the DLQ Handler, you need
to make sure that group id mqm, user id MUSR_MQADMIN (on Windows) has Read andExecutable
privileges on the dlqhandler.bat executable file. RULETBL.RUL is the rules
table file.
And start
the service command and monitor the service status.
Scenario 2: Triggering the DLQ Handler
Scenario
2 involves setting up the WebSphere MQ trigger facility so that the DLQ Handler
runs andprocesses undelivered messages only when they arrive on the DLQ. To set
up Scenario 2, define aprocess object processdlq within the queue manager B that
is triggered whenever the trigger conditions are met. Specify the absolute path
of the program or process to be triggered in the Application ID field, to avoid
unexpected results in the DLQ with the message.
Create a Process
definition:
Create
a process definiton with name of PROCESSDLQ and keep the applicid as below.
Create a
bat file called dlq_trigger.bat and copy it to D:\MQ path.
cd
"C:\Program Files\IBM\WebSphere MQ\bin"
runmqdlq
< RULETBL.RUL
Rule table should like below:
INPUTQ('DEADQ')
INPUTQM(B) RETRYINT(45) WAIT(NO)
REASON(MQRC_Q_FULL)
ACTION(FWD) FWDQ(DLQX) FWDQM(B)
Set the
Triggering feature ON on this DEADQ of the IBMQMR queue manager, so that
whenever amessage arrives on DEADQ, DLQ Handler becomes active to handle the
message based on thecontents of the rules table file RULETBL.RUL. Specify the
process name to be triggered as processdlq and the initiation queue as SYSTEM.DEFAULT.INITIATION.QUEUE:
DEFINE
QLOCAL(DEADQ) DESCR('WebSphere MQ Default Dead Letter Queue')
INITQ(SYSTEM.DEFAULT.INITIATION.QUEUE)
TRIGTYPE(EVERY) TRIGGER PROCESS('processdlq')
1 :
DEFINE QLOCAL(DEADQ) DESCR('WebSphere MQ Default Dead Letter Queue')
INITQ(SYSTEM.DEFAULT.INITIATION.QUEUE)
TRIGTYPE(EVERY) TRIGGER PROCESS('processdlq')
AMQ8006:
WebSphere MQ queue created.
:
DISPLAY
QLOCAL(DEADQ) DESCR INITQ TRIGGER TRIGTYPE PROCESS
2 :
DISPLAY QLOCAL(DEADQ) DESCR INITQ TRIGGER TRIGTYPE PROCESS
AMQ8409:
Display Queue details.
QUEUE(DEADQ)
TYPE(QLOCAL)
DESCR(WebSphere
MQ Default Dead Letter Queue)
INITQ(SYSTEM.DEFAULT.INITIATION.QUEUE)
TRIGGER
PROCESS(processdlq)
TRIGTYPE(EVERY)
Listing 9. Run the trigger
monitor using the command prompt.
runmqtrm
-m IBMQMR -i SYSTEM.DEFAULT.INITIATION.QUEUE
Listing
10. Definition and status of the trigger monitor server service object
display
svstatus('triggerdlq') all
1 :
display svstatus('triggerdlq') all
AMQ8632:
Display service status details.
SERVICE(triggerdlq)
STATUS(RUNNING)
PID(9540)
SERVTYPE(SERVER)
STARTDA(2011-12-27)
STARTTI(17.11.53)
CONTROL(MANUAL)
STARTCMD(C:\Program
Files\IBM\WebSphere MQ\bin\runmqtrm)
STARTARG(-m
IBMQMR) STOPCMD( )
STOPARG(
) DESCR(trigger the dlq handler)
STDOUT(C:\IBM\WebSphere\MQ\Log_runmqtrm.txt)
STDERR(C:\IBM\WebSphere\MQ\Err_runmqtrm.txt)