As part of the installation of our application, I need to put a bunch of xml messages into an MQ queue. To make it more complicated, the messages need to have the usr-folder of the RFH2-header set.
I found that mqput2.exe from the IBM RFHUtil is an ideal tool for this task. Unfortunately, I have been unable to make setting of the usr-folder work, the documentation is too vague. What am I doing wrong? Or, is there another command-line tool available that works better?
My prop. file for mqput2 looks like this:
[header]
.....
*
* message type
*
* Allowed values for message type
* 1 - request
* 2 - reply
* 4 - report
* 8 - datagram
* 112 - MQE fields from MQE
* 113 - MQE fields
* 65536 to 999,999,999 - user
msgtype=8
.....
*
* rfh usage
* rfh = N for No rfh
* rfh = A for Automatic (look for RFH at beginning of data file)
* rfh = 1 or V1 for Version 1 rfh from parameters in parm file
* rfh = 2 or V2 for Version 2 rfh from parameters in parm file
* rfh = X for special V2 rfh with fixed portion only and format=xml
*
* only first character checked, except for V when second character is also checked
*
rfh=X
<usr>
<NotificationType>RDS.Codebook.Changes</NotificationType>
</usr>
.....
[filelist]
file1.xml
mqput2 simply ignores the <usr> section and doesn't include it with the message. I've also tried rfh=A and put the <usr> section at the beginning of the file1.xml file, but then I get MQPUT error reason=2142 (invalid MQ header structure).
Also dmpmqmsg utility, which is part of the WMQ8 installation, can be used for sending the messages from command-line. A message can be exported from a queue including the headers via
dmpmqmsg -m queue_manager> -I <queue> -f <msg_file> -a
and then submitted again via (I think, consult the docs)
dmpmqmsg -m queue_manager> -o <queue> -f <msg_file>
This utility is however not part of WMQ 7.5.
I have it set up this way, and it works fine:
[header]
qname=QName
qmgr=QMName
msgcount=1
format= "MQSTR "
codepage=1208
rfh=2
<usr>
<test>test</test>
</usr>
[filelist]
test.xml
Related
I am trying to use the cmo.deleteMessages to clean up messages that are older than 30 days.
connect(...)
domainRuntime()
print 'Cleaning Message from QUEUE:myqueue'
try:
cd('ServerRuntimes/myserver/JMSRuntime/myserver.jms/JMSServers/myserver/Destinations/JMSMODULE!JMSmyserver#myqueue')
cmo.deleteMessages("JMSTimestamp > 5200000000")
except:
pass
However Weblogic doesnt recognize the attribute "JMSTimestamp > 5200000000". It deletes all the messages.
When I put the entry "JMSTimestamp > 5200000000" in the Message Selector [in wl console], it shows up all messages instead of messages that are only 30 days old [5200000000 milliseconds is 30 days].
The problem is the format "JMSTimestamp > 5200000000" is either not recognized by Weblogic or the python script. Any idea what I am missing.
I was able to create the timestamp in milliseconds using a modified date command tool in Linux.
$ date +%s%N | cut -b1-13
1617374452236
JMS time stamp parameter accepted this format and was able to perform the task.
I have a list of crontab entries:
0 * * * * /home/tomcat/abc.sh
0 * * * * /home/tomcat/def.sh
I want to perform an action through a bash script and it requires one of the cron jobs to be disabled.
#0 * * * * /home/tomcat/abc.sh
0 * * * * /home/tomcat/def.sh
How can I comment a single cron job using bash script?
Please help. Thanks!
That's kinda dangerous in my book, I wouldn't recommend doing that. Instead, I'd update your script so that it creates a file (like /tmp/MY_SCRIPT_LOCK or whatever) at the start and removes the file at the end. Then just update the cron job so it doesn't run if it finds the file:
0 * * * * test -f /tmp/MY_SCRIPT_LOCK || /home/tomcat/abc.sh
If you want to add a comment (#) at a particular line you can use -
Third line:
sed '3s/^/#/' filename
You can save this as new file or use output redirections.
I am running a web-application (MyCronTest) on a Glassfish-Server in a Jelastic-Environment. This web-application contains the servlet (/test), that I would like to call regularly with a cron-job.
So I followed this tutorial from the Jelastic docs, but they use Tomcat instead of Glassfish and I am not so sure about the paths and where to put which file...and now I am lost ;)
the servlet
When calling the servlet directly in my browser it prints out the following line to System.out:
test executed at 05/03/2014 15:00
the bash file to execute
I created a bash script called myCronJob.sh and put it in the directory glassfish3/temp:
#!/bin/bash
curl http://myGlassfish.jelastic.dogado.eu/MyCronTest/test;
I tested it of course, it is executable and it works (at least when I execute it on my computer).
the cron event scheduler
according to the tutorial there is a file /cron/tomcat I need to edit. Well, I found a /cron/glassfish which (I am guessing) should do the same.
# IMPORTANT NOTE!
# Please make sure there is a blank line after the last cronjob entry.
*/1 * * * * /opt/glassfish3/temp/myCronJob.sh
I added an empty line at the end, as they told me to. I even tried it with
*/1 * * * * /bin/bash /opt/glassfish3/temp/myCronJob.sh
as they suggested in the tutorial. But still no output. No error.. just empty log files.
Does anyone have an idea what I am missing here? Am I doing something wrong?
Solution / Edit
Thanks to Damien's Answer I was finally able to narrow down my problem. It was actually the line in my bash-script that caused the problem:
curl http://myGlassfish.jelastic.dogado.eu/MyCronTest/test;
should have been
curl http://localhost/MyCronTest/test;
since I was blocked by a firewall. Lucky for me, my Glassfish is running on the same machine / environment, so localhost works.
Everything else is correct.
Well, I found a /cron/glassfish which (I am guessing) should do the same.
Correct.
But still no output. No error.. just empty log files.
Assuming that you have correctly uploaded your file to /opt/glassfish3/temp/myCronJob.sh, I recommend that you try to direct the cron output to your own log file or email it to you:
MAILTO="your#email.com"
*/1 * * * * /opt/glassfish3/temp/myCronJob.sh 2&1 > /opt/glassfish3/glassfish/nodes/localhost-domain1/instance-168458181/logs/cronoutput.log
Note that the email may be filtered by your spam filters due to things like missing PTR (reverse DNS) and so on - but it's ok to use like this for testing/debugging purposes (just don't rely on these mails getting through for anything critical!)
If these tips don't help you, then I recommend contacting your hosting provider's support team to verify the .sh file's permissions, output when executed manually, and the cron log file contents (all of which only they can help you with).
I have a static directory: /var/tmp/files
This directory is only shared with users for upload/download via SFTP, it has some static file names such as:
recording-security.frontdoor.avi
recording-security.backdoor.avi
recording-security.parkingspace.avi
....
from another PC via SFTP those files are getting removed/edited/updated/added etc
Now another path: /var/www/html/livevideo-stream/
those files are copied, moved from /var/tmp/files
How can i using BASH read those files were edited or newly added or overwritten? So, that my script can move valid contents from /var/tmp/files to livevide-stream only those which has been modified or newly added etc?
$ crontab i have:
0 7 * * * /var/tmp/finishit.sh
0 8 * * * /var/tmp/finishit.sh
0 9 * * * /var/tmp/finishit.sh
0 19 * * * /var/tmp/finishit.sh
0 20 * * * /var/tmp/finishit.sh
$ cat /var/tmp/finishit.sh
#!/bin/bash
cd /var/tmp/files
while :
do
"""
how do we now validate those files which was modified or changed or newly added and place them in that directory?
"""
# echo $1 $2
cp -R /var/tmp/files/* /var/www/html/livevideo-stream/
sleep 1
done
Your cron will launch your script several times per hour, and your script does not terminate due to the while : loop... You will end up with a lot of background scripts trying to copy stuff ever second.
You should simply replace the whole script with
rsync -vaq /var/tmp/files/* /var/www/html/livevideo-stream/
I want to load files in the file system to a WebSphere MQ Queue. There are couple of support pacs - Q Program and MO03: WebSphere MQ Queue Load / Unload Utility
that come close but they mandate the files to be in a specific format. I have the messages which are XML files and want a quick way to load them to a queue. The number of files run into a few hundred so looking for an utility to do this job instead of having to write an application to achieve this.
I could not locate some general purpose application to achieve this. So looking for some help here
Thanks
Why do you believe that the Q program requires a specific file format? According to the README.TXT file, the following options are available:
-f<filename>
Input file.
Each line of the file will be put to output queue as a different
message.
See "Z/OS FILE NAME FORMAT EXAMPLES" for specific z/OS details.
-F[+]<filename>
Input/output file.
Entire file will be put to the output queue as a single message.
If '+' is specified the dataset attributes will be retained if
the output dataset exists - z/OS only.
See "Z/OS FILE NAME FORMAT EXAMPLES" for specific z/OS details.
So if you specify -F (without the +) all lines in the the XML file are loaded into a single message. You can also specify the message options using the -a parameter:
-a<Opts> Sets message attributes when put to the output queue
n - forces non-persistence
p - forces persistence
q - uses queue default persistence
d - put a datagram message type
r - put a reply message type
R - put a request message type
t - put a report message type
x - don't treat lines starting with '#' as special
Although the Q program will interpret files by default, note that the -ax option above tells it to ignore lines with # which it would ordinarily interpret as commands. This allows you to load XML files or source code with comments or even binary files such as a PDF or JPG.
Was there a specific limitation in Q that you are unable to work with? If so, it would be helpful to know what that is so we might point you to something that would better fit your purpose.
UPDATE
Responding to Spyro's comments, Q is not limited to 1000 characters. Here's an example where the README file from the Q distribution is written to a single message and read back.
D:\WMQ\MA01>q -m JMSDEMO -OSYSTEM.DEFAULT.LOCAL.QUEUE -FREADME
MQSeries Q Program by Paul Clarke [ V6.0.0 Build:May 1 2012 ]
Connecting ...connected to 'JMSDEMO'.
D:\WMQ\MA01>echo dis q(SYSTEM.DEFAULT.LOCAL.QUEUE) curdepth | runmqsc JMSDEMO
5724-H72 (C) Copyright IBM Corp. 1994, 2011. ALL RIGHTS RESERVED.
Starting MQSC for queue manager JMSDEMO.
1 : dis q(SYSTEM.DEFAULT.LOCAL.QUEUE) curdepth
AMQ8409: Display Queue details.
QUEUE(SYSTEM.DEFAULT.LOCAL.QUEUE) TYPE(QLOCAL)
CURDEPTH(1)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.
D:\WMQ\MA01>q -m JMSDEMO -dl -iSYSTEM.DEFAULT.LOCAL.QUEUE
MQSeries Q Program by Paul Clarke [ V6.0.0 Build:May 1 2012 ]
Connecting ...connected to 'JMSDEMO'.
MQGET 24309 bytes
============================================================================
Message Descriptor (MQMD)
Report :00000000
Message Type :8 (Datagram)
Format :'MQSTR '
Priority :0
Persistence :0 (Not Persistent)
Message Id :A M Q J M S D E M O . . . R . * .
414D51204A4D5344454D4F20202020201DDEA052200B2A02
'AMQ JMSDEMO ...R .*.'
ReplyToQ :' '
ReplyToQMgr :'JMSDEMO '
----------------------------------------------------------------------
| |
| |
| DESCRIPTIVE NAME WebSphere MQ Q Program |
| |
------- 8><-------------------------------------------------------------
REMAINDER OF MSG OUTPUT OMITTED FOR BREVITY. PRINT-OUT RESUMES...
------- 8><-------------------------------------------------------------
No more messages.
D:\WMQ\MA01>
Note the header lines where the message was printed. The -dl option tells Q to print the message length which, in this case, was 24309 bytes. I downloaded the current version to perform this test so this is accurate as of 7 December 2013.
If you are looking for loading the file to queue.. Its easy to work with RFHUtil s/w or application.
In RFHUtil you can easily load the file to MQ and clear the Queue, purge ect...
Many more options are provided .