To add a message to MSMQ I do:
def var msgQ as class System.Messaging.MessageQueue.
def var msg as class System.Messaging.Message.
def var msgActiveXFormatter as class System.Messaging.ActiveXMessageFormatter.
def var msgXMLFormatter as class System.Messaging.XmlMessageFormatter.
def var msgBinaryFormatter as class System.Messaging.BinaryMessageFormatter.
METHOD PUBLIC VOID SendMsg(input ipcLabel as char, input iplcMessage as longchar ):
msg = new Message().
if MsgFormat = 'Binary' then msg:Formatter = msgBinaryFormatter.
else if MsgFormat = 'ActiveX' then msg:Formatter = msgActiveXFormatter.
else msg:Formatter = msgXMLFormatter.
msg:Label = ipcLabel.
msg:Body = string(iplcMessage).
But to receive it, I am not able to get the Body. I do like this:
METHOD PUBLIC VOID ReceiveFromQueue( ):
def var lc as longchar no-undo.
msgQ = new msgMQ().
msgXMLFormatter = new System.Messaging.XmlMessageFormatter().
msg = new System.Messaging.Message().
msg:Formatter = msgXMLFormatter.
msg = msgQ:Receive().
I am able to see the label and the message I receive is removed from the queue.
I thought I could do
lc = msg:Body().
but no luck, I have tried
lc = msg:Body:ToString().
no luck, and many more.... How do I do it? If I use a COM object, I can get the message without any problems.
Best regards, Geir Otto.
Members of the OpenEdge development team may not have experience with this .NET facility. But hopefully members of the community have used this capability and can provide input.
Geir, where are you in Copenhagen?
Anyway, the way to get the message Body is the UNBOX function. The Body of the MSMQ Message is of type System.Object. UNBOX (oMessage:Box) will return you an ABL String, when the message actually contains an string.
On receive, you must set the message formatter for the message after the Receive() method returns.
working sample now available here:
Thanks Frank, I got it from Techsupport. All the examples I found with C# had it in front of the Receive() method, so I never tested it after. Now I know :-)