Author |
Message
|
moi3 |
Posted: Wed Apr 06, 2005 10:35 am Post subject: Using Websphere MQ API inside a J2EE app server |
|
|
Novice
Joined: 05 Apr 2005 Posts: 24
|
I tried to use this code inside my J2EE Websphere application. It works fine as a stand alone application. The reason i don't use JMS is somehow it does not work on HP UX so I have to use the below API. But when I run my app, I got the error
com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2058
com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:246)
Have anyone tried to use the below code inside a J2EE app before? Right now I hard code the name of the queue manager and queue. Do I need to look it up via JNDI? Any sample code would be great. Thanks
MQQueueManager qMgr = new MQQueueManager("MY_QMGR");
int openOptions = MQC.MQOO_OUTPUT;
MQQueue q = qMgr.accessQueue("MY.Q", openOptions, null, null, null);
MQMessage mBuf = new MQMessage();
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_NONE; // use defaults
mBuf.clearMessage(); // reset the buffer
mBuf.correlationId = MQC.MQCI_NONE; // set correlationId
mBuf.messageId = MQC.MQMI_NONE; // set messageId
mBuf.writeString("hello world"); // set actual message
q.put(mBuf, pmo);
q.close();
qMgr.disconnect(); |
|
Back to top |
|
 |
malammik |
Posted: Wed Apr 06, 2005 11:27 am Post subject: |
|
|
 Partisan
Joined: 27 Jan 2005 Posts: 397 Location: Philadelphia, PA
|
It worked for me without JNDI because I did not need it. I was running was 5.0 network deployment on Z/OS. It did not work entirely though. For example MQEnvironment.enableTrace() call was ignored. I opened up a PMR with IBM and they said I should not be using base java classes inside WAS, I should be using JMS. _________________ Mikhail Malamud
http://www.netflexity.com
http://groups.google.com/group/qflex |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Apr 06, 2005 12:35 pm Post subject: Re: Using Websphere MQ API inside a J2EE app server |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
moi3 wrote: |
I tried to use this code inside my J2EE Websphere application. It works fine as a stand alone application. The reason i don't use JMS is somehow it does not work on HP UX so I have to use the below API. But when I run my app, I got the error ....
|
What do you mean JMS does not work on HPUX?
Did you set up all the needed variables for WAS to find the jars etc... ??
What was the error that WAS gave you ?
Did you do the right WAS setup?
Have you had this running on any other WAS non HPUX ?
Enjoy  |
|
Back to top |
|
 |
moi3 |
Posted: Wed Apr 06, 2005 12:47 pm Post subject: |
|
|
Novice
Joined: 05 Apr 2005 Posts: 24
|
JMS does not work on HP UX bec. when I submitted a message, it went directly into the system.dead.letter.queue. I already defined all the queues and channels on hp ux already. It works fine on windows. I have not tried it out on other unix flavors yet. Anyone got JMS working in a J2EE environment on HP UX?
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("jms/myQCF");
con = factory.createQueueConnection();
QueueSession session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue) ctx.lookup("jms/myQ");
QueueSender sender = session.createSender(queue);
TextMessage message = session.createTextMessage(textMessage);
sender.send(message);
AMQSBCG0 - starts here
**********************
MQOPEN - 'SYSTEM.DEAD.LETTER.QUEUE'
MQGET of message number 1
****Message descriptor****
StrucId : 'MD ' Version : 2
Report : 0 MsgType : 8
Expiry : -1 Feedback : 0
Encoding : 273 CodedCharSetId : 1051
Format : 'MQDEAD '
Priority : 4 Persistence : 1
MsgId : X'414D51205741535F514153434D4153324252C47E20000310'
CorrelId : X'000000000000000000000000000000000000000000000000'
BackoutCount : 0
ReplyToQ : ' '
ReplyToQMgr : 'WAS_QASCMAS2 '
** Identity Context
UserIdentifier : 'compass '
AccountingToken :
X'0331303800000000000000000000000000000000000000000000000000000006'
ApplIdentityData : ' '
** Origin Context
PutApplType : '6'
PutApplName : 'java '
PutDate : '20050405' PutTime : '22592419'
ApplOriginData : ' '
GroupId : X'000000000000000000000000000000000000000000000000'
MsgSeqNumber : '1'
Offset : '0'
MsgFlags : '0'
OriginalLength : '-1'
**** Message ****
length - 1405 bytes |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Apr 06, 2005 1:10 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
This just proves to the contrary that JMS is working.
What you need to find out is what the reason code on the DLQ is and what the destination queue name and qmgr on the DLQ record are.
This will help you find what the queue definition that you are retrieving from the context has wrong or missing.
My guess is your queue definition in your JNDI context is not up to par.
try adding some code like
Code: |
System.out.println(queue.getQueueName()); |
You should see a url that will give you something like qmgr/queue?attributes
Enjoy
[/code] |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Apr 06, 2005 1:16 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
It would also help to see the first couple of hex lines of output from amqsbcg. This would give the actual reason for why the message was put on the dead letter queue. |
|
Back to top |
|
 |
