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 IndexIBM MQ API SupportC# MQRC_NOT_CONVERTED MQException

Post new topicReply to topic Goto page 1, 2, 3  Next
C# MQRC_NOT_CONVERTED MQException View previous topic :: View next topic
Author Message
ranjha100
PostPosted: Wed Jul 25, 2012 12:18 pm Post subject: C# MQRC_NOT_CONVERTED MQException Reply with quote

Novice

Joined: 05 Jul 2012
Posts: 15

I am converting a Java client code to C#. I am getting a MQRC_NOT_CONVERTED error when doing a Get on a MQQueue on a reply message.
The java code is working perfectly. The application sends a message to the queue and receives a reply message in another queue. What are some things I need to be aware of when sending and getting the messages through C#. I read something about encoding and charaterSet, and format. I have noticed that C# MQMessage messages have a encoding of 546 and a CharaterSet of 1200 vs encoding 273 and CharaterSet 819 for the Java MQMessage. Does any conversion have to be done and where? I only have access to the code putting the message in the queue and getting the response so any conversion has to be done, i can only do on my end.

Here is a little code snippet that puts the message in the queue.

Code:

    public MQMessage put(MqTran msg)
    {
        // create a new message object
        MQMessage writeMsg = new MQMessage();

        // set the MQMD values
        writeMsg.Report =
             MQC.MQRO_EXCEPTION_WITH_DATA |
             MQC.MQRO_NEW_MSG_ID |
             MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID;

        writeMsg.UserId = racfId;

        writeMsg.MessageType = MQC.MQMT_REQUEST;
        writeMsg.Format = "MQIMS";
        writeMsg.Priority    = MQC.MQPRI_PRIORITY_AS_Q_DEF;
        writeMsg.Persistence = MQC.MQPER_NOT_PERSISTENT;

        if (mSecondExpiry == 0)
        {
            writeMsg.Expiry = MQC.MQEI_UNLIMITED;
        }
        else
        {
            writeMsg.Expiry = mSecondExpiry;
        }

        if (replyQName.Length > 0)
        {
            writeMsg.ReplyToQueueName = replyQName;
        }

        writeMsg.ReplyToQueueManagerName = qMgr.Name;

        // Build an IMS information header
        MqIih iih = new MqIih();

        iih.format = "MQIMSVS";
        iih.ltermOverride = "        ";
        iih.mfsMapName = "        ";
        iih.replyToFormat = "MQIMSVS";
        iih.commitMode = '1';
        iih.securityScope = 'C';
        iih.encoding = 0;
        iih.codedCharSetId = 0;

        try
        {
            // place the IIH into the write message buffer
            iih.write(writeMsg);

            // insert the transaction data
            msg.write(writeMsg);
        }
        catch (IOException ioe)
        {         
        }

        // set up the put msg options
        MQPutMessageOptions pmo = new MQPutMessageOptions();
        pmo.Options =
             MQC.MQPMO_NO_SYNCPOINT |
             MQC.MQPMO_SET_IDENTITY_CONTEXT ;

        // put the message
        Q.Put(writeMsg, pmo);

        return writeMsg;
    }
    }




Here is a little code snippet of getting the reply message from the queue.
Code:

        // Create an object to hold reply msg
        MQMessage replyMsg = new MQMessage();

            replyMsg.ResizeBuffer(30000);
       

        // Set up the get msg options
        MQGetMessageOptions gmo = new MQGetMessageOptions();

        if (correlationId != null)
        {
            replyMsg.CorrelationId = correlationId;
        }

        gmo.Options =
            MQC.MQGMO_NO_SYNCPOINT |
            MQC.MQGMO_WAIT |   
            MQC.MQGMO_FAIL_IF_QUIESCING |
            MQC.MQGMO_CONVERT |
            MQC.MQGMO_ACCEPT_TRUNCATED_MSG; ;
            gmo.WaitInterval = mSecondTimeout;

        // Get the message
        Q.Get(replyMsg, gmo);


