Author |
Message
|
Faby.tp |
Posted: Thu May 05, 2011 6:37 am Post subject: Formating of messages in MQSTR using C# in MQ v 7.0.1.4 |
|
|
Novice
Joined: 05 May 2011 Posts: 13
|
I am developing MQ Client application (v 7.0.1.4) in .Net with C#.
Through this application SWIFT messages are able to send to MINT. But all have failed to process due to invalid format of the messages.
Since messages are taken from production data, format of SWIFT message used to send is absolutely correct.
Therefore problem could be in MQSTR format.
C# code for message formating is given below:
=================
Producer producer = new Producer();
//Connection Factory Created
//Connection created
//Session created
//Destination Created
//Producer created
//Started the connection
string strSWIFTmsg="SWIFT message is assigned here"
string strTrnReference="Transaction ref"
string strAppId="R0005";
IMessage sendMsg;
StringBuilder sbdrMessageText = new StringBuilder();
sbdrMessageText.Append((strSWIFTmsg.Trim().Length + .ToString().PadLeft(8, '0')).Append(strSWIFTmsg.Trim());
string strMsgCmnt = "MSGCMNT " + " " + strTrnReference.Trim().PadRight(26) + strAppId;
sbdrMessageText.Append((strMsgCmnt.Trim().Length + .ToString().PadLeft(8, '0')).Append(strMsgCmnt.Trim());
//session variable created above is used here
msg = session.CreateTextMessage(sbdrMessageText.ToString()); //This is for TEXT Messaging
//msg = session.CreateBytesMessage(); //This is for Message transfer in Bytes which also doesnot work
//((IBytesMessage)msg).WriteUTF(sbdrMessageText.ToString()); //This is for Message transfer in Bytes which also doesnot work
//Setting the Message Format
msg.SetIntProperty("priority", 0);
msg.SetStringProperty("format", "MQSTR ");
msg.SetStringProperty("applicationIdData", "W");
producer.Send(sendMsg); //Now message is sent successfull but failed at MINT side
=================
Please help... |
|
Back to top |
|
 |
mqjeff |
Posted: Thu May 05, 2011 6:44 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I don't believe that the Format property you are trying to set is actually set by using setStringProperty.
I think you need to set it using a property of the IMessage object directly.
Also you should *always* use MQFMT_STRING rather than a hand-defined constant.
And you probably should be explicit about the CodedCharSetId. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu May 05, 2011 3:07 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Quote: |
Code: |
msg = session.CreateTextMessage(sbdrMessageText.ToString()); //This is for TEXT Messaging
//msg = session.CreateBytesMessage(); //This is for Message transfer in Bytes which also doesnot work
//((IBytesMessage)msg).WriteUTF(sbdrMessageText.ToString()); //This is for Message transfer in Bytes which also doesnot work
//Setting the Message Format
msg.SetIntProperty("priority", 0);
msg.SetStringProperty("format", "MQSTR "); |
|
You are already creating a TextMessage using XMS. Please don't set the format property, it may not be set correctly and is implicitely set by XMS when you are using a TextMessage.
Does the destination expect properties or an RFH2 header?
If not, you may want to make sure you define your destination correctly...
My guess: cast your Destination to an MQQueue and set the targetClient to 1 (see appropriate constant name in WMQ.Constants) (MQ or non JMS).
If you use the session and a queue name you should use the URI form:
"queue://QMGRNAME/QNAME?targetClient=1"
This should solve your problem.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
shashikanth_in |
Posted: Thu May 05, 2011 7:44 pm Post subject: |
|
|
Centurion
Joined: 26 Feb 2009 Posts: 123
|
Priority should be set using msg.JMSPriority property like
msg.JMSPriority=0
Also when creating the message the return value needs to be cast accordingly like below
ITextMessage msg = (ITextMessage)session.CreateTextMessage(sbdrMessageText.ToString());
Application ID can also be set as property on the message
msg.SetStringProperty(XMSC.JMSX_APPID,strAppId);
HTH |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu May 05, 2011 7:48 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
shashikanth_in wrote: |
Priority should be set using msg.JMSPriority property like
msg.JMSPriority=0
Also when creating the message the return value needs to be cast accordingly like below
ITextMessage msg = (ITextMessage)session.CreateTextMessage(sbdrMessageText.ToString());
Application ID can also be set as property on the message
msg.SetStringProperty(XMSC.JMSX_APPID,strAppId);
HTH |
Great information, but I fail to see the relevance with the OP's problem...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Faby.tp |
Posted: Fri May 06, 2011 1:06 am Post subject: |
|
|
Novice
Joined: 05 May 2011 Posts: 13
|
Hi,
Still the problem persists.
Code for Session & Destination creation are given below:
Code: |
ISession session = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge);
IDestination iDest;
iDest = session.CreateQueue("queue://QMGRNAME/QNAME?targetClient=1");
//where QMGRNAME-Queue Manager Name, QNAME-Out Queue Name
iDest.SetIntProperty(XMSC.DELIVERY_MODE, XMSC.DELIVERY_NOT_PERSISTENT); |
Also, IMessage was changed to ITextMessage and priority also assigned as msg.JMSPriority=0
How can we cast IDestination to MQQueue? MQQueue class is available in MQ Series but not in WebSphereMQ v7.0.1.4. Right?
Please clarify and suggestion to correct the code.
Thanks for your valid inputs. |
|
Back to top |
|
 |
Faby.tp |
Posted: Fri May 06, 2011 4:56 am Post subject: |
|
|
Novice
Joined: 05 May 2011 Posts: 13
|
I had made a mistake in the message format. When it was corrected to the following format, application is working fine and MINT AP is able to process the messages received.
00000025This is the SWIFT message
where first 8 characters are the message length.
Thank you very much to all for your support ....... |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat May 07, 2011 8:21 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Faby.tp wrote: |
I had made a mistake in the message format. When it was corrected to the following format, application is working fine and MINT AP is able to process the messages received.
00000025This is the SWIFT message
where first 8 characters are the message length.
Thank you very much to all for your support ....... |
Thanks for posting the solution.
Being a little pedantic, this had ultimately noting to do with the message format but was tied to the message content or the internal format of the message content and not the message format (binary, text, RFH2...) as declared on the message...
It would probably have sped up the resolution some if you had been more specific.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Faby.tp |
Posted: Mon May 09, 2011 4:18 am Post subject: |
|
|
Novice
Joined: 05 May 2011 Posts: 13
|
|
Back to top |
|
 |
|