Author |
Message
|
riturajan |
Posted: Fri Oct 19, 2007 4:38 am Post subject: XMS - Binary messsage from Unix to Windows |
|
|
Newbie
Joined: 19 Oct 2007 Posts: 7
|
hi,
I am using the IBM .NET client libraries (XMS) to access a queue on a Unix box from Windows 2003. I can get and send text message fine.
But when i get a binary message - a pdf - looks like it is getting transformed. Is there a setting i can specify to not convert the message?
The target client is MQ and not JMS. am a newbie at this - so any help will be greatly appreciated.
thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 19, 2007 4:49 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Which XMS Message object are you using? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
riturajan |
Posted: Fri Oct 19, 2007 4:58 am Post subject: |
|
|
Newbie
Joined: 19 Oct 2007 Posts: 7
|
I get the message as IMessage. I have tried to cast it to IBytesMessage - but it throws an exception when I do that.
I have only been able to cast it to ITextMessage - but that can't be right for binary. works for the text messages that i am getting on the same queue.
MessageListener messageListener = new MessageListener(OnNewMessageCallback);
private void OnNewMessageCallback(IMessage message) {
ITextMessage tm = (ITextMessage)msg;
...
} |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 19, 2007 5:26 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You will need to be able to work with it as an IBytesMessage, I believe, in order to avoid having it run through Text conversion.
You may be having issues doing this because the person who wrote the message is setting MQMD.Format=MQFMT_STRING. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
riturajan |
Posted: Fri Oct 19, 2007 6:13 am Post subject: |
|
|
Newbie
Joined: 19 Oct 2007 Posts: 7
|
Any idea if there is an XMSC setting that i can use to make this work. Here is how the message is being written - in java
lQuoteOutput_ms : MemoryStream = New;
lQuoteOutput_ms.Open( accessMode = SP_AM_READ_WRITE, isBinary = TRUE );
lQuoteOutput_ms.WriteBinary( source = lQuoteOutput_bin );
lQuoteOutput_ms.Close( );
lMessage_ent : LR_MessageEnt = New;
lMessage_ent.SetMemoryStream( pMessage_ms = lQuoteOutput_ms );
return lMessage_ent;
Writing the message out to MQ
Persistence is set…
Lower level output to Queue LR_AssemblyLineMaster._WriteOutputToQueue
lQueue_ent : LR_QueueEnt;
lQueue_ent = _mQCacheOut_o.GetQEnt( pQName_str = pQueueName_str
, pInputMode_int = LR_MQOO_NOT_OPEN_FOR_INPUT
, pOutputMode_b = TRUE
, pBrowseMode_b = FALSE );
-- Put object on queue for Save
_mMQResourceMgr_o.PutMessageOnQ( pMessage_ent = pMsg_ent
, pQueue_ent = lQueue_ent
, pLUOW_b = TRUE
, pReplyToQName_td = NIL
, pReplyToQMgrName_td = NIL
, pMsgID_ent = lMQID_ent
, pCorrelationID_ent = lMQID_ent
, pUserID_td = lUserID_td
, pPersistence_c = lPersistMsg_c
, pSetIdentityContext_b = FALSE
, pMessagePriority_int = pMessagePriority_int ); |
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri Oct 19, 2007 12:16 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
I think Jeff's going down the correct path. Fix the problem on the sending side. What is the sending side putting on the MQMD's Format field? _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
riturajan |
Posted: Fri Oct 19, 2007 12:20 pm Post subject: |
|
|
Newbie
Joined: 19 Oct 2007 Posts: 7
|
i am checking with sender - but i don't have much control over that. Is there anything I can do at the receiving end to make this work?
thanks |
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri Oct 19, 2007 12:24 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
stop your consumer when they send a message and look at the MQMD yourself to see what they are setting in that field. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
riturajan |
Posted: Fri Oct 19, 2007 12:39 pm Post subject: |
|
|
Newbie
Joined: 19 Oct 2007 Posts: 7
|
In looking at the trace - CreateXMSMessage() : No mcd folder found. Not a real JMS message. Trying to create a suitable WmqMessage.
16:31:55.777081 2536.1980 IBM.XMS.WMQ.WmqMsg ----+ d CreateXMSMessage() : mcd folder does not exist. messageClass set to be 'text'.
Also
JMS_IBM_Format = MQSTR
Is this what you were referring to? can you please let me know how to look at MQMD?
thanks |
|
Back to top |
|
 |
