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 Java / JMSMQ receives message in special characters

Post new topicReply to topic
MQ receives message in special characters View previous topic :: View next topic
Author Message
Hamsa
PostPosted: Thu Dec 03, 2015 1:34 am Post subject: MQ receives message in special characters Reply with quote

Newbie

Joined: 03 Dec 2015
Posts: 3

HI Team,

Kindly help..
I'm sending an .xls file content to MQ by creating object message using JMS style from .Net but at MQ the content is having some invalid headers and special chars.

Logic used to send
1. Read .xls file contents in byte array
2. Created objectmessage
3. Sending objectmessage to MQ from .Net application using JMS style

on doing so, after sending the message to MQ.. having invalid headers and special characters.

Thanks, Hamsa
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Dec 03, 2015 2:31 am Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

What problem character etc?
Care to give us a sample of what you get and what should be output?
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
Hamsa
PostPosted: Thu Dec 03, 2015 5:44 am Post subject: Reply with quote

Newbie

Joined: 03 Dec 2015
Posts: 3

//connection

//CreateQueue
destination = sessionWMQ.CreateQueue(destinationName);
destination.SetIntProperty(XMS.WMQ_Target_CLIENT,1);
destination.SetIntPropert(XMS.WMQ_Target_CLIENT,XMSC.WMQ_TARGET_DEST_WMQ)

//create object message
objmesg = sessionWMQ.CreateObjectMessage();

//createProducer

//Read the number of files
string[] files = Directory.GetFiles(@"c:\...some path");

foreach(string filename in files)
{
byte[] file = system.IO.File.ReadAllBytes(filename);
var filenamec = Path.GetFileName(filename);
var MSGID = new byte[124];
var filenames = system.Text.Encoding.UT8.GetBytes(filenamec);
System.Buffer.BlockCopy(filenames,0,MSGID,0,filenames.Length);

objmesg.JMSMessageID = filename;
objmesg.JMSPriority =9;
objmesg.JMSTimestamp = DateTime.Now.Ticks;
objmesg.JMSRedelivered = false;
objmesg.JMSDeliveryMode = IBM.XMS.DeliveryMode.Persistent;

objmesg.SetObjectProperty("JMS_IBM_Last_Msg_In_Group", true);
objmesg.SetobjectProperty("FILENAME", Sample.xls);
objmesg.object = file;
producer.send(objmesg);

}

Here after executing above code the file will be sent to MQ and
input file contains some data like ABCDEF

Output wil be in some headers and special chars
ÿÿÿÿK%PK!ª÷X¤z[Content_Types].xml ¢( ÌTÉjÃ0½úF×+I¡”'‡.Ç6ôkl‹Ø’ÐLÒäï;vJÈ‚i ½ØØÒ¼e†yƒÑª*£%4Î&¢wE6uÚØ<ŸÓ·Î£■”Õªt±£áíÍ`ºö■W[LDA䟤Ĵ■Jaì<X>É\¨ñgÈ¥Wé\å ûÝîƒL%°Ô¡C/©EIÑëŠo”ÌŒÑóæ^M•å}iRE,T.­> é¸,3)h—.*†ŽÑP
ªÊØÃŒaDl…<Ê Äv¤[W1W6°0‑ïØú
†úä´«mݏ#

ÑXzW{—«R~¹0Ÿ97Ïƒ´mMÓ¢¸RÆîtŸáo.£l^½+
©ý5À-uôÿ‰Žû?ÒA¼s ›çïGÒÀ\Òº¼²Û

Kindly help how I can overcome unwanted headers and special chars.
Thanks
Back to top
View user's profile Send private message
tczielke
PostPosted: Fri Dec 04, 2015 7:59 am Post subject: Reply with quote

Guardian

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

Is this line:

Code:

var filenames = system.Text.Encoding.UT8.GetBytes(filenamec);


mistyped, and should have been:

Code:

var filenames = system.Text.Encoding.UTF8.GetBytes(filenamec);


I would recommend looking into what is happening here. I am not a .Net programmer, but my guess is that an assumption is being made here on what codepage the file is in and then being used to convert the file contents to UTF-8. For example, that method might be assuming (since you are not explicitly stating it) that the file is UTF-16 encoded and then reading the bytes as if they were UTF-16 and converting them to UTF-8. If the file was not UTF-16 encoded, that would be a problem and could lead to scrambled data.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Dec 04, 2015 10:29 am Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Just a few crazy things:
Code:
objmesg.JMSMessageID = filename;

If we've said a hundred times it still does not seem to hit conciousness.
The message ID is NOT a String but a byte[24].
Typically JMS does not allow you to set the messageID.

Code:
objmesg.SetObjectProperty("JMS_IBM_Last_Msg_In_Group", true);

Not necessary if you are not explicitely doing grouping...

Code:
objmesg.SetobjectProperty("FILENAME", Sample.xls);

?? should that not be
Code:
objmesg.SetStringProperty("FILENAME", "Sample.xls");

Code:
objmesg.object = file;

you might want to use a variable with a different name to avoid confusion between the File class and the byte[] you are effectevely supplying here.

Finally as you are using message properties be ready to deal with an RFH2 at the receiving end or make sure that the GMO(Get Message Options) include properties in handle...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexIBM MQ Java / JMSMQ receives message in special characters
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.