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 IndexGeneral IBM MQ SupportQuestion about conversion mq message.

Post new topicReply to topic
Question about conversion mq message. View previous topic :: View next topic
Author Message
gaorenwei
PostPosted: Wed Jan 09, 2019 10:40 pm Post subject: Question about conversion mq message. Reply with quote

Apprentice

Joined: 16 May 2018
Posts: 29

Hi guys.
I have try to use node.js to receive the websphere mq message on my client.Our message process is that MF platform is sender side. I know the encoding is "IBM500". The sender side will send the message to linux platform.
My side is window10. Currently,I will try to get message from linux platform.
This is my code.
style changed to quote for testing purposes
Quote:
// Import the MQ package
var mq = require('ibmmq');
var Parser = require("binary-parser").Parser;
var encoding = require("encoding");
var MQC = mq.MQC; // Want to refer to this export directly for simplicity

// Import any other packages needed
var StringDecoder = require('string_decoder').StringDecoder;
var decoder = new StringDecoder('utf8');

// The queue manager to be used.
var qMgr = "NSU2";
var hConn;

// The program starts here.
// Connect to the queue manager.
console.log("Sample AMQSCONN.JS start");

// Create default MQCNO structure
var cno = new mq.MQCNO();

// Add authentication via the MQCSP structure
var csp = new mq.MQCSP();

csp.UserId = "*****";
csp.Password = "*****";
// Make the MQCNO refer to the MQCSP

cno.SecurityParms = csp;

// And use the MQCD to programatically connect as a client
// First force the client mode
cno.Options |= MQC.MQCNO_CLIENT_BINDING;
// And then fill in relevant fields for the MQCD
var cd = new mq.MQCD();
cd.ConnectionName = "*********************";
cd.ChannelName = "NSU2.SVRCONN";
// Make the MQCNO refer to the MQCD
cno.ClientConn = cd;

var qName = "COV.MQ.L.WWD";

var ok = true;

// Now we can try to connect
mq.Connx(qMgr, cno, function(err,hConn) {
if (err) {
console.log(formatErr(err));
} else {
console.log('conn',hConn);
var od = new mq.MQOD();
od.ObjectName = qName;
od.ObjectType = MQC.MQOT_Q;
console.log('MQC.MQOT_Q',MQC.MQOT_Q);
var openOptions = MQC.MQOO_INPUT_AS_Q_DEF;
mq.Open(hConn,od,openOptions,function(err,hObj) {
if (err) {
console.log('conn-err',err);
console.log(formatErr(err));
} else {
console.log("MQOPEN of %s successful",hObj);
// And loop getting messages until done.
// getMessages(hObj);
}
//cleanup(hConn,hObj);
})
}
});


// Define some functions that will be used from the main flow
function getMessages(hObj) {
while (ok) {
getMessage(hObj);
}
}

// This function retrieves messages from the queue without waiting.
function getMessage(hObj) {

var buf = Buffer.alloc(10240);

var mqmd = new mq.MQMD();
var gmo = new mq.MQGMO();

gmo.Options = MQC.MQGMO_NO_SYNCPOINT |
MQC.MQGMO_NO_WAIT |
MQC.MQGMO_FAIL_IF_QUIESCING;

mq.GetSync(hObj,mqmd,gmo,buf,function(err,len) {
if (err) {
console.log('get-err',err.mqrcstr);
console.log(err.MQ)
if (err.mqrc == MQC.MQRC_NO_MSG_AVAILABLE) {
console.log("no more messages");
} else {
console.log(formatErr(err));
}
// ok = false;
} else {
console.log("message <%s>", decoder.write(buf.slice(0,len)));
}
});
}

But I get the result from linux is like this.
message data deleted for testing purposes

How can I handle this problem.Can you give me some suggests?
Back to top
View user's profile Send private message
PaulClarke
PostPosted: Wed Jan 09, 2019 11:56 pm Post subject: Reply with quote

Guardian

Joined: 17 Nov 2005
Posts: 941
Location: New Zealand

I don't know whether your application message is well formed or the message descriptor is correct but at the very least I would expect you to use the MQGMO_CONVERT option,

