MQ

MQ

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  runmqtrm not passing params?

    Posted 11/18/21 01:55 PM
    Hi Folks,
    Righto... I'm on distributed and I've got runmqtrm running as a service. That works fine.
    Set up trigger on a queue and that all works fine too.
    Set up a process that is a bat file as apptype "windows". That all works OK too - up to a point...

    I was expecting the .bat file to be passed command line parameters but it's not. I understood that the process environment data and user data along with the trigger data would be passed to it - but they don't seem to be getting there. I've looked at the sample trigger program and it clearly shows they should be getting passed. 
    When I call my .bat file from the cmd line it picks up the params it's passed just fine which makes me think that the params aren't being passed or something in the process definition is wrong - the apptype maybe? I've tried it as type=dos (doesn't work)  and type=windows NT - same issue.


    Any ideas  as to what I need to do?

    thanks for your help folks !
    John.

    ------------------------------
    John Hawkins
    Integration Consultant
    ------------------------------


  • 2.  RE: runmqtrm not passing params?

    Posted 11/18/21 04:05 PM
    Can you pass it thru "start args" and "stop args" in the service command. See if that helps.

    ------------------------------
    om prakash
    WI
    ------------------------------



  • 3.  RE: runmqtrm not passing params?

    Posted 11/18/21 07:14 PM

    It's hard to say what you need to correct when you don't show us the definitions you have created. Where did you put the command line parameters? Possible places are in the PROCESS object's USERDATA or the triggered queue's TRIGDATA (or both). The ENVDATA is not for passing parameters. That's just for getting a process to run in the background. Show us your definitions and we might be able to see what's up.

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 4.  RE: runmqtrm not passing params?

    Posted 11/19/21 04:05 AM
    hi Morag,

    trigger def:
    DEFINE QLOCAL('MYQ') +
    INITQ('DLQ.INITQ') +
    TRIGGER +
    PROCESS('DLQHANDLER') +
    TRIGDATA('sad') +
    TRIGTYPE(EVERY)

    process def
    DEFINE PROCESS('DLQHANDLER') +
    APPLTYPE(WINDOWSNT) + [or "WINDOWS"- doesn't matter - same result]
    APPLICID('c:\coliance\cat.bat') +
    USERDATA('wer')

    service def (you may recognise this ;-):
    DEFINE SERVICE('TRIGGER.MONITOR') +
    CONTROL(QMGR) +
    SERVTYPE(SERVER) +
    STARTCMD('+MQ_INSTALL_PATH+bin64\runmqtrm') +
    STARTARG('-m +QMNAME+ -q DLQ.INITQ') +
    STOPCMD('+MQ_INSTALL_PATH+bin64\amqsstop') +
    STOPARG('-m +QMNAME+ -p +MQ_SERVER_PID+')

    bat file:
    echo "Hello World. " %time% > C:\coliance\hello.txt

    IF NOT "%0"=="" echo %0 >>c:\coliance\hello.txt
    IF NOT "%1"=="" echo %1 >>c:\coliance\hello.txt
    IF NOT "%2"=="" echo %2 >>c:\coliance\hello.txt
    IF NOT "%3"=="" echo %3 >>c:\coliance\hello.txt

    output: from MQ trigger:
    "Hello World. " 8:56:25.35
    c:\coliance\cat.bat 

    output from cmdline:
    "Hello World. " 8:59:18.37
    c:\coliance\cat.bat
    hello
    john

    ------------------------------
    John Hawkins
    Integration Consultant
    ------------------------------



  • 5.  RE: runmqtrm not passing params?

    Posted 11/19/21 04:28 AM

    Hmmm, are you sure that your bat file is handling the MQTMC2 structure that it is passed correctly? I assume that's the entirety of your bat file there and I don't see anything handling the TMC2. The parameters are passed in the TMC2.UserData and TMC2.TriggerData fields. I'm surprised you don't simply get the whole structure printed out as parameter %1.

    If you run the trigger monitor in a foreground window for the moment, you will see the full invocation of the triggered program inline in the command prompt which might help you to see what the parameters passed to the program are - it's a very long character string in effect. You'll probably need some substringing in that batch file.

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 6.  RE: runmqtrm not passing params?

    Posted 11/19/21 04:54 AM
    Ah ha - thank you, as always Morag !
    Never thought of running the trigger monitor on the command line (doh - always good to talk ;-) cheers for that -  I got the script from someone else who was trying to debug the same problem years ago and didn't think about it too much. On the command line I can see that the params *are* being passed in but the 2nd line (param %1) can't handle the structure. I should have a) never trusted dos to be nice b) redirected sdout and stderr from the service then I would have seen that (for future cruisers I have put that below)...

    DEFINE SERVICE('TRIGGER.MONITOR') +
    CONTROL(QMGR) +
    SERVTYPE(SERVER) +
    STARTCMD('+MQ_INSTALL_PATH+bin64\runmqtrm') +
    STARTARG('-m +QMNAME+ -q DLQ.INITQ') +
    STOPCMD('+MQ_INSTALL_PATH+bin64\amqsstop') +
    STOPARG('-m +QMNAME+ -p +MQ_SERVER_PID+') +
    STDOUT('c:\coliance\std.out') +
    STDERR('c:\coliance\std.err') +
    DESCR('Trigger Monitor Service Auto Started with QMgr')

    ------------------------------
    John Hawkins
    Integration Consultant
    ------------------------------



  • 7.  RE: runmqtrm not passing params?

    Posted 11/19/21 11:51 AM
    As another triggering debugging tip, you can also use strmqtrc to turn on tracing for runmqtrm. The tracing will provide all the command line arguments being passed to your triggered script, and also show if any errors were returned when the process was started (e.g. security errors when starting the script).

    ------------------------------
    Tim Zielke
    ------------------------------