PeterPotkay |
Posted: Fri Oct 19, 2007 12:57 pm Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
I haven't used XMS, but......
It looks like they ae saying this message is character data by setting the MQMD_FORMAT to a value that says its char data (MQSTR). But the payload is not.
It seems XMS sees that in the header and is converting the character data for you, except its not char data, hence the corruption.
They need to stop setting that value. Just cause you call a dog a duck does not mean it will quack! They should leave that field blank. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Oct 19, 2007 1:01 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
riturajan wrote: |
16:31:55.777081 2536.1980 IBM.XMS.WMQ.WmqMsg ----+ d CreateXMSMessage() : mcd folder does not exist. messageClass set to be 'text'.
Also
JMS_IBM_Format = MQSTR
Is this what you were referring to? can you please let me know how to look at MQMD?
thanks |
This is your problem: messageClass set to be 'text'
you need messageClass set to be 'byte'...
in XMS you should have something like
Session.createBytesMessage();
A Text message is not suitable to transfer binary data. Unless you want to double the size and do it in hex representation of a binary array....
A lot of additional work if you ask me...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
riturajan |
Posted: Fri Oct 19, 2007 2:07 pm Post subject: |
|
|
Newbie
Joined: 19 Oct 2007 Posts: 7
|
fjb_saper wrote: |
This is your problem: messageClass set to be 'text'
you need messageClass set to be 'byte'...
in XMS you should have something like
Session.createBytesMessage();
A Text message is not suitable to transfer binary data. Unless you want to double the size and do it in hex representation of a binary array....
A lot of additional work if you ask me...
Enjoy  |
I am the consumer - so i don't call createBytesMessage - i would like to be able to read the message as BytesMessage - but it is coming to me as text - can i convert it back or stop the conversion?
thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Oct 20, 2007 1:49 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
riturajan wrote: |
I am the consumer - so i don't call createBytesMessage - i would like to be able to read the message as BytesMessage - but it is coming to me as text - can i convert it back or stop the conversion?
thanks |
I am more familiar with JMS than XMS. However having a message of class TextMessage means that the get is automatically done with convert.
At the same time a number of extra controls for String manipulations could be embedded behind the scenes, so even though the right bytes may have been written to the message I would not guarantee the message's integrity as it has been declared as Text and not Bytes. (Truncation of bytestream and other things come to mind as text is being handled differently in different programming languages.)
You really need to request from the sender that he modify his message to send a byte message when sending a pdf...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
riturajan |
Posted: Tue Oct 23, 2007 8:46 pm Post subject: |
|
|
Newbie
Joined: 19 Oct 2007 Posts: 7
|
I was able to get this to work - by doing the following..
System.Text.Encoding oEncoder = System.Text.Encoding.GetEncoding("iso-8859-1");
byte[] bytesArr = oEncoder.GetBytes(tm.Text);
Converts it back into binary - which when written out forms a valid PDF document. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Oct 24, 2007 8:41 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
riturajan wrote: |
I was able to get this to work - by doing the following..
System.Text.Encoding oEncoder = System.Text.Encoding.GetEncoding("iso-8859-1");
byte[] bytesArr = oEncoder.GetBytes(tm.Text);
Converts it back into binary - which when written out forms a valid PDF document. |
I would view this as best as a temporary solution. You just need a few special characters to throw off your game...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|