Author |
Message
|
jadaaih |
Posted: Thu Sep 11, 2008 2:11 am Post subject: Sending MQMessage to a queue |
|
|
Apprentice
Joined: 10 Sep 2008 Posts: 25
|
Hi Guys,
I am facing a strange issue when sending MQMessage to a queue. The same code was working fine with the default queue but its not working with the newly added queue manager - queue.
I am sure its some configuration issue and also I am sure I am missing the basic understanding of MQ so far.
I have the following assumption please let me if its right,
- Whenever an application code developed with API for java sends or receives a message it has to go through the server connection channel?
If the above is true how do I send a message to other connection channels? if there is neccasity
The following is my code for reference
MQEnvironment.hostname = MQSConstants.MQ_HOST;
MQEnvironment.channel = MQSConstants.MQ_CHANNEL_NAME;
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,
MQC.TRANSPORT_MQSERIES);
mqManager = new MQQueueManager(MQSConstants.MQ_QUEUE_MANAGER);
openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
System.out.println("[ Open Options : "+openOptions+"]");
defaultQ = mqManager.accessQueue("default",
openOptions);
// Framing message to send
MQMessage msg = new MQMessage();
//5MB file
baos = MQSUtil.readFile("C:/Test.doc");
msg.write(baos.toByteArray());
MQPutMessageOptions mqpo = new MQPutMessageOptions(); //Blank options
defaultQ.put(msg); //Put the message in queue
// Getting the message from queue
MQMessage rmsg = new MQMessage();
rmsg.messageId = msg.messageId;
MQGetMessageOptions mqgo = new MQGetMessageOptions();
defaultQ.get(rmsg, mqgo);
System.out.println("[Received : "+rmsg.readUTF()+"]");
// Close the queue
defaultQ.close();
// Disconnect from the mq manager
mqManager.disconnect();
Thanks,
Jade |
|
Back to top |
|
 |
bower5932 |
Posted: Thu Sep 11, 2008 2:30 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
Are you getting an error that you could post? |
|
Back to top |
|
 |
jadaaih |
Posted: Thu Sep 11, 2008 2:44 am Post subject: |
|
|
Apprentice
Joined: 10 Sep 2008 Posts: 25
|
bower5932 wrote: |
Are you getting an error that you could post? |
Sorry to have missed that out...The following is the trace,
MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
com.ibm.mq.MQException: MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:212)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:318)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:338)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:84)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:168)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:772)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:697)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:657)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:153)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:451)
at com.mqs.research.MQMain.main(MQMain.java:44)
Caused by: com.ibm.mqservices.MQInternalException: MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
at com.ibm.mq.MQv6InternalCommunications.checkControlFlags(MQv6InternalCommunications.java:740)
at com.ibm.mq.MQv6InternalCommunications.establishChannel(MQv6InternalCommunications.java:656)
at com.ibm.mq.MQv6InternalCommunications.initialize(MQv6InternalCommunications.java:206)
at com.ibm.mq.MQv6InternalCommunications.<init>(MQv6InternalCommunications.java:102)
at com.ibm.mq.MQSESSIONClient.MQCONNX(MQSESSIONClient.java:1337)
at com.ibm.mq.MQSESSIONClient.MQCONN(MQSESSIONClient.java:1246)
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:184)
... 10 more |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Sep 11, 2008 2:45 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You are setting the host and channel. You are not setting the port. MQ will assume the default port of 1414. If your qmgr uses a listener on a different port you will not be able to communicate with it.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jadaaih |
Posted: Thu Sep 11, 2008 3:05 am Post subject: |
|
|
Apprentice
Joined: 10 Sep 2008 Posts: 25
|
Bingo!! you got it right again...Its working with the port set up...
However I am facing issues in reading such a huge message using readFully method...I had to tweak the VM arguments Heap size...Is there a better way of doing it by configuration or is this the only way?
Also one more question, if I am adding a message in server connection channel, is there any way to add it in local queue or remote queue automatically through configuration or programmatically? |
|
Back to top |
|
 |
jadaaih |
Posted: Thu Sep 11, 2008 3:13 am Post subject: |
|
|
Apprentice
Joined: 10 Sep 2008 Posts: 25
|
I am getting the same stack trace when trying to send a message to a remote queue using the java code,
Queue Manager : QM_ORANGE
Port : 1414
Queue Name : Q1 Type : Remote
Channel Name : QM_ORANGE.QM_APPLE Type : Sender
So again I am doing a wrong thing  |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Sep 11, 2008 3:16 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
But are you getting the same reason code in your stack trace?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jadaaih |
Posted: Thu Sep 11, 2008 3:22 am Post subject: |
|
|
Apprentice
Joined: 10 Sep 2008 Posts: 25
|
fjb_saper wrote: |
But are you getting the same reason code in your stack trace?  |
Yes same reason code
MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
com.ibm.mq.MQException: MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:212)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:318)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:338)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:84)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:168)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:772)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:697)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:657)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:153)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:451)
at com.mqs.research.MQMain.main(MQMain.java:45)
Caused by: com.ibm.mqservices.MQInternalException: MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
at com.ibm.mq.MQv6InternalCommunications.checkControlFlags(MQv6InternalCommunications.java:740)
at com.ibm.mq.MQv6InternalCommunications.establishChannel(MQv6InternalCommunications.java:656)
at com.ibm.mq.MQv6InternalCommunications.initialize(MQv6InternalCommunications.java:206)
at com.ibm.mq.MQv6InternalCommunications.<init>(MQv6InternalCommunications.java:102)
at com.ibm.mq.MQSESSIONClient.MQCONNX(MQSESSIONClient.java:1337)
at com.ibm.mq.MQSESSIONClient.MQCONN(MQSESSIONClient.java:1246)
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:184)
... 10 more |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Sep 11, 2008 3:28 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Same reason code = same kind of problem. Search the forum! The causes for 2009 rc are multiple... Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jadaaih |
Posted: Thu Sep 11, 2008 4:33 am Post subject: |
|
|
Apprentice
Joined: 10 Sep 2008 Posts: 25
|
Anways, Can I send message to any channel irrespective of its type through the java code or is it restricted? |
|
Back to top |
|
 |
bower5932 |
Posted: Thu Sep 11, 2008 6:14 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
jadaaih wrote: |
Anways, Can I send message to any channel irrespective of its type through the java code or is it restricted? |
Are you asking if your program can use a server connection channel of a different queue manager and send messages to it, the answer is yes.
If you are asking can you use any type of channel to connect to a queue manager, the answer is no. Some of the channels are for clients. The others are for qmgr to qmgr communication. |
|
Back to top |
|
 |
jadaaih |
Posted: Thu Sep 11, 2008 10:32 pm Post subject: |
|
|
Apprentice
Joined: 10 Sep 2008 Posts: 25
|
Thanks bower...Got the questions answered !! |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Sep 12, 2008 7:17 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
|
Back to top |
|
 |
|