|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
MQPUT & Perl |
« View previous topic :: View next topic » |
Author |
Message
|
jarp |
Posted: Thu Feb 12, 2004 6:38 am Post subject: MQPUT & Perl |
|
|
Newbie
Joined: 12 Feb 2004 Posts: 3 Location: Houston
|
I'm writing a PUT and GET utility in perl, and am a newbie to MQSeries. I need the ability to deal with possibly large files, larger than the QM max message length. I'd like the QM to handle segmenting the files, but cannot seem to get the message descriptor flag MQMF_SEGMENTATION_ALLOWED to work as I expect. Here's the code, that processes all the little files, but errors out on the one large file in the input sample:
Code: |
{...}
$Hcon = MQCONN($Name, $CompCode, $Reason);
# Report & stop if it failed
my $O_options = MQOO_OUTPUT | MQOO_FAIL_IF_QUIESCING;
my $QName = { ObjectName => $que };
my $Hobj = MQOPEN($Hcon,$QName,$O_options,$CompCode,$Reason);
# Report & stop if it failed
my $md = {MQMF_SEGMENTATION_ALLOWED | MQMD_DEFAULT};
my $pmo = { Options => MQPMO_FAIL_IF_QUIESCING | MQPMO_NEW_MSG_ID | MQPMO_NEW_CORREL_ID };
opendir DIR, "C:\\Perl\\MyPerlPrograms\\";
@infiles = grep { /\.pl$/ } readdir DIR;
close DIR;
for $infile (@infiles)
{
my $size = (stat($infile))[7];
print "Writing [$size] bytes to queue $que, from file [$infile]\n";
$Buff = read_file ($infile);
MQPUT($Hcon, $Hobj, $md, $pmo, $Buff, $CompCode, $Reason);
print "REASON IS: $Reason\n" if ($Reason!=MQRC_NONE && $Reason!=MQRC_NO_MSG_AVAILABLE);
}
#
# Done reading files
{...}
|
When it errors, the reason code is 2031.
The idea is that in the GET utility, I'll have the QM reassemble the message with the MQGMO_COMPLETE_MSG flag.
Alternatively, is there a better way to do this?
I appreciate the help! |
|
Back to top |
|
 |
bduncan |
Posted: Thu Feb 12, 2004 1:00 pm Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
A couple of things:
1. You might want to look at the getput.pl sample program in the software repository on this site.
2. Have you considered using logical grouping rather than segmentation? I've sucessfully used it with Perl, where I was sending large image files and breaking them into 16k chucks each of which was a separate message in a group.
3. It appears that your code isn't dealing with the possibility when the file is larger than $Buff is allowed to have in the MQPUT. In this case you need to do multiple MQPUTs (after breaking the file into legal size chunks). The pseudocode looks like:
Code: |
PMO.Options = MQPMO_LOGICAL_ORDER | MQPMO_SYNCPOINT
MQPUT MD.MsgFlags = MQMF_SEGMENT
MQPUT MD.MsgFlags = MQMF_SEGMENT
MQPUT MD.MsgFlags = MQMF_SEGMENT
MQPUT MD.MsgFlags = MQMF_LAST_SEGMENT
MQCMIT
|
Notice it's important to use syncpoint because you don't ever want to get left with an incomplete group of messages on the queue.
4. If you haven't already you might want to look at the section on segmentation in the API Guide:
http://publibfp.boulder.ibm.com/epubs/html/csqzal06/csqzal062d.htm#HDRPART _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
jarp |
Posted: Fri Feb 13, 2004 5:59 am Post subject: |
|
|
Newbie
Joined: 12 Feb 2004 Posts: 3 Location: Houston
|
Brandon,
Thanks for the input.
The only reason I'm considering segmentation is the QM will handle that for me. After reading the docs, I came to the conclusion that a large message (in my case, a file) will be broken up into chunks, sized as needed by the queue or QM -- given I allow MQMF_SEGMENTATION_ALLOWED.
Syncpoints will play a role in the finished code. I'm aware of the issue, but figured it could wait until I get the basics in place.
Logical grouping is the next solution for this problem. But I'd like to understand why the above doesn't work as I expect.
I've downloaded both the getput.pl code from the MQSeries.net site; this was my starting point since I've never used this perl module before. And read the segmentation section in the API guide.
Again, I appreciate any help you're will to give!
Cheers,
Jo-an _________________ Cheers,
Jo-an |
|
Back to top |
|
 |
bduncan |
Posted: Fri Feb 13, 2004 3:19 pm Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
Exactly how large are these files you are trying to put in messages? _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
jarp |
Posted: Mon Feb 16, 2004 6:22 am Post subject: |
|
|
Newbie
Joined: 12 Feb 2004 Posts: 3 Location: Houston
|
The QM/queue reports max_msg_length to be a little over 4Mb. The test file is over 5Mb.
I realize the max_msg_length can be as much as 100Mb. In production, this will occasionally not be enough. I'm keeping the message length restricted on purpose, until I can work out either segmenting the file, or the plan B solution... _________________ Cheers,
Jo-an |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|