Here is the MqIih class:
Code:

    class MqIih
    {
            /** Length of an IIH */
    public static int MQ_IIH_LENGTH = 84;

    static int MQ_TRAN_INSTANCE_ID_LENGTH = 16;

    // instance variables
    String strucId        = "IIH ";
    int version           = 1;
    int strucLength       = MQ_IIH_LENGTH;
    public int encoding = MQC.MQENC_NATIVE;
    public int codedCharSetId = MQC.MQCCSI_Q_MGR;
    public String format = MQC.MQFMT_NONE;
    int flags             = 0;
    public String ltermOverride  = "";
    public  String mfsMapName = "";
    public  String replyToFormat = "";
    String authenticator  = "";
    public byte[] tranInstanceId = new byte[MQ_TRAN_INSTANCE_ID_LENGTH];
    public  char tranState = ' ';
    public  char commitMode = '0';
    public  char securityScope = 'C';
    public  char reserved = ' ';

    /**
     * Create a IIH object.
     */
    public MqIih()
    {
    }


    public static MqIih read(MQMessage msg)
    {
        MqIih iih = new MqIih();

        int startPos = msg.MessageLength - msg.DataLength;

        msg.Seek(0);

        iih.strucId = msg.ReadString(4);
        iih.version = msg.ReadInt();
        iih.strucLength = msg.ReadInt();
        iih.encoding = msg.ReadInt();
        iih.codedCharSetId = msg.ReadInt();
        iih.format = msg.ReadString(8);
        iih.flags = msg.ReadInt();
        iih.ltermOverride = msg.ReadString(8);
        iih.mfsMapName = msg.ReadString(8);
        iih.replyToFormat = msg.ReadString(8);
        iih.authenticator = msg.ReadString(8);

        try
        {
            for (int i = 0; i < MqIih.MQ_TRAN_INSTANCE_ID_LENGTH; i++)
            {
                iih.tranInstanceId[i] = (byte)msg.ReadUnsignedByte();
            }

       
        iih.tranState = (char) msg.ReadUnsignedByte();
        iih.commitMode = (char) msg.ReadUnsignedByte();
        iih.securityScope = (char) msg.ReadUnsignedByte();
        iih.reserved = (char) msg.ReadUnsignedByte();

        msg.Seek(startPos);
        }
        catch (EndOfStreamException ex)
        {

            Console.WriteLine("EOF Exception occurred:" + " message= " + ex.Message);
            Console.WriteLine(ex.ToString());
        }
       
        return iih;
    }

    public void write(MQMessage msg)
    {
        msg.WriteString(ToolBox.padString(strucId, 4));
        msg.WriteInt(version);
        msg.WriteInt(strucLength);
        msg.WriteInt(encoding);
        msg.WriteInt(codedCharSetId);
        msg.WriteString(ToolBox.padString(format, 8));
        msg.WriteInt(flags);
        msg.WriteString(ToolBox.padString(ltermOverride, 8));
        msg.WriteString(ToolBox.padString(mfsMapName, 8));
        msg.WriteString(ToolBox.padString(replyToFormat, 8));
        msg.WriteString(ToolBox.padString(authenticator, 8));

        for (int i=0; i < MqIih.MQ_TRAN_INSTANCE_ID_LENGTH; i++)
        {
            if (i < tranInstanceId.Length)
                msg.WriteByte(tranInstanceId[i]);
            else
                msg.WriteByte(0);
        }

        msg.WriteByte((byte) tranState);
        msg.WriteByte((byte) commitMode);
        msg.WriteByte((byte) securityScope);
        msg.WriteByte((byte) reserved);
    }


This code works fine Java, but I get that exception MQRC_NOT_CONVERTED during the Q.Get(replyMsg, gmo); in C#. What could be the problem?
Back to top
View user's profile Send private message
rekarm01
PostPosted: Thu Jul 26, 2012 11:41 pm Post subject: Re: C# MQRC_NOT_CONVERTED MQException Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1239

ranjha100 wrote:
I have noticed that C# MQMessage messages have a encoding of 546 and a CharaterSet of 1200 vs encoding 273 and CharaterSet 819 for the Java MQMessage.

MQ headers such as the MQIIH headers have fixed size character fields; they work best with single byte characters. 1200 (UTF-16) is a multi-byte encoding. Since 819 (ISO 8859-1) is known to work, that's a good choice. 1208 (UTF-8) is also popular, as long as the character data in the MQ headers uses only ASCII characters. Modify the MQMessage.characterSet property as needed.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Fri Jul 27, 2012 5:03 am Post subject: Re: C# MQRC_NOT_CONVERTED MQException Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 7798
Location: US: west coast, almost. Otherwise, enroute.

ranjha100 wrote:
I have noticed that C# MQMessage messages have a encoding of 546 and a CharaterSet of 1200 vs encoding 273 and CharaterSet 819 for the Java MQMessage.

I have noticed that messages and their CCSIDs and encodings are not a function of the programming language chosen.
_________________
I didn't know that Schrdinger had a cat.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jul 27, 2012 5:23 am Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17307

Both Java and .NET use Unicode as their base character set for string values.
Back to top
View user's profile Send private message
ranjha100
PostPosted: Fri Jul 27, 2012 8:56 am Post subject: Re: C# MQRC_NOT_CONVERTED MQException Reply with quote

Novice

Joined: 05 Jul 2012
Posts: 15

rekarm01 wrote:
ranjha100 wrote:
I have noticed that C# MQMessage messages have a encoding of 546 and a CharaterSet of 1200 vs encoding 273 and CharaterSet 819 for the Java MQMessage.

MQ headers such as the MQIIH headers have fixed size character fields; they work best with single byte characters. 1200 (UTF-16) is a multi-byte encoding. Since 819 (ISO 8859-1) is known to work, that's a good choice. 1208 (UTF- is also popular, as long as the character data in the MQ headers uses only ASCII characters. Modify the MQMessage.characterSet property as needed.


I have tried changing the characterSet property to both of those values, but I am still getting that error message. What could the problem be?
Back to top
View user's profile Send private message
bruce2359
PostPosted: Fri Jul 27, 2012 9:16 am Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 7798
Location: US: west coast, almost. Otherwise, enroute.

Encoding, character set and format fields in the MQMD describe attributes of the application data component of your message. Merely changing these fields in the MQMD does not change the application data itself.
_________________
I didn't know that Schrdinger had a cat.
Back to top
View user's profile Send private message
ranjha100
PostPosted: Fri Jul 27, 2012 9:30 am Post subject: Reply with quote

Novice

Joined: 05 Jul 2012
Posts: 15

bruce2359 wrote:
Encoding, character set and format fields in the MQMD describe attributes of the application data component of your message. Merely changing these fields in the MQMD does not change the application data itself.


So where does the conversion have to be done? In my code, when I do a Put and a Get in the queues, how do I specify or convert the data? The queue manager is on a SunOS Unix system. The client is Windows. Any help will be appreciated.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jul 27, 2012 10:32 am Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17307

Conversion is always done on GET.

You need to change the ccsid on the message object BEFORE you write to it.
Back to top
View user's profile Send private message
ranjha100
PostPosted: Fri Jul 27, 2012 10:55 am Post subject: Reply with quote

Novice

Joined: 05 Jul 2012
Posts: 15

mqjeff wrote:
Conversion is always done on GET.

You need to change the ccsid on the message object BEFORE you write to it.


How do I change the CCSID on the MQMessage object, that object doesn't have any methods to change that?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jul 27, 2012 11:15 am Post subject: Re: C# MQRC_NOT_CONVERTED MQException Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17307

ranjha100 wrote:
I have tried changing the characterSet property to both of those values, but I am still getting that error message.
Back to top
View user's profile Send private message
ranjha100
PostPosted: Fri Jul 27, 2012 11:41 am Post subject: Re: C# MQRC_NOT_CONVERTED MQException Reply with quote

Novice

Joined: 05 Jul 2012
Posts: 15

mqjeff wrote:
ranjha100 wrote:
I have tried changing the characterSet property to both of those values, but I am still getting that error message.


I have done replyMsg.CharacterSet = 819; before the Get, but I am still getting the error message MQRC_NOT_CONVERTED on the Get. I looked at the debugger and the MQMessage CharacterSet = 1200 after the Get call is ran. Why is it getting changed?[/list]
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jul 27, 2012 11:42 am Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17307

Set it before you write into the message before you do the PUT.
Back to top
View user's profile Send private message
ranjha100
PostPosted: Fri Jul 27, 2012 12:13 pm Post subject: Reply with quote

Novice

Joined: 05 Jul 2012
Posts: 15

mqjeff wrote:
Set it before you write into the message before you do the PUT.


Ok I have done writeMsg.CharacterSet = 819; before the Put happens. Now I am getting MQRC_FORMAT_ERROR on the GET. Also, the MQMessage replyMsg CharacterSet = 500 after the Get call is ran now. Its still not 819, why is that?
Back to top
View user's profile Send private message
bruce2359
PostPosted: Fri Jul 27, 2012 12:23 pm Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 7798
Location: US: west coast, almost. Otherwise, enroute.

ranjha100 wrote:
Ok I have done writeMsg.CharacterSet = 819; before the Put happens.

Did you look in the queue to verify that the message ccsid was 819?

ranjha100 wrote:
Now I am getting MQRC_FORMAT_ERROR on the GET.


The GET is for the reply message, yes? Did you look up MQRC_FORMAT_ERROR? What does it mean?


ranjha100 wrote:
Also, the MQMessage replyMsg CharacterSet = 500 after the Get call is ran now. Its still not 819, why is that?

The replying app sets the ccsid of the reply messsage, just like the requesting app sets the ccsid of the request message.
_________________
I didn't know that Schrdinger had a cat.
Back to top
View user's profile Send private message
ranjha100
PostPosted: Fri Jul 27, 2012 12:49 pm Post subject: Reply with quote

Novice

Joined: 05 Jul 2012
Posts: 15

bruce2359 wrote:
Did you look in the queue to verify that the message ccsid was 819?

Yes after the Put call is complete the writeMsg CharacterSet = 819. So thats fine.

bruce2359 wrote:
The GET is for the reply message, yes? Did you look up MQRC_FORMAT_ERROR? What does it mean?

Yes, The GET is for the reply message. I have looked at the MQRC_FORMAT_ERROR error and it means that "message cannot be converted successfully due to an error associated with the message format".
Code:

        // Create an object to hold reply msg
        MQMessage replyMsg = new MQMessage();

            replyMsg.ResizeBuffer(30000);
       
        // Set up the get msg options
        MQGetMessageOptions gmo = new MQGetMessageOptions();

        if (correlationId != null)
        {
            replyMsg.CorrelationId = correlationId;
        }

        gmo.Options =
            MQC.MQGMO_NO_SYNCPOINT |
            MQC.MQGMO_WAIT |   
            MQC.MQGMO_FAIL_IF_QUIESCING |
            MQC.MQGMO_CONVERT |
            MQC.MQGMO_ACCEPT_TRUNCATED_MSG; ;
            gmo.WaitInterval = mSecondTimeout;

        // Get the message
        Q.Get(replyMsg, gmo);


Where could the problem be?
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Goto page 1, 2, 3  Next Page 1 of 3

MQSeries.net Forum IndexIBM MQ API SupportC# MQRC_NOT_CONVERTED MQException
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.