Author |
Message
|
kocsc |
Posted: Tue Nov 20, 2007 2:45 am Post subject: .NET XMS, JMS problem |
|
|
Newbie
Joined: 09 Nov 2007 Posts: 6
|
Hi
I have a problem sending a message to a WebLogic JMS messagequeue.
I'm sending a message from a .NET application via a Websphere MQ to a WebLogic JMS message queue. The message I'm sending must be compliant to JMS 1.1, so I've made a XMS implementation as seen below, because it should be compliant to JMS 1.1.
At the WebLogic site they have a listenerapplication that picks up messages at the Websphere MQ queue NS_MS_0009_S_OUT.
But the problem is the WebLogic site gets a "MQJMS0003 Destination not understood or no longer valid" error when I put a message on NS_MS_0009_S_OUT.
I'm confused because I put the message on the right Websphere queue and the message gets picked up by the listener at WebLogic, so it's actually out of my control and from my point of view, picked up correctly. Do I need to provide some destination information, although it seems illogical, that relates to the WebLogic queue configuration in my XMS message?
I've seen Java JMS examples doing exactly the same as me and they don't get any errors.
I'm not sure if I need to set this at all, because I'm setting queuenames in the IDestination object?
iConnFact.SetStringProperty(XMSC.WMQ_QUEUE_NAME, "NS_MS_0009_S_OUT");
iConnFact.SetStringProperty(XMSC.WMQ_BROKER_PUBQ, "NS_MS_0009_S_OUT");
I've also tried to send without these parameters and it's still the same error (MQJMS0003).
I'd like to know if anyone has experience sending JMS messages from .NET via Websphere MQ to a WebLogic JMS messagequeue? And maybe they could provide me with some code or give me some hints on what I'm doing wrong.
Best
Kristoffer
Code: |
XMSFactoryFactory factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
// Use the connection factories factory to create a connection factory
IConnectionFactory iConnFact = factoryFactory.CreateConnectionFactory();
// Set the properties
iConnFact.SetStringProperty(XMSC.WMQ_HOST_NAME, AppProp.MQConnectionName);
iConnFact.SetIntProperty(XMSC.WMQ_PORT, int.Parse(AppProp.MQPort));
iConnFact.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
iConnFact.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, AppProp.MQQueueManagerName);
iConnFact.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V2);
iConnFact.SetStringProperty(XMSC.WMQ_CHANNEL, AppProp.MQChannelName);
iConnFact.SetStringProperty(XMSC.WMQ_QUEUE_NAME, "NS_MS_0009_S_OUT");//Necessary?
iConnFact.SetStringProperty(XMSC.WMQ_BROKER_PUBQ, "NS_MS_0009_S_OUT");//Necessary?
IConnection iConn = iConnFact.CreateConnection();
ISession iSess = iConn.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
IDestination iDest = iSess.CreateQueue("queue://NS_MS_0009_S_OUT");
iDest.SetIntProperty(XMSC.WMQ_TARGET_CLIENT, XMSC.WMQ_TARGET_DEST_JMS);
IMessageProducer iProducer = iSess.CreateProducer(iDest);
iConn.Start();
IMessage iMsg = iSess.CreateTextMessage(message);//message = simple xml document
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(message);
iMsg.SetStringProperty("MessageID", Functions.getMessageID(xDoc));
iMsg.SetStringProperty("CorrelationID", Functions.getFileLogicalSessionID(xDoc));
iProducer.Send(iMsg);
|
|
|
Back to top |
|
 |
