Author |
Message
|
elixir9999 |
Posted: Thu Oct 08, 2015 6:34 am Post subject: Script for putting Test Message on a Queue |
|
|
Novice
Joined: 24 Sep 2015 Posts: 10
|
Hi
I was trying to write a script to put a test message on a local Q.
But when I write amqsput Q QMGR in the script and the message below it,The control goes from the Script to amqsput and expects a manual entry or a test message at the console.
Can someone please tell me how to tackle this thing, so it puts the message written in the same script in the below line of amqsput command.
Thanks
Sumit |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Oct 08, 2015 6:39 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Code: |
amqsput MYQUEUE MYQMGR < inputfile.txt
|
and you have the message that you want to send on one line in the file.
Have more than one line, and you send one message per line _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Oct 08, 2015 6:57 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
please don't use large font sizes. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
elixir9999 |
Posted: Thu Oct 08, 2015 8:23 am Post subject: |
|
|
Novice
Joined: 24 Sep 2015 Posts: 10
|
Hi smdavies99
I tried with the below and placed a file msg.txt in the same directory as the script with content of the msg.txt as "TEST".
Now the amqsput starts finds the correct Q but then closes without putting any message on the Q itself.
What am I missing here.
Thanks
Sumit |
|
Back to top |
|
 |
bruce2359 |
Posted: Thu Oct 08, 2015 9:33 am Post subject: Re: Script for putting Test Message on a Queue |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
elixir9999 wrote: |
Hi
I was trying to write a script to put a test message on a local Q.
But when I write amqsput Q QMGR in the script and the message below it,The control goes from the Script to amqsput and expects a manual entry or a test message at the console.
Can someone please tell me how to tackle this thing, so it puts the message written in the same script in the below line of amqsput command.
Thanks
Sumit |
Working as designed.
The IBM-supplied amqsput sample program does not look at the lines below it. Rather, amqsput expects input from STDIN to populate the application data portion of the message. STDIN is your keyboard OR a redirected file. Such as:
amqsput QL.A QMC01 <my.data _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 08, 2015 9:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
elixir9999 wrote: |
What am I missing here. |
A '<' character?  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
bruce2359 |
Posted: Thu Oct 08, 2015 10:24 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
Vitor wrote: |
elixir9999 wrote: |
What am I missing here. |
A '<' character?  |
It's the redirect (in) character in both Windoze and UNIX. The redirect (out) character is > _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Oct 08, 2015 10:27 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
bruce2359 wrote: |
Vitor wrote: |
elixir9999 wrote: |
What am I missing here. |
A '<' character?  |
It's the redirect (in) character in both Windoze and UNIX. The redirect (out) character is > |
I was speculating if the OP used:
Code: |
amqsput Q QMGR < msg.txt |
or
Code: |
amqsput Q QMGR msg.txt |
_________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
elixir9999 |
Posted: Fri Oct 09, 2015 4:07 am Post subject: |
|
|
Novice
Joined: 24 Sep 2015 Posts: 10
|
Thanks alot Everyone, you guys are great help to new beginners like me.
I had 1 more query, Its working now with < character but if I want to do the same thing with a single script only, can that be done too - I mean the contents of msg.txt are also in the same script file and amqsput picks the msg from the same script only and puts the msg and closes.Can this also be done - everything in a single Script ??
Thanks
Sumit |
|
Back to top |
|
 |
smdavies99 |
Posted: Fri Oct 09, 2015 4:45 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
This is not really an MQ problem but a Windows one.
That said, something like
Code: |
echo "Hello world" | amqsput MYQUEUE MYQMGR
|
will do the job. _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
elixir9999 |
Posted: Fri Oct 09, 2015 5:32 am Post subject: |
|
|
Novice
Joined: 24 Sep 2015 Posts: 10
|
Hi Jedi
Thanks for the Helpful reply.
But If i want to put a long MQ or xml msg onto the Q , can I do that through the Script , a single script which picks the msg from within and puts the msg onto the Q.
Thanks
Sumit |
|
Back to top |
|
 |
Vitor |
Posted: Fri Oct 09, 2015 5:40 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
elixir9999 wrote: |
But If i want to put a long MQ or xml msg onto the Q , can I do that through the Script , a single script which picks the msg from within and puts the msg onto the Q |
Two points:
- The amqsput sample application is just that - a sample. If it doesn't do what you want (e.g. doesn't handle long messages, doesn't read directly from a file system) then change it;
- There are many other tools available to manipulate queues that do handle long messages and XML; RFHUtil comes immediately to mind but there are others. You may find these suit you better. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
elixir9999 |
Posted: Fri Oct 09, 2015 5:56 am Post subject: |
|
|
Novice
Joined: 24 Sep 2015 Posts: 10
|
Hi Vitor
Yes, its correct what you are saying.
But our requirement is to integrate MQ with TWS, so that at a specific time in day, TWS will login to the server and execute the script and put the message on the Q and trigger the msg flow at a fixed time each day.
Thanks
Sumit |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Oct 09, 2015 5:58 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Also, there's no such thing as an XML message.
There's only an MQ Message.
Regardless of what it holds. It could hold XML, it could hold JSON, it could hold a MIME document, it could hold a COBOL record, it could hold a PDF, it could hold a NSFW jpg. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Vitor |
Posted: Fri Oct 09, 2015 6:07 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
elixir9999 wrote: |
But our requirement is to integrate MQ with TWS, so that at a specific time in day, TWS will login to the server and execute the script and put the message on the Q and trigger the msg flow at a fixed time each day. |
Then you'd probably want something a bit more "production strength" than the sample code anyway (better error handling and logging for example) so my comment about changing the sample (or using it as a template for your own utility) applies.
As my most worthy associate correctly points out, there's no such thing as an "XML message"; just a message that holds XML. If you don't want to view it as XML (which is a feature of RFHUtil) but just put a message on a queue that happens to contain XML then clearly this kind of technology suits you.
It sounds to me like you need to extend or replace amqsput with something that suits you better. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|