|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
  |
|
MQ receives message in special characters |
View previous topic :: View next topic |
Author |
Message
|
Hamsa |
Posted: Thu Dec 03, 2015 1:34 am Post subject: MQ receives message in special characters |
|
|
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 |
|
 |
smdavies99 |
Posted: Thu Dec 03, 2015 2:31 am Post subject: |
|
|
 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 |
|
 |
Hamsa |
Posted: Thu Dec 03, 2015 5:44 am Post subject: |
|
|
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 |
|
 |
tczielke |
Posted: Fri Dec 04, 2015 7:59 am Post subject: |
|
|
Guardian
Joined: 08 Jul 2010 Posts: 941 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 |
|
 |
fjb_saper |
Posted: Fri Dec 04, 2015 10:29 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 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 |
|
 |
|
|
  |
|
Page 1 of 1 |
|
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
|
|
|
|