MSMQ - Microsoft Message Queues?
-
techjunkie
- Addict

- Posts: 1126
- Joined: Wed Oct 15, 2003 12:40 am
- Location: Sweden
- Contact:
MSMQ - Microsoft Message Queues?
Have anyone tried to do an application in PB using MSMQ? or do I have to switch to Visual Studio (it's very easy in Visual C++ 2005).

(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
I recently need to write a service that would interact with other services using MSMQ, and using PureDispHelper I managed to make a very basic implementation of it. Here's a simplified example:
(you'll need the PureDispHelper lib, of course)
I hope you can find some use for this:)
(you'll need the PureDispHelper lib, of course)
Code: Select all
#MQ_RECEIVE_ACCESS = 1
#MQ_SEND_ACCESS = 2
#MQ_PEEK_ACCESS = 32
#MQ_DENY_NONE = 0
#MQ_DENY_RECEIVE_SHARE = 1
#MQ_NO_TRANSACTION = 0
#MQ_MTS_TRANSACTION = 1
#MQ_XA_TRANSACTION = 2
#MQ_SINGLE_MESSAGE = 3
#MQ_ERROR_QUEUE_NOT_EXIST = -1072824317
#MQMSG_ACKNOWLEDGMENT_FULL_REACH_QUEUE = 5
#MQMSG_ACKNOWLEDGMENT_FULL_RECEIVE = 14
#DEFAULT_MAX_TIME_TO_REACH_QUEUE = 20
qi = dhCreateObject("MSMQ.MSMQQueueInfo.1")
dhPutValue(qi, "PathName=%s", @".\private$\TestQueue")
;Send a message
dhGetValue("%o", @myq, qi, "Open(%d,%d)", #MQ_SEND_ACCESS, #MQ_DENY_NONE)
If myq
Debug "Opened private$\TestQueue for sending"
out_msg = dhCreateObject("MSMQ.MSMQMessage.1")
body.s = "Hello MSMQ!"
label.s = "TestMessage"
dhPutValue(out_msg, "Label=%s", @label)
dhPutValue(out_msg, "Body=%s", @body)
Debug " sending message 'TestMessage' with content='Hello MSMQ!'"
dhCallMethod(out_msg, "Send(%o)", myq)
dhReleaseObject(out_msg)
dhCallMethod(myq, "Close()")
Debug "Queue closed"
dhReleaseObject(myq)
EndIf
Debug ""
;Receive the message
dhGetValue("%o", @myq, qi, "Open(%d,%d)", #MQ_RECEIVE_ACCESS, #MQ_DENY_NONE)
If myq
Debug "Opened private$\TestQueue for receiving"
dhGetValue("%o", @in_msg, myq, "Receive()")
If msg
dhGetValue("%s", @message, in_msg, "Body")
Debug " Message received: '" + PeekS(message) + "'"
dhReleaseObject(in_msg)
EndIf
dhCallMethod(myq, "Close()")
Debug "Queue closed"
dhReleaseObject(myq)
EndIf
dhReleaseObject(qi)-
techjunkie
- Addict

- Posts: 1126
- Joined: Wed Oct 15, 2003 12:40 am
- Location: Sweden
- Contact:
