How To Create A New Msmq Message In Ironpython With Label, Reply Queue And Other Properties
I'm following this example here to use MS Message Queues with IronPython. The example works to create a message text string without any properties. import clr clr.AddReference('Sys
Solution 1:
I don't think that this works with IronPython classes, because serialize and deserialize them does not work like it does for c#/.net classes.
The only thing to get this work, will be to get IronPython classes serialize-able and deserialize-able. I think deserialization will be the hard part. But you may proof me wrong.
Solution 2:
I've started guessing the syntax by examining c# examples and have hacked a solution to the problem. The following code delivers a message with a user defined label and response queue and a body message.
import clr
from System import Array
from System import Byte
clr.AddReference('System.Messaging')
from System.Messaging import MessageQueue
from System.Messaging import Message
ourQueue = '.\\private$\python_in'
ourOutQueue = '.\\private$\python_out'ifnot MessageQueue.Exists(ourQueue):
queue = MessageQueue.Create(ourQueue)
else:
queue = MessageQueue(ourQueue)
ifnot MessageQueue.Exists(ourOutQueue):
out_queue = MessageQueue.Create(ourOutQueue)
else:
out_queue = MessageQueue(ourOutQueue)
mymessage = Message()
mymessage.Label = 'MyLabel'
mymessage.ResponseQueue = out_queue
mystring = 'hello world'
mybytearray = bytearray(mystring)
# this is very hacky
mymessage.BodyStream.Write(Array[Byte](mybytearray),0,len(mybytearray))
queue.Send(mymessage)
Post a Comment for "How To Create A New Msmq Message In Ironpython With Label, Reply Queue And Other Properties"