Author |
Message
|
garymach64 |
Posted: Mon Apr 30, 2007 3:54 am Post subject: putting a file onto a queue |
|
|
Newbie
Joined: 30 Apr 2007 Posts: 1
|
My goal is to be able to put a message on the queue that is contained in a file on the disk.
I can do it with a
amqsput MyQueueName < c:\gary\mq\text.txt
command.
However, each new line is separated into a new message on the queue. Can I make them all into a single message?
Thanks in advance,
Gary _________________ Gary Machol
Software Engineer
Last edited by garymach64 on Mon Apr 30, 2007 4:12 am; edited 1 time in total |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 30, 2007 4:05 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
There have been a number of discussions on this subject - the Search button (top right this page) will be your friend here.
There's no single API to do it, but there are commerical products that provide this functionality and might be better than reinventing a wheel. It's not as straightforward as it first appears.
The one I'm familar with is PM4DATA (or whatever it's called these days). I offer this as suggestion only, no warrenty is accepted.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
zpat |
Posted: Mon Apr 30, 2007 4:08 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Qload support pac for non-mainframe. There are also many samples of code to do this.
For testing purposes use RFHUTILC (support pac IH03), I have used this for messages of 16 MB in size, read from a file. |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Mon Apr 30, 2007 4:40 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
I have simple code which sends file content to MQ queue.
It is not very complicated.
Code: |
import org.apache.commons.codec.binary.Base64;
...
byte readbytes[] = this.getBytesFromFile(fileName);
Base64 base = new Base64();
byte[] base64value = base.encode(readbytes);
String base64content= new String( base64value, "UTF-8" );
this.sendDataViaMQ(queueOut,"<DATA><FILENAME>"+
fileName+"</FILENAME><BASE64CONTENT><![CDATA["+base64content+"]]></BASE64CONTENT></DATA>");
|
_________________ Marcin |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 30, 2007 4:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
The complicated part is a large file which has problems during transmission, or needs to be segmented, or similar. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Mon Apr 30, 2007 5:01 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
Vitor wrote: |
The complicated part is a large file which has problems during transmission, or needs to be segmented, or similar. |
Adding segmentation here :
What you have to do:
- divide content into parts in loop
- every part put into MQ with
Code: |
mqmessage.messageFlags=MQC.MQMF_SEGMENT; |
- last part put into MQ with
Code: |
mqmessage.messageFlags=MQC.MQMF_LAST_SEGMENT; |
Another thing is reading.
Generally you are absolutely right. It is little more complicated, but if you are motivated to can do it  _________________ Marcin |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 30, 2007 5:11 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
marcin.kasinski wrote: |
Generally you are absolutely right. It is little more complicated, but if you are motivated to can do it  |
If you're well funded you can buy something to do it
It's always possible to reinvent a wheel; nearly always as circular as the originial.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
marcin.kasinski |
Posted: Mon Apr 30, 2007 5:28 am Post subject: |
|
|
Sentinel
Joined: 21 Dec 2004 Posts: 850 Location: Poland / Warsaw
|
Of cuorse.
We are talking about the same thing.
Somethimes it is better to buy dedicated product which can do it.
Somethimes it is better to implement new version of your applicatin which does it.
It depends on lots of things.
We do both of this.
There was a question about sending file to queue.
I posted only one option.
Maybe garymach64 will consider using it. _________________ Marcin |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 30, 2007 5:39 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
marcin.kasinski wrote: |
There was a question about sending file to queue.
I posted only one option.
Maybe garymach64 will consider using it. |
And a very good option it was, and worthy of consideration. It all depends on requirements, volume, budget, standards, etc, etc...
If every problem had one and only one answer, the software market would be a lot flatter. And I'd have had to get a proper job years ago.  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|