moi3 |
Posted: Wed Apr 06, 2005 3:44 pm Post subject: |
|
|
Novice
Joined: 05 Apr 2005 Posts: 24
|
I changed my program and added the following changes
message.setJMSCorrelationID(String.valueOf(MQC.MQCI_NONE));
message.setJMSMessageID(String.valueOf(MQC.MQMI_NONE));
but it still puts it into the dead letter queue. |
|
Back to top |
|
 |
EddieA |
Posted: Wed Apr 06, 2005 5:21 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
We need the start of the message to see why it went to the DLQ.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Apr 06, 2005 7:57 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
moi3 wrote: |
I changed my program and added the following changes
message.setJMSCorrelationID(String.valueOf(MQC.MQCI_NONE));
message.setJMSMessageID(String.valueOf(MQC.MQMI_NONE));
but it still puts it into the dead letter queue. |
Not a good change in JMS. Leave those alone !
The problem is most probably with the definition of your target Q.
As Eddie said we really do need the full DLQ header.
As well did you do the change I asked for. What is the output ?
Enjoy  |
|
Back to top |
|
 |
moi3 |
Posted: Wed Apr 06, 2005 9:37 pm Post subject: |
|
|
Novice
Joined: 05 Apr 2005 Posts: 24
|
Yes I put in your change. Here's the output of your change, the jms code and the entire header and detail info of the message that went directly into the dead letter queue the minute I put it into the remote queue. I undo the 2 changes that I made.
queue://CAMQ/TEST.Q?targetClient=1
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("jms/myQCF");
con = factory.createQueueConnection();
QueueSession session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue) ctx.lookup("jms/myQ");
QueueSender sender = session.createSender(queue);
TextMessage message = session.createTextMessage(textMessage);
sender.send(message);
AMQSBCG0 - starts here
**********************
MQOPEN - 'SYSTEM.DEAD.LETTER.QUEUE'
MQGET of message number 1
****Message descriptor****
StrucId : 'MD ' Version : 2
Report : 0 MsgType : 8
Expiry : -1 Feedback : 0
Encoding : 273 CodedCharSetId : 1051
Format : 'MQDEAD '
Priority : 4 Persistence : 1
MsgId : X'414D51205741535F514153434D4153324252C47E20000310'
CorrelId : X'000000000000000000000000000000000000000000000000'
BackoutCount : 0
ReplyToQ : ' '
ReplyToQMgr : 'WAS_QASCMAS2 '
** Identity Context
UserIdentifier : 'compass '
AccountingToken :
X'0331303800000000000000000000000000000000000000000000000000000006'
ApplIdentityData : ' '
** Origin Context
PutApplType : '6'
PutApplName : 'java '
PutDate : '20050405' PutTime : '22592419'
ApplOriginData : ' '
GroupId : X'000000000000000000000000000000000000000000000000'
MsgSeqNumber : '1'
Offset : '0'
MsgFlags : '0'
OriginalLength : '-1'
**** Message ****
length - 1405 bytes
00000000: 444C 4820 0000 0001 0000 0847 594D 4139 'DLH .......GYMA9'
00000010: 392E 434F 4D50 4153 532E 4F52 4445 522E '9.COMPASS.ORDER.'
00000020: 5155 4555 4520 2020 2020 2020 2020 2020 'QUEUE '
00000030: 2020 2020 2020 2020 2020 2020 4D51 5431 ' MQT1'
00000040: 2020 2020 2020 2020 2020 2020 2020 2020 ' '
00000050: 2020 2020 2020 2020 2020 2020 2020 2020 ' '
00000060: 2020 2020 2020 2020 2020 2020 0000 0111 ' ....'
00000070: 0000 04B8 4D51 5354 5220 2020 0000 0006 '....MQSTR ....'
00000080: 7275 6E6D 7163 686C 5F6E 6420 2020 2020 'runmqchl_nd '
00000090: 2020 2020 2020 2020 2020 2020 3230 3035 ' 2005'
000000A0: 3034 3035 3232 3539 3234 3232 3C3F 786D '040522592422<?xm'
000000B0: 6C20 7665 7273 696F 6E3D 2231 2E30 2220 'l version="1.0" '
000000C0: 656E 636F 6469 6E67 3D22 5554 462D 3822 'encoding="UTF-8"'
000000D0: 3F3E 0A3C 7472 616E 7361 6374 696F 6E20 '?>.<transaction '
000000E0: 786D 6C6E 733A 636F 6D70 6173 733D 2268 'xmlns:compass="h'
000000F0: 7474 703A 2F2F 636F 6D70 6173 7322 3E3C 'ttp://compass"><'
00000100: 6F72 6465 723E 3C73 616C 6573 2D6F 7264 'order><sales-ord'
00000110: 6572 2D6E 756D 6265 723E 4D43 3035 3530 'er-number>MC0550'
00000120: 3930 4D43 3035 4131 3C2F 7361 6C65 732D '90MC05A1</sales-'
00000130: 6F72 6465 722D 6E75 6D62 6572 3E3C 7361 'order-number><sa'
00000140: 6C65 732D 6F66 6669 6365 3E43 413C 2F73 'les-office>CA</s'
00000150: 616C 6573 2D6F 6666 6963 653E 3C73 616C 'ales-office><sal'
00000160: 6573 2D70 726F 6772 616D 3E4D 4330 3541 'es-program>MC05A'
00000170: 3C2F 7361 6C65 732D 7072 6F67 7261 6D3E '</sales-program>'
00000180: 3C73 6F6C 642D 746F 3E30 3535 3039 303C '<sold-to>055090<'
00000190: 2F73 6F6C 642D 746F 3E3C 7265 6C65 6173 '/sold-to><releas'
000001A0: 652D 6C69 7374 3E3C 7265 6C65 6173 653E 'e-list><release>'
000001B0: 3C6F 6964 3E31 3730 3333 3838 3531 3C2F '<oid>170338851</'
000001C0: 6F69 643E 3C70 7269 6F72 6974 793E 353C 'oid><priority>5<'
000001D0: 2F70 7269 6F72 6974 793E 3C66 7265 6967 '/priority><freig'
000001E0: 6874 3E66 616C 7365 3C2F 6672 6569 6768 'ht>false</freigh'
000001F0: 743E 3C70 726F 6772 616D 2D63 6F64 653E 't><program-code>'
00000200: 4D41 473C 2F70 726F 6772 616D 2D63 6F64 'MAG</program-cod'
00000210: 653E 3C73 6869 702D 746F 3E3C 7375 6666 'e><ship-to><suff'
00000220: 6978 3E30 3031 3C2F 7375 6666 6978 3E3C 'ix>001</suffix><'
00000230: 2F73 6869 702D 746F 3E3C 6765 6E65 7261 '/ship-to><genera'
00000240: 6C2D 6C65 6467 6572 2D6C 6973 743E 3C67 'l-ledger-list><g'
00000250: 656E 6572 616C 2D6C 6564 6765 723E 3C73 'eneral-ledger><s'
00000260: 6571 7565 6E63 653E 313C 2F73 6571 7565 'equence>1</seque'
00000270: 6E63 653E 3C2F 6765 6E65 7261 6C2D 6C65 'nce></general-le'
00000280: 6467 6572 3E3C 6765 6E65 7261 6C2D 6C65 'dger><general-le'
00000290: 6467 6572 3E3C 7365 7175 656E 6365 3E32 'dger><sequence>2'
000002A0: 3C2F 7365 7175 656E 6365 3E3C 2F67 656E '</sequence></gen'
000002B0: 6572 616C 2D6C 6564 6765 723E 3C67 656E 'eral-ledger><gen'
000002C0: 6572 616C 2D6C 6564 6765 723E 3C73 6571 'eral-ledger><seq'
000002D0: 7565 6E63 653E 333C 2F73 6571 7565 6E63 'uence>3</sequenc'
000002E0: 653E 3C2F 6765 6E65 7261 6C2D 6C65 6467 'e></general-ledg'
000002F0: 6572 3E3C 6765 6E65 7261 6C2D 6C65 6467 'er><general-ledg'
00000300: 6572 3E3C 7365 7175 656E 6365 3E34 3C2F 'er><sequence>4</'
00000310: 7365 7175 656E 6365 3E3C 2F67 656E 6572 'sequence></gener'
00000320: 616C 2D6C 6564 6765 723E 3C2F 6765 6E65 'al-ledger></gene'
00000330: 7261 6C2D 6C65 6467 6572 2D6C 6973 743E 'ral-ledger-list>'
00000340: 3C6C 696E 652D 6974 656D 2D64 6574 6169 '<line-item-detai'
00000350: 6C2D 6C69 7374 3E3C 6C69 6E65 2D69 7465 'l-list><line-ite'
00000360: 6D2D 6465 7461 696C 3E3C 6F69 643E 3137 'm-detail><oid>17'
00000370: 3033 3338 3835 373C 2F6F 6964 3E3C 6D6F '0338857</oid><mo'
00000380: 6465 6C3E 5856 5331 3141 5453 3C2F 6D6F 'del>XVS11ATS</mo'
00000390: 6465 6C3E 3C71 7561 6E74 6974 793E 313C 'del><quantity>1<'
000003A0: 2F71 7561 6E74 6974 793E 3C77 6172 6568 '/quantity><wareh'
000003B0: 6F75 7365 3E30 353C 2F77 6172 6568 6F75 'ouse>05</warehou'
000003C0: 7365 3E3C 7465 726D 3E35 314D 3C2F 7465 'se><term>51M</te'
000003D0: 726D 3E3C 7370 6C69 742D 7368 6970 2D69 'rm><split-ship-i'
000003E0: 6E64 6963 6174 6F72 3E59 3C2F 7370 6C69 'ndicator>Y</spli'
000003F0: 742D 7368 6970 2D69 6E64 6963 6174 6F72 't-ship-indicator'
00000400: 3E3C 7363 6865 6475 6C65 2D64 6174 653E '><schedule-date>'
00000410: 3C64 6179 3E36 3C2F 6461 793E 3C6D 6F6E '<day>6</day><mon'
00000420: 7468 3E34 3C2F 6D6F 6E74 683E 3C79 6561 'th>4</month><yea'
00000430: 723E 3230 3035 3C2F 7965 6172 3E3C 2F73 'r>2005</year></s'
00000440: 6368 6564 756C 652D 6461 7465 3E3C 6469 'chedule-date><di'
00000450: 7363 6F75 6E74 2D6C 6973 743E 3C64 6973 'scount-list><dis'
00000460: 636F 756E 743E 3C73 6571 7565 6E63 653E 'count><sequence>'
00000470: 313C 2F73 6571 7565 6E63 653E 3C76 616C '1</sequence><val'
00000480: 7565 3E30 2E30 3C2F 7661 6C75 653E 3C2F 'ue>0.0</value></'
00000490: 6469 7363 6F75 6E74 3E3C 6469 7363 6F75 'discount><discou'
000004A0: 6E74 3E3C 7365 7175 656E 6365 3E32 3C2F 'nt><sequence>2</'
000004B0: 7365 7175 656E 6365 3E3C 7661 6C75 653E 'sequence><value>'
000004C0: 302E 303C 2F76 616C 7565 3E3C 2F64 6973 '0.0</value></dis'
000004D0: 636F 756E 743E 3C64 6973 636F 756E 743E 'count><discount>'
000004E0: 3C73 6571 7565 6E63 653E 333C 2F73 6571 '<sequence>3</seq'
000004F0: 7565 6E63 653E 3C76 616C 7565 3E30 2E30 'uence><value>0.0'
00000500: 3C2F 7661 6C75 653E 3C2F 6469 7363 6F75 '</value></discou'
00000510: 6E74 3E3C 2F64 6973 636F 756E 742D 6C69 'nt></discount-li'
00000520: 7374 3E3C 2F6C 696E 652D 6974 656D 2D64 'st></line-item-d'
00000530: 6574 6169 6C3E 3C2F 6C69 6E65 2D69 7465 'etail></line-ite'
00000540: 6D2D 6465 7461 696C 2D6C 6973 743E 3C2F 'm-detail-list></'
00000550: 7265 6C65 6173 653E 3C2F 7265 6C65 6173 'release></releas'
00000560: 652D 6C69 7374 3E3C 2F6F 7264 6572 3E3C 'e-list></order><'
00000570: 2F74 7261 6E73 6163 7469 6F6E 3E '/transaction> '
No more messages |
|
Back to top |
|
 |
