Hello, everybody!
Does anyone have an experience of using MS-MQ messaging system under j#?
I have a trouble - I can't get message body, I always receive messages which
have bodylength==0. I'm using MS-MQ functionality which is accessible after
mqoa.dll reference addition. According MS description IMSMQQueue.Receive()
has four parameters, the third is so-called "WantBody", but I get messages
without bodies regardless of this parameter state. And moreover, I can get
messages with filled bodyes, which were sended by my j# example and were
retrieved by C++ client, not j#!
You can see my sources at http://magictale.com/download/MS_MQ-JS.zip
Thank you very much.
Dmitry
Lars-Inge T?nnessen [VJ# MVP] - 15 Dec 2004 22:11 GMT
> Does anyone have an experience of using MS-MQ messaging system under j#?
Yes, it's working very good.
> I have a trouble....
> You can see my sources at http://magictale.com/download/MS_MQ-JS.zip
Your link is not working.
Do you have any code we can take a look at. Please post a small sample of
what you are trying to do here in plain text.
Regards,
Lars-Inge T?nnessen
Pakhomenko Dmitry - 16 Dec 2004 04:42 GMT
> Yes, it's working very good.
I beleive in that
> Your link is not working.
It's strange. A lot of people can access my site. Anyway....
Please take a look a my code:
---cut---
public static boolean receiveMSMQMessage(String computerName, String
queueName)
{
if ((computerName == null) || (queueName == null)) return false;
try
{
IMSMQQueueInfo qinfo = (IMSMQQueueInfo) new MSMQQueueInfoClass();
String formatName = "DIRECT=OS:" + computerName + queueName;
qinfo.set_FormatName(formatName);
IMSMQQueue pQueue = qinfo.Open ( (int)MQACCESS.MQ_RECEIVE_ACCESS,
(int)MQSHARE.MQ_DENY_NONE );
IMSMQMessage pMsg = null;
for ( ; ;)
{
Variant vtMissing = null;
Object obMissing = (Object) vtMissing;
Variant vtTimeout = new Variant((long)(3));
Object obTimeout = (Object) vtTimeout;
Variant vtWantBody = new Variant((boolean)false);
Object obWantBody = (Object) vtWantBody;
//I don't understand what is happening here - the method always returns
messages with empty body regardless
//obWantBody variable state. But if you try to retrieve these sended
messages using C++ client for example,
//you will get non-empty body!!!
pMsg = pQueue.Receive(obMissing, obMissing, obWantBody, obTimeout);
//-----------------------------------------------------------------------------------------------------
if (pMsg == null)
{
System.out.println("No more messages, closing queue " + formatName);
pQueue.Close();
break;
}
System.out.println("Message was received successfully");
System.out.println("Message label == " + pMsg.get_Label());
System.out.println("Message body length == " + pMsg.get_BodyLength());
System.out.println("Message body == '" + pMsg.get_Body() + "'");
System.out.println("Message CorrelationId == '" +
sBytesToStr(pMsg.get_CorrelationId()) + "'");
System.out.println("Message senderIdType == '" + pMsg.get_SenderIdType()
+ "'");
System.out.println("Removed message from queue " + formatName + "\n");
}
return true;
}
catch (System.Runtime.InteropServices.COMException ex)
{
System.out.println(ex);
}
return false;
}
---cut---
Best wishes,
Dmitry Pakhomenko
Lars-Inge T?nnessen [VJ# MVP] - 16 Dec 2004 18:50 GMT
Please use the .net API. Here is one of my previous reply on using the MSMQ
with J#.
http://www.eggheadcafe.com/ng/microsoft.public.dotnet.vjsharp/post524418.asp
Regards,
Lars-Inge T?nnessen
David Browne - 16 Dec 2004 03:46 GMT
> Hello, everybody!
> Does anyone have an experience of using MS-MQ messaging system under
[quoted text clipped - 9 lines]
> retrieved by C++ client, not j#!
> You can see my sources at http://magictale.com/download/MS_MQ-JS.zip
Ahh, You are trying to use the MSMQ COM library.
Ditch that old thing and use the System.Messaging
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fsystemmessagingmessageclasstopic.asp
David
Pakhomenko Dmitry - 16 Dec 2004 06:42 GMT
> Ditch that old thing and use the System.Messaging
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemmessagingmessageclasstopic.asp
O-h....
There is one more path to access to MSMQ
Thank you very much, David.
Best wishes, Dmitry
Dmitry