Author |
Message
|
anveshita |
Posted: Wed Jun 18, 2008 10:38 am Post subject: help with putting a pdf on MQ queue |
|
|
Master
Joined: 27 Sep 2004 Posts: 254 Location: Jambudweepam
|
I need help with putting a pdf on MQ queue. Could you please review hte following snippet and let me know if I am on the right track
------------------------
//Set up the MQEnvironment properties for Client Connections
MQEnvironment.hostname = hostName ;
MQEnvironment.channel = channel ;
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES);
MQQueueManager qMgr = new MQQueueManager(qManager) ;
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING ;
//Open the queue
MQQueue queue = qMgr.accessQueue(qName,openOptions, null,null,null);
// Set the put message options , we will use the default setting.
MQPutMessageOptions pmo = new MQPutMessageOptions();
MQMessage outMsg = new MQMessage();
outMsg.format = MQC.MQFMT_NONE
// Read the PDF file to input stream
BufferedInputStream in = new BufferedInputStream(new FileInputStream("c:\\test.pdf"));
while ((len = in.read(buf)) >= 0) {
outMsg.write(buf,0,len);
}
// Now we put The message on the Queue
queue.put(outMsg, pmo);
-------------------
I am unable to test as MQ as I do not have access to the queue. But wanted to have the code ready before.
Thanks |
|
Back to top |
|
 |
AkankshA |
Posted: Wed Jun 18, 2008 10:04 pm Post subject: |
|
|
 Grand Master
Joined: 12 Jan 2006 Posts: 1494 Location: Singapore
|
i fear we might not be able to review...
we all have learnt here by doing it...
how about getting the trial version of MQ from IBM portal and testing it yourself.... and then if u face any error then we would love to be with you in resolution of the same.... _________________ Cheers |
|
Back to top |
|
 |
Gaya3 |
Posted: Wed Jun 18, 2008 10:26 pm Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
where is the error handling scenario in your code?
are you segmenting the messages? _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
gbaddeley |
Posted: Wed Jun 18, 2008 11:41 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
You need to read the entire PDF contents as one binary record into a buffer (allocated with the same size as the file), and then put the buffer as a message on a MQ queue. _________________ Glenn |
|
Back to top |
|
 |
bruce2359 |
Posted: Thu Jun 19, 2008 6:47 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
Quote: |
I am unable to test as MQ as I do not have access to the queue. But wanted to have the code ready before. |
It is unrealistic to expect that untested code will work. Create a test qmgr; then test your program. _________________ 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 |
|
 |
ucbus1 |
Posted: Thu Jun 19, 2008 11:44 am Post subject: |
|
|
Knight
Joined: 30 Jan 2002 Posts: 560
|
I guess you are in luck. I happened to address this issue sometime back. I can send you the sample which I created if you are interested. I am not posting here the code as it is a barebones code with flaky error handling. If it works for you then you may post |
|
Back to top |
|
 |
|