ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Formating of messages in MQSTR using C# in MQ v 7.0.1.4

Post new topic  Reply to topic
 Formating of messages in MQSTR using C# in MQ v 7.0.1.4 « View previous topic :: View next topic » 
Author Message
Faby.tp
PostPosted: Thu May 05, 2011 6:37 am    Post subject: Formating of messages in MQSTR using C# in MQ v 7.0.1.4 Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Thu May 05, 2011 6:44 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu May 05, 2011 3:07 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
shashikanth_in
PostPosted: Thu May 05, 2011 7:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu May 05, 2011 7:48 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Faby.tp
PostPosted: Fri May 06, 2011 1:06 am    Post subject: Reply with quote

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
View user's profile Send private message
Faby.tp
PostPosted: Fri May 06, 2011 4:56 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Sat May 07, 2011 8:21 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Faby.tp
PostPosted: Mon May 09, 2011 4:18 am    Post subject: Reply with quote

Novice

Joined: 05 May 2011
Posts: 13

Thank you the correction
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Formating of messages in MQSTR using C# in MQ v 7.0.1.4
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.