clindsey |
Posted: Thu Apr 07, 2005 5:33 am Post subject: |
|
|
Knight
Joined: 12 Jul 2002 Posts: 586 Location: Dallas, Tx
|
Here is some detail that may help:
reason code = 2119 (MQRC_NOT_CONVERTED)
encoding = 0x0111 (MQENC_FLOAT_IEEE_NORMAL + MQENC_DECIMAL_NORMAL + MQENC_INTEGER_NORMAL)
ccsid = 0x04B8 (1208) = UTF-8.
I would check your conversion tables on the HP box. It sounds like you may be missing one.
Charlie |
|
Back to top |
|
 |
moi3 |
Posted: Thu Apr 07, 2005 7:57 am Post subject: |
|
|
Novice
Joined: 05 Apr 2005 Posts: 24
|
what do u mean by conversion tables? I applied the latest fix pack (#9) for MQ. Can you give me more details pls? |
|
Back to top |
|
 |
clindsey |
Posted: Thu Apr 07, 2005 9:22 am Post subject: |
|
|
Knight
Joined: 12 Jul 2002 Posts: 586 Location: Dallas, Tx
|
First, let me state that I am no NLS expert so you may want to speak with your HP Sys Admin on this.
Your incoming message shows that it has a CCSID of 1051 and encoding of 273. The 273 = 0x111 which matches the receiving side so there is no encoding issue. It appears to me that the conversion that fails is an attempt to convert from CCSID 1051 to 1208.
You can look at the MQ supported code sets in chapter 10 of the WMQ Quick Beginnings Guide. For HP, it shows that 1051 is codeset roman8. There is no entry for 1208 so this seems to be an unsupported conversion.
On the other unix platforms, 1208 is UTF-8. I am a bit surprised there is no UTF-8 for HP ??. If it were supported though, you would need to have a conversion table in /usr/lib/nls/loc/iconv with name roman8_UTF-8.
WMQ relies on iconv at the OS level. For your conversion to work, you should be able to run "iconv -f roman8 -t UTF-8". Then you can enter some text and the converted text is echoed to the console. If you get an error, the underlying iconv environment doesn't support your conversion. This is not a WMQ problem.
Do you have the ability to change the CCSID values on your sending and receiving queue managers?. You might try changing these to values where conversion is supported and your problem should go away.
Hope this helps and any NLS expert may want to pitch in more here.
Charlie |
|
Back to top |
|
 |
clindsey |
Posted: Thu Apr 07, 2005 9:50 am Post subject: |
|
|
Knight
Joined: 12 Jul 2002 Posts: 586 Location: Dallas, Tx
|
FYI, this is right out of the WMQ Quick Beginnings Guide for HP
Quote: |
Locales using the default roman8 code set (CCSID=1051) are supported, but there might be very limited support for this code set on other platforms, which means that sending data to them using these locales is not possible.
You are recommended to use the ISO8859-1 code set (CCSID = 819) when communicating with iSeries servers and other platforms
|
See if you can change your qmgr to use ccsid 819.
Charlie |
|
Back to top |
|
 |
moi3 |
Posted: Thu Apr 07, 2005 7:32 pm Post subject: |
|
|
Novice
Joined: 05 Apr 2005 Posts: 24
|
Thanks everyone. The problem is with the CCSID and once I put the value provided by clindsey. The message is transmitted correctly to mainframe. |
|
Back to top |
|
 |
|