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 » General IBM MQ Support » Why do I have to set mqmd encoding = 273 before Linux MQPUT?

Post new topic  Reply to topic
 Why do I have to set mqmd encoding = 273 before Linux MQPUT? « View previous topic :: View next topic » 
Author Message
Pootle
PostPosted: Thu Jan 07, 2016 7:38 am    Post subject: Why do I have to set mqmd encoding = 273 before Linux MQPUT? Reply with quote

Newbie

Joined: 18 Dec 2014
Posts: 7

I have a utility program mqput which wraps a call to MQPUT which I have ported from Solaris to Linux. When I tried to use it to put a message on Linux I got a 2142 error.

The MQMD encoding field is defaulting to 546 on Linux which I thought would be correct as it is Little Endian. However I have to set it to 273, the same as on Big Endian Solaris for it to work.

So I now have my program working but I don't understand why. Is anyone able to shed any light please?
Back to top
View user's profile Send private message
tczielke
PostPosted: Thu Jan 07, 2016 10:58 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 941
Location: Illinois, USA

What programming language is your mqput utility written in?

How did you determine that your Linux server is little endian?
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jan 07, 2016 10:59 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

What options is your getting program using?
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Pootle
PostPosted: Thu Jan 07, 2016 11:56 am    Post subject: Reply with quote

Newbie

Joined: 18 Dec 2014
Posts: 7

Thanks for your quick replies. To answer your questions:

1) The program is written in C.
2) I can't remember how I first established the Linux server is little endian but it certainly is from some of the other conversion work I've had to do. If there's a quick check you want me to run to prove it then please let me know. It's running Red Hat on Intel if that helps.

@mqjeff - can I just check you meant to ask about the getting program please? I'm not sure if you meant to ask about the putting program or if you're interested in how I got the message first.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jan 07, 2016 11:57 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

It's the responsibilty of the program reading a message to decide if it wants to receive data in it's local codepage/encoding or not.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
tczielke
PostPosted: Thu Jan 07, 2016 12:15 pm    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 941
Location: Illinois, USA

Linux on Intel (i.e. x86) would be little endian. I just wanted to make sure it wasn't big endian like Linux on SPARC.

The MQENC_NATIVE on Linux x86 is 546 or x222, so having the MQMD.Encoding field show as 546 should be correct.

One thing you could go do is go back to the way it was when you were getting the 2142 error and recreate it with a trace:

strmqtrc -m qmgr -t api -p mqput

It would be helpful to see the MQPUT from that trace that is being passed into the call. It would start with MQPUT >>.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jan 07, 2016 12:25 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

tczielke wrote:
having the MQMD.Encoding field show as 546 should be correct.


The encoding is correct when it accurately describes the contents of numerical data in the message.

This can coincide with the default encoding of the platform running the app doing the PUT or of the queue manager being PUT to, but it is not in any way required to.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
tczielke
PostPosted: Thu Jan 07, 2016 1:35 pm    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 941
Location: Illinois, USA

True. Also, the 2142 is an error with a header in the message data. So if you wanted to look into this deeper with a trace, you would need to use a trace options like "-d all" to see the message data.

strmqtrc -m qmgr -t api -d all -p mqput
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
Pootle
PostPosted: Thu Jan 07, 2016 1:54 pm    Post subject: Reply with quote

Newbie

Joined: 18 Dec 2014
Posts: 7

To give you some more context, I am getting the message to file with an equivalent mqget utility. The MQGET contained therein specifies 546 encoding. I am then trying to put it back on with mqput.

The trace gave me the output below, which I've copied up to the header part of the message. What should I be looking for here?

MQPUT >>
Hconn:
0x0000: 06004001 |..@. |
Hobj:
0x0000: 02000000 |.... |
ObjHdl:2 ObjType:QUEUE ObjName:FROM_TANDEM_CORP ResObjName:FROM_TANDEM_CORP
Msgdesc:
0x0000: 4d442020 01000000 00000000 08000000 |MD ............|
0x0010: ffffffff 00000000 22020000 00000000 |........".......|
0x0020: 4d514852 46000000 ffffffff 02000000 |MQHRF...........|
0x0030: 00000000 00000000 00000000 00000000 |................|
0x0040: === Skipping 16 Duplicate Lines === |................|
0x0140: 00000000 |.... |
Putmsgopts:
0x0000: 504d4f20 01000000 00000000 ffffffff |PMO ............|
0x0010: 00000000 00000000 00000000 00000000 |................|
0x0020: 00000000 00000000 00000000 00000000 |................|
0x0030: 00000000 00000000 00000000 00000000 |................|
0x0040: 00000000 00000000 00000000 00000000 |................|
0x0050: 00000000 00000000 00000000 00000000 |................|
0x0060: 00000000 00000000 00000000 00000000 |................|
0x0070: 00000000 00000000 00000000 00000000 |................|
Bufferlength:
0x0000: 7e010000 |~... |
Bufferaddress:
0x0000: 102079f0 067f0000 |. y..... |
Buffer:
0x0000: 52464820 00000001 00000053 00000000 |RFH .......S....|
0x0010: 000001b5 4d515354 52202020 00000000 |....MQSTR ....|
Back to top
View user's profile Send private message
tczielke
PostPosted: Thu Jan 07, 2016 2:01 pm    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 941
Location: Illinois, USA

The message that is in your buffer is big endian.

For example, the Version of the RFH header that is at offset 4 in your buffer is x'00000001' = 1 in big endian.

Notice that the version for your PMO at offset 4 is x'01000000', which is equal to 1 in little endian.

Does your mqput utility just read in a file and then PUT it?

Does you mqget utility do a GET with a convert?

Are you running the mqput and mqget both on the Linux server?
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
Pootle
PostPosted: Fri Jan 08, 2016 2:07 am    Post subject: Reply with quote

Newbie

Joined: 18 Dec 2014
Posts: 7

I think I'm there now thanks to you both. I'd wrongly assumed that the encoding of the message related directly to the OS. What I now hopefully understand correctly is that the OS has a default encoding, but as mqjeff says, "It's the responsibilty of the program reading a message to decide if it wants to receive data in it's local codepage/encoding or not".

So my application which puts the message in the first place uses 273 encoding. My mqget utility doesn't convert so encoding remains 273 (From the IBM website I got "If you specify the MQGMO_CONVERT option on the MQGET call, this field is an input/output field...In other cases, this is an output field for the MQGET call".

Finally the mqput utility reads the message which is in 273 encoding from a file so has to specify this encoding when performing the put.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jan 08, 2016 5:21 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

That looks reasonably correct.

Ideally what you do in this situation is change the getting program to convert. It's generally best practice/recommended practice.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
tczielke
PostPosted: Fri Jan 08, 2016 6:01 am    Post subject: Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 941
Location: Illinois, USA

I agree that doing a CONVERT on the GET would be preferred, in this case. That would follow the general practice of "receiver makes good", and would also make your program more portable and not have to be aware of hard coding any encoding fields in your put program.

This is a link that IBM provides for MQ Data Conversion -> http://www-01.ibm.com/support/docview.wss?uid=swg27005729&aid=1

It is also geared more towards procedural programming, like C.
_________________
Working with MQ since 2010.
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 » General IBM MQ Support » Why do I have to set mqmd encoding = 273 before Linux MQPUT?
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.