kocsc |
Posted: Tue Nov 20, 2007 2:53 am Post subject: |
|
|
Newbie
Joined: 09 Nov 2007 Posts: 6
|
Ups! sorry
My installation:
Windows XP Pro
IBM Message Service Client for .NET 1.2.6.0
IBM Websphere MQ For Windows, Version 6.0 (Client)
(6.0.2-WS-MQ-WinIA32-FP0002-EnUs.zip)
Kristoffer |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Nov 20, 2007 5:48 am Post subject: Re: .NET XMS, JMS problem |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
kocsc wrote: |
I've seen Java JMS examples doing exactly the same as me and they don't get any errors. |
I'd try putting a message from your application and one from JMS. You can then browse the queue to see how they differ which might shed some light on what is going wrong. |
|
Back to top |
|
 |
kocsc |
Posted: Tue Nov 20, 2007 6:03 am Post subject: |
|
|
Newbie
Joined: 09 Nov 2007 Posts: 6
|
Thank you.
That's my next step.
Downloading and installing JDK right now. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Nov 20, 2007 8:37 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Quote: |
iConnFact.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V2);
.........
iConnFact.SetStringProperty(XMSC.WMQ_QUEUE_NAME, "NS_MS_0009_S_OUT");//Necessary?
iConnFact.SetStringProperty(XMSC.WMQ_BROKER_PUBQ, "NS_MS_0009_S_OUT");//Necessary? |
From these lines it is not clear to me whether you want to define a qcf or a tcf. For a qcf these lines should not be necessary.
The line in red might be for the default name of the dynamic queue and you should have something like 'myapp.*' in there or the name of the corresponding model queue...
So it looks to me like you have some flaws in the definition of your connection factory...
In any case the name of the queue in the few lines I quoted is completely wrong... _________________ MQ & Broker admin |
|
Back to top |
|
 |