Regards,
Paul.
_________________
Paul Clarke
MQGem Software
www.mqgem.com
Back to top
View user's profile Send private message Visit poster's website
gaorenwei
PostPosted: Thu Jan 10, 2019 12:23 am Post subject: Reply with quote

Apprentice

Joined: 16 May 2018
Posts: 29

When I add the MQGMO_CONVERT .I get the error message is MQRC_FORMAT_ERROR [2110]
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jan 10, 2019 5:15 am Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 25729
Location: Ohio, USA

gaorenwei wrote:
When I add the MQGMO_CONVERT .I get the error message is MQRC_FORMAT_ERROR [2110]


Ask whoever's sending the message what the format of the message is (or look in the MQMD if you've access to a tool). MQGMO_CONVERT only works if the message is text (MQFMT_STRING). If it's not set to that (the default is MQFMT_NONE) ask whoever's sending the message to change it.

If they say they can't because the message has embedded binary numbers (or they set it to MQFMT_STRING, you use MQFMT_CONVERT and part of the text is still hash) then you'll need to convert it by some other means.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
hughson
PostPosted: Thu Jan 10, 2019 2:12 pm Post subject: Reply with quote

Grand Master

Joined: 09 May 2013
Posts: 1141
Location: Bay of Plenty, New Zealand

gaorenwei wrote:
When I add the MQGMO_CONVERT .I get the error message is MQRC_FORMAT_ERROR [2110]

What is the format of your message?

In your initial post you supplied the printable character version of your message when you didn't convert it. I can see where the spaces are ('@' in ASCII is space in EBCDIC) but we might be able to help you more if you could show us the hex dump of the message.

For example, instead of getting it with your program, browse it with the amqsbcg sample which will dump it out in hex. Then we can see the format, and see whether the message is correctly in that format.

Vitor wrote:
Ask whoever's sending the message what the format of the message is (or look in the MQMD if you've access to a tool). MQGMO_CONVERT only works if the message is text (MQFMT_STRING). If it's not set to that (the default is MQFMT_NONE) ask whoever's sending the message to change it.

Not entirely true. MQGMO_CONVERT works with all the MQ supplied formats (of which MQFMT_STRING is only one), and will work with User defined formats IFF you create a data conversion exit.

As you can see, the key to all of this is what value is in the MQMD.Format field.

Cheers,
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
gaorenwei
PostPosted: Thu Jan 10, 2019 9:40 pm Post subject: Reply with quote

Apprentice

Joined: 16 May 2018
Posts: 29

Thanks for replying me.I try to check the data in linux without program.

When I command amqsget QMGR QLOCAL

MQGET ended with reason code 2110
message <▒▒▒@▒▒▒▒▒▒▒▒▒▒▒▒▒`▒▒`▒▒`▒▒K▒▒K▒▒K▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒@@▒▒▒▒▒▒▒▒▒@@@@@@@@@@@@@@@@@@@@@@@@@@▒▒▒▒▒▒▒▒▒▒@@@@@@@@@@@@@@@@@@@@@@@@@▒▒▒▒@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@▒▒▒▒▒▒▒▒▒▒▒▒▒@▒▒▒▒`▒▒`▒▒`▒▒K▒▒K▒▒K▒▒▒▒▒▒▒▒▒▒▒▒@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@▒▒▒@▒▒@▒▒▒▒▒▒k@▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒@▒@@▒▒▒▒▒▒@▒▒@▒▒▒▒▒▒▒▒@▒▒▒▒@@@@@@@@@@@@▒▒@▒▒▒▒▒k@▒▒▒▒▒▒▒@▒▒▒▒▒▒@@@@@@@@@@@▒▒▒▒▒@@▒▒▒▒▒@@@@@▒▒▒@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@▒▒▒@▒▒▒▒▒▒@@@@@@@@@@@@@@@@@@@@@@@@@▒@▒▒▒▒▒▒▒@▒▒▒▒@▒▒▒@@@@@@@@@@@@@@@@@▒▒▒▒▒▒▒▒▒▒▒@@@@@@@@@@@@@@@@@@@@@@@@▒▒@▒▒@@▒▒▒▒▒@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@>
no more messages

