Ummm, there's a lot of other stuff around the code that I have (which was in a VB.DLL used within ASP pages), but I tried to pull out the working code that would get to the essence of what you need. Essentially, this code opens a queue, creates a message on the queue, sets the body of the message, then sends the message. We developed another module which gets back the Id from the message sent so we use that to track the status of the send. Not sure if it works, but it's pretty close ... maybe I left something off, but this is code that has been working for the last several years ... having generated hundreds of thousands of messages. If you have any questions, or want some ideas on some more complicated stuff we put around it for sending and checking results, let me know at henry @ dcbiking . com
>> Henry
Dim oDOM As MSXML2.DOMDocument 'Holds XML to be sent
Dim oQueueInfo As MSMQ.MSMQQueueInfo 'Used to return the queue info for formatting message props.
Dim oQueue As MSMQ.MSMQQueue 'Queue
Dim oMsg As MSMQ.MSMQMessage 'Message to be placed on queue
Set oQueueInfo = CreateObject("MSMQ.MSMQQueueInfo")
oQueueInfo.Pathname = "MACHINENAME\PATHNAMEBLAHBLAH"
Set oQueue = oQueueInfo.Open(MSMQ.MQ_SEND_ACCESS, MSMQ.MQ_DENY_NONE)
Set oDOM = Server.CreateObject("MSXML2.DOMDocument")
oDOM.loadXML = "<call><sendTo>user@user.com</sendTo><method>Sum</method><parms><parm>1</parm><parm>2</parm></parms></call>"
' Create message
If oQueue.IsOpen Then
Set oMsg = CreateObject("MSMQ.MSMQMessage")
oMsg.Body = oDOM.xml
Else
Err.Raise 203, "sendRequest", "MSMQ queue could not be opened to send the message."
End If
' Send message
'Message sending will accommodate both transactional and non-transactional queues.
'If the queue is transactional, send the message with the single message option.
'If the queue is not transactional, send the message as non-transactional.
If oQueueInfo.IsTransactional Then
oMsg.Send oQueue, MQ_SINGLE_MESSAGE
Else
oMsg.Send oQueue, MQ_NO_TRANSACTION
End If
'Close queue; Null all objects
oQueue.Close
Set oMsg = Nothing
Set oQueue = Nothing
Set oQueueInfo = Nothing
Set oDOM = Nothing