Sending and Receiving messages to/from MSMQ directly from AB

Posted by dmci2309 on 19-Oct-2012 23:21

Just wondering if it is possible directly via ABL.

.NET library? Other?

I'm not looking for a SonicMQ/MSMQ bridge solution.

Thanks

David

All Replies

Posted by Admin on 20-Oct-2012 03:33

.NET library? Other?

 

Depends on your version of Progress...: http://msdn.microsoft.com/en-us/library/system.messaging.messagequeue(v=vs.90).aspx

USING System.Messaging.* .

DEFINE VARIABLE oQueue AS MessageQueue NO-UNDO .

EFINE VARIABLE oMessage AS System.Messaging.Message NO-UNDO .

oMessage = NEW System.Messaging.Message () .

oMessage:Body = BOX ("Hallo Welt") .

oMessage:Label = "Ich bin ein Berliner" .

oQueue = NEW MessageQueue () .

oQueue:Path = ".\Private$\MyNewQueueMF" .

oQueue:Send (oMessage) .

Posted by dmci2309 on 20-Oct-2012 20:04

Hi Mike,

Thanks for your response.

I have a basic sender and receiver working (after working out how to import .NET assemblies again, I even remembered to add the "from assembly" statement, as per this thread http://communities.progress.com/pcom/thread/49656 ).

Sender

USING System.Messaging.* FROM ASSEMBLY .

DEFINE VARIABLE oQueue   AS MessageQueue NO-UNDO .
DEFINE VARIABLE oMessage AS Message      NO-UNDO .
        
oMessage = NEW System.Messaging.Message () .
          
oMessage:Body = BOX ("Sarge") .
oMessage:Label = "Sarge" .
          
oQueue = NEW MessageQueue (".\Private$\SargeQueue") .

oQueue:Send (oMessage) .

Receiver

USING System.Messaging.* from assembly.

def var oQueue     as MessageQueue        no-undo.
def var oMessage   as Message             no-undo.

oMessage   = new Message().
oQueue     = new MessageQueue (".\Private$\SargeQueue").

do on error undo, leave:

    oMessage = oQueue:Receive ().
   
    message oMessage:label /* skip oMessage:body */ view-as alert-box title "Receiver".

    catch ioe as System.InvalidOperationException :
        message ioe:Message view-as alert-box.   
    end catch.

    catch mqe as MessageQueueException :
        message mqe:Message view-as alert-box. 
    end catch.

end.

However, I'm having trouble trying to retrieve the payload of the message (oMessage:body).

Reading up on this, it seems the default formatter is XML (XMLMessageFormatter).

Body of my message is therefore:

Sarge

I've tried *understanding* how to set the formatter to read my simple XML, but am not having much luck (I seriously need to work with OO).

Are you able to help? Is there a way to send the body as just a string?

Thanks

David

Posted by goo on 02-Nov-2015 17:06

Did you ever get this to work? I am struggeling whit the same. I am not able to get any body received.

This thread is closed