I think the reason is linux codingis not same as MF.So where can I set something??
Back to top
View user's profile Send private message
hughson
PostPosted: Thu Jan 10, 2019 11:35 pm Post subject: Reply with quote

Grand Master

Joined: 09 May 2013
Posts: 1141
Location: Bay of Plenty, New Zealand

Please use amqsbcg as requested so that we can see the HEX dump of the message not the printable characters. You have used amqsget,

amqsget and amqsbcg are two different samples. Can you please try again with the one I requested?

Cheers,
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
bruce2359
PostPosted: Fri Jan 11, 2019 4:14 am Post subject: Reply with quote

Poobah

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

gaorenwei wrote:
Thanks for replying me.I try to check the data in linux without program.

When I command amqsget QMGR QLOCAL

According to the Knowledge Center https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q024070_.htm
the basic syntax of the IBM-supplied browse sample programs is: amqsbcg qname qmgrname

gaorenwei wrote:
I think the reason is linux codingis not same as MF.So where can I set something??

Yes, MQ on z/OS zArchitecture hardware will use different CCISD (code-page) and different encoding (little- vs. big-endian) from MQ in Intel. It is the responsibility of the developer to ensure that fields in the MQMD (CCSID, ENCODING, FORMAT) are set appropriately for the consuming application and qmgr.

The amqsbcg (or amqsbcgc) browse utilities will display BOTH the MQMD and the application data in HEX.
_________________
There are two types of people in this world:
1) Those that can extrapolate from incomplete data
Back to top
View user's profile Send private message
gaorenwei
PostPosted: Sat Jan 12, 2019 7:47 pm Post subject: Reply with quote

Apprentice

Joined: 16 May 2018
Posts: 29

**** Message ****

length - 954 of 954 bytes

00000000: C8C4 D940 C4C9 E2E3 C8D6 D9E4 E2F2 F0F1 '...@............'
00000010: F860 F1F0 60F1 F260 F1F9 4BF3 F64B F1F7 '.`..`..`..K..K..'
00000020: 4BF0 F0F0 F0F0 F0F0 F0F0 F0F3 C4C9 E2E3 'K...............'
00000030: E2C8 C9D7 D640 40F8 F0F3 F1F0 F2F8 F5F6 '.....@@.........'
00000040: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000050: 4040 4040 4040 4040 4040 F0F0 F1F3 F7F2 '@@@@@@@@@@......'
00000060: F1F1 F1F2 4040 4040 4040 4040 4040 4040 '....@@@@@@@@@@@@'
00000070: 4040 4040 4040 4040 4040 4040 40C7 C6F0 '@@@@@@@@@@@@@...'
00000080: F340 4040 4040 4040 4040 4040 4040 4040 '.@@@@@@@@@@@@@@@'
00000090: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
000000A0: E2D3 F0F3 F0F0 F0F0 F0F1 D4F0 F540 F2F0 '.............@..'
000000B0: F1F8 60F1 F060 F1F2 60F1 F24B F0F0 4BF0 '..`..`..`..K..K.'
000000C0: F04B F0F0 F0F0 F0F0 F7F8 F1F7 F5E6 4040 '.K............@@'
000000D0: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
000000E0: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
000000F0: 4040 4040 4040 4040 4040 4040 40C9 C2D4 '@@@@@@@@@@@@@...'
00000100: 40C4 C540 D4C5 E7C9 C3D6 6B40 C3D6 D4C5 '@..@......k@....'
00000110: D9C3 C9C1 D3C9 E9C1 C3C9 D6D5 40E8 4040 '............@.@@'
00000120: C3C1 D4C9 D5D6 40C1 D340 C3C1 E2E3 C9D3 '......@..@......'
00000130: D3D6 40F2 F2F0 F040 4040 4040 4040 4040 '..@....@@@@@@@@@'
00000140: 4040 40C5 D340 E2C1 D3E3 D66B 40D1 C1D3 '@@@..@.....k@...'
00000150: C9E2 C3D6 40D4 C5E7 C9C3 D640 4040 4040 '....@......@@@@@'
00000160: 4040 4040 4040 D1C1 D3D4 E740 40F4 F5F6 '@@@@@@.....@@...'
00000170: F8F0 4040 4040 40F8 F9F5 4040 4040 4040 '..@@@@@...@@@@@@'
00000180: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000190: 4040 4040 4040 4040 4040 4040 40D1 D6C5 '@@@@@@@@@@@@@...'
000001A0: 40E3 C1E8 D3D6 D940 4040 4040 4040 4040 '@......@@@@@@@@@'
000001B0: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
000001C0: F140 C3C1 D4C5 D9D6 D540 C8C9 D3D3 40C3 '.@.......@....@.'
000001D0: C9D9 4040 4040 4040 4040 4040 4040 4040 '..@@@@@@@@@@@@@@'
000001E0: 4040 40C3 C8C1 E3E3 C1D5 D6D6 C7C1 4040 '@@@...........@@'
000001F0: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000200: 4040 4040 4040 E3D5 40E4 E240 40F3 F7F4 '@@@@@@..@..@@...'
00000210: F0F2 4040 4040 4040 4040 4040 4040 4040 '..@@@@@@@@@@@@@@'
00000220: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000230: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000240: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000250: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'