kocsc |
Posted: Wed Nov 21, 2007 12:09 am Post subject: |
|
|
Newbie
Joined: 09 Nov 2007 Posts: 6
|
Thank you!
It's a queue connection factory I make.
I've tried without these lines and still the same error (MQJMS0003) at WebLogic.
Kristoffer |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Nov 21, 2007 12:01 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Remember JMSExceptions and errors have very little meaning. By definition they are very generic. What we need is the provider exception.
To get to the provider exception you need to extract the linked exception from the JMS exception and display it. Remember however that the linked exception may be null...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
kocsc |
Posted: Thu Nov 22, 2007 12:18 am Post subject: |
|
|
Newbie
Joined: 09 Nov 2007 Posts: 6
|
The problem is I'm not sitting by the WebLogic server and the server adm. can only see this error.
Anyway, I found an example on how to generate a JMS message here:
http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci930896,00.html
And it worked with minor adjustments, so at least now I got something to compare my XMS against, when I get the time.
Kristoffer
Code: |
private MQMessage getMQRFH2Message(string message)
{
const string RFH2_STRUCID_DEFAULT = "RFH ";
const int RFH2_VERSION_DEFAULT = 2;
const int RFH2_STRUCLENGTH_DEFAULT = 36;
const int RFH2_ENCODING_DEFAULT = 0x00000222;
const int RFH2_CODEDCHARSETID_DEFAULT = 1208;
const string RFH2_FORMAT_DEFAULT = "MQSTR ";
const int RFH2_FLAGS_DEFAULT = 0;
const int RFH2_NAMEVALUECCSID_DEFAULT = 1208; //default(int);// 1208;
const string MCD_DATA_DEFAULT = "<mcd><Msd>jms_text</Msd></mcd>";
const string FORMAT_MESSAGE_HRF2 = "MQHRF2 ";
//Message generation
MQRFH2 rfh2 = new MQRFH2(RFH2_STRUCID_DEFAULT,
RFH2_VERSION_DEFAULT,
RFH2_STRUCLENGTH_DEFAULT,
RFH2_ENCODING_DEFAULT,
RFH2_CODEDCHARSETID_DEFAULT,
RFH2_FORMAT_DEFAULT,
RFH2_FLAGS_DEFAULT,
RFH2_NAMEVALUECCSID_DEFAULT);
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(message);
string mcd_data = MCD_DATA_DEFAULT;
string jms_data = "<jms><Dst>queue:///MYQUEUENAME</Dst><Tms>"
+ (((long)System.DateTime.Now.Ticks) - 621355968000000000)/10000 + "</Tms><Dlv>2</Dlv>" +
"<Cid>" + Functions.getFileLogicalSessionID(xDoc) + "</Cid>" +
"</jms>";
string Data = message;// XML Message to Send.
string usr_data = "<usr><version>VERSION_1</version>" +
"<MessageID>" + Functions.getMessageID(xDoc) + "</MessageID>" +
"<ReplyTo>FALSE</ReplyTo></usr>";
int mcd_len = ((mcd_data.Length - 1) / 4) * 4 + 4;
int jms_len = ((jms_data.Length - 1) / 4) * 4 + 4;
int usr_len = ((usr_data.Length - 1) / 4) * 4 + 4;
int msg_len = Data.Length;
//Padding of sections (again attention to the spaces)
mcd_data += " ";
mcd_data = mcd_data.Substring(0, mcd_len);
jms_data += " ";
jms_data = jms_data.Substring(0, jms_len);
usr_data += " ";
usr_data = usr_data.Substring(0, usr_len);
MQMessage objMsg = new MQMessage();
objMsg.Format = FORMAT_MESSAGE_HRF2;
objMsg.Persistence = (int)IBM.WMQ.MQC.MQPER_PERSISTENT;
objMsg.WriteBytes(rfh2.StrucId);
objMsg.WriteInt4(rfh2.Version);
objMsg.WriteInt4(rfh2.StrucLength + mcd_len + jms_len + usr_len + 12);
objMsg.WriteInt4(rfh2.Encoding);
objMsg.WriteInt4(rfh2.CodedCharSetId);
objMsg.WriteBytes(rfh2.Format);
objMsg.WriteInt4(rfh2.Flags);
objMsg.WriteInt4(rfh2.NameValueCCSID);
objMsg.WriteInt4 (mcd_len);
objMsg.WriteBytes(mcd_data);
objMsg.WriteInt4 (jms_len);
objMsg.WriteBytes(jms_data);
objMsg.WriteInt4 (usr_len);
objMsg.WriteBytes(usr_data);
objMsg.WriteBytes(Data);
return objMsg;
}
|
[/url][/code] |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 22, 2007 4:22 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The whole point with XMS is that you should not have to deal with the RFH2 header...
Serialize your XML into a String and send that string to the TextMessage using the setText method. Make sure to use the right CCSID for the string. (by default .NET uses ccsid 1200) If your target client on the destination is JMS you should get an RFH2 header...
Send the message and inspect while still in queue.
Enjoy
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
bower5932 |
Posted: Thu Nov 22, 2007 5:12 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
fjb_saper wrote: |
Send the message and inspect while still in queue. |
And do the inspect with the amqsbcg program not with something that you've written. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 22, 2007 5:22 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
bower5932 wrote: |
fjb_saper wrote: |
Send the message and inspect while still in queue. |
And do the inspect with the amqsbcg program not with something that you've written. |
RFHUtil or RFHUtilc should do fine and show the RFH header. _________________ MQ & Broker admin |
|
Back to top |
|
 |
kocsc |
Posted: Thu Nov 22, 2007 6:46 am Post subject: |
|
|
Newbie
Joined: 09 Nov 2007 Posts: 6
|
fjb_saper wrote: |
The whole point with XMS is that you should not have to deal with the RFH2 header...  |
Thats why I implemented XMS in the first place, but I was really frustrated when the WebLogic server would'nt accept it and all I got was MQJMS0003. So I was kind of desperate and tried to build my own RFH2 header and it worked.
Thanks a lot for your help, I'll try the tools and solutions you've provided. Unfortunately I don't have the time right now, but I'll make a followup on this thread when I've tried it.
Kristoffer |
|
Back to top |
|
 |
|