By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,931 Members | 2,015 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,931 IT Pros & Developers. It's quick & easy.

Using MSMQ on Windows (and Navision)

P: n/a
I'm investigating getting Microsoft Navision to do stuff from a Python
script. The recommended way seems to be to use message queues (MSMQ).
I can get Navision to send a message to itself fine. I found a couple
of code example in an ancient message in this newsgroup. The send.py
one I changed to the following:

from win32com.client import gencache
msmq = gencache.EnsureModule('{D7D6E071-DCCD-11D0-AA4B-0060970DEBAE}',
0, 1, 0)
qi = msmq.MSMQQueueInfo()
qi.PathName = ".\\testqueue"
try:
myq = qi.Open(msmq.constants.MQ_SEND_ACCESS,0)
except:
qi.Create()
myq = qi.Open(msmq.constants.MQ_SEND_ACCESS,0)

if myq.IsOpen:
msg = msmq.MSMQMessage()
msg.Priority = 3
msg.Body = "Hello World!"
msg.Label = "Navision MSMQ-BA"
print len(msg.Body)
print msg.BodyLength

msg.Send(myq)
myq.Close()

--------------------

And the read one all I changed was the queue name.

# read.py - reads from the queue

# following bit generated via "makepy -i" ...
# Use these commands in Python code to auto generate .py support
from win32com.client import gencache
msmq = gencache.EnsureModule('{D7D6E071-DCCD-11D0-AA4B-0060970DEBAE}',
0, 1, 0)

qi = msmq.MSMQQueueInfo()
qi.PathName = ".\PyQueueX"
myq = qi.Open(msmq.constants.MQ_RECEIVE_ACCESS,0)
if myq.IsOpen:
msg = myq.Receive()
print " body: %s" % msg.Body
print "label: %s" % msg.Label
myq.Close()

---------------------

They can send messages to each other fine.

The read.py can receive messages from Navision fine.

But messages sent to Navision (after changing the msg.Label to "Navision
MSMQ-BA") show up as empty messages (nothing in the body).

I can only see two differences between messages generated from Navision
and messages generated send.py.

1) Messages from Navision have something in the "Administration" bit
when you look at the message's properties in computer management (Format
name: PUBLIC=2bc802b2-7778-42c1-bc30-28caca20d974, Name:
it2-new\nsadminreceivequeue). Where as ones from send.py don't.

2) Every character in the body of messages sent from send.py has a 0
value character after them (ie in hex 48 00 65 00 6C 00 6C 00 6F 00 20
00 57 00 00 6F 00 72 00 6C 00 64 00 21 00)

Adding a print msg.BodyLength just before the msg.Send(myq) yields 24
for a 12 character message.

I'm assuming it is 2), coz it's just weird (unicode?).

Any ideas?
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.