00000260: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000270: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000280: 4040 4040 4040 4040 4040 4040 0000 0000 '@@@@@@@@@@@@....'
00000290: 0622 0C40 4040 4040 4040 4040 4040 4040 '.".@@@@@@@@@@@@@'
000002A0: 4040 4040 40F1 F0F0 4040 F0F0 F1F3 F7F2 '@@@@@...@@......'
000002B0: F1F1 F1F2 4040 4040 4040 4040 4040 4040 '....@@@@@@@@@@@@'
000002C0: 4040 4040 4040 4040 4040 4040 40F7 F5E6 '@@@@@@@@@@@@@...'
000002D0: 4040 4040 4040 40E7 D7D3 4040 4040 4040 '@@@@@@@...@@@@@@'
000002E0: 40F7 F8F1 F8F9 F5C4 C9E2 D2F8 F9F9 E2E7 '@...............'
000002F0: F140 4040 4040 4040 F9F0 F0F9 4040 4040 '.@@@@@@@....@@@@'
00000300: 4040 4040 4040 40F0 F0F0 F0F0 F0F0 F0F1 '@@@@@@@.........'
00000310: 4040 4040 4040 F9F7 F0C7 C4C2 F0D6 C6D3 '@@@@@@..........'
00000320: D4F0 F040 4040 4040 4040 4040 4040 4040 '...@@@@@@@@@@@@@'
00000330: 4040 C140 40F7 F8F1 C5F6 F7F0 4040 4040 '@@.@@.......@@@@'
00000340: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000350: 4040 4040 4040 4040 4040 4040 4040 4040 '@@@@@@@@@@@@@@@@'
00000360: 4040 4040 4040 4040 4040 4040 4040 F2C7 '@@@@@@@@@@@@@@..'
00000370: 4040 4040 4040 4040 4040 4040 4040 0000 '@@@@@@@@@@@@@@..'
00000380: 0000 0622 0C40 4040 F0F0 F0F0 F0F0 F0F1 '...".@@@........'
00000390: F0F0 F0F0 F0F0 F0F0 F0F0 F0F0 F0F0 F0F0 '................'
000003A0: F9F7 F0C7 C4C2 F0D6 C6D3 D4F0 F040 4040 '.............@@@'
000003B0: F8F9 F9E2 E7F1 4040 4040 '......@@@@ '

****Message descriptor****

StrucId : 'MD ' Version : 2
Report : 0 MsgType : 8
Expiry : -1 Feedback : 0
Encoding : 785 CodedCharSetId : 500
Format : ' '
Priority : 5 Persistence : 1


This is my message when I use amqsbcg QL DSGR.About this issue. So first I should set some property in QMGR .Second I should set some CCSID in program?Is that right?
Back to top
View user's profile Send private message
PaulClarke
PostPosted: Sat Jan 12, 2019 9:04 pm Post subject: Reply with quote

Guardian

Joined: 17 Nov 2005
Posts: 941
Location: New Zealand

Well the fact that the MQMD Format field is blank is the reason why MQ is not converting the data. How can it ? You haven't told it what format the data is in. Assuming that the data is just character data - and at first glance it appears to be - then you just need to set the Format field to MQSTR (MQFMT_STRING) and try the conversion again,

Cheers,
Paul.
_________________
Paul Clarke
MQGem Software
www.mqgem.com
Back to top
View user's profile Send private message Visit poster's website
hughson
PostPosted: Sat Jan 12, 2019 9:16 pm Post subject: Reply with quote

Grand Master

Joined: 09 May 2013
Posts: 1141
Location: Bay of Plenty, New Zealand

gaorenwei wrote:
Format : ' '

About this issue. So first I should set some property in QMGR .Second I should set some CCSID in program?Is that right?

You need to get the application which is putting this message to fill in the MQMD.Format field as MQFMT_STRING. At the moment it is blank which means it is in binary and so no string conversion can happen.

Cheers,
Morag
_________________
Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
bruce2359
PostPosted: Sun Jan 13, 2019 6:39 am Post subject: Reply with quote

Poobah

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

gaorenwei wrote:

****Message descriptor****

StrucId : 'MD ' Version : 2
Report : 0 MsgType : 8
Expiry : -1 Feedback : 0
Encoding : 785 CodedCharSetId : 500
Format : ' '
Priority : 5 Persistence : 1


This is my message when I use amqsbcg QL DSGR.About this issue. So first I should set some property in QMGR .Second I should set some CCSID in program?Is that right?

Two participants in this: producer and consumer. Please be precise as to which application and which qmgr.

The producing application needs to be modified to fill in the FORMAT field BEFORE MQPUTting the message.

The FORMAT field "tells" the consuming app and consuming app qmgr about the contents of the application data - so that the application data can be coverted. Conversion needs to be requested either on the SENDER channel AND/OR in the consuming application.

Please read about the purpose of the MQMD here: https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.5.0/com.ibm.mq.ref.dev.doc/q097400_.htm
_________________
There are two types of people in this world:
1) Those that can extrapolate from incomplete data
Back to top
View user's profile Send private message
gaorenwei
PostPosted: Sun Jan 13, 2019 9:42 pm Post subject: Reply with quote

Apprentice

Joined: 16 May 2018
Posts: 29

Thanks a lot guys.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Mon Jan 14, 2019 12:15 pm Post subject: Re: Question about conversion mq message. Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1365

If a topic contains any posts with excessively long lines, that makes it more difficult to read them, let alone respond. To fix this, use the 'Edit' button in the upper right corner of each post to wrap or truncate the long lines. Also, use the 'Preview' button as needed, to preview posts, before submitting them.

gaorenwei wrote:
I know the encoding is "IBM500".
...
Code:
var decoder = new StringDecoder('utf8');

These don't match. The StringDecoder object here is expecting 'utf-8', not 'ibm500'.

As explained already, MQ can convert the message from 'ibm500' to 'utf8', as long as the sender correctly sets its MQMD CCSID and Format, to indicate what to convert from. But the receiver also needs to set its MQMD CCSID, to indicate what to convert to.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Mon Jan 14, 2019 1:32 pm Post subject: Re: Question about conversion mq message. Reply with quote

Poobah

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

rekarm01 wrote:
As explained already, MQ can convert the message from'ibm500' to 'utf8', as long as the sender correctly sets its MQMD CCSID and Format, to indicate what to convert from. But the receiver also needs to set its MQMD CCSID, to indicate what to convert to.

The usual practice is for the producing app to ensure that
the CCSID in the MQMD is that of the producing platform.
This allows for the consuming app to request MQGMQ_CONVERT,
which, if necessary, will drive the qmgr to convert the app data using the
code-pages of both producing platform and consuming platform.
_________________
There are two types of people in this world:
1) Those that can extrapolate from incomplete data
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexGeneral IBM MQ SupportQuestion about conversion mq message.
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.