Discussion:
Using Microsoft Message Queues (MSMQ) with LabVIEW
(too old to reply)
P.C. Lindsey
2007-06-01 00:40:06 UTC
Permalink
I want to use the Microsoft Message Queue to communicate between applications on different machines. Does anybody have experience in using the MSMQ with Labview (in the .NET framework)? How do I send messages? The MessageQueue.Send method requires an object, and I don't know how to create this object format.
 
This question was asked several years ago on this forum and no answer was given.
 
I would appreciate any examples of Create a Queue, Delete a Queue,  Send a Message, and Read a Message in LabVIEW 7 or earlier.
 
Thanks,
P.C. Lindsey
2007-06-01 23:10:07 UTC
Permalink
Thanks for your suggestions.
Maybe I should state the problem differently: How do I get the desired Message into the Object that I input to the Send Method for MSMQ?
I've attached a simple VI that sends a message with nothing in it to Message Queue in "Computer Management." How do I get it to send a message.
Thanks,
 


MSMQ.vi:
http://forums.ni.com/attachments/ni/170/250813/1/MSMQ.vi
Coal Man
2007-06-04 14:10:10 UTC
Permalink
P.C.,
 
In order to send a Message in the MessageQueue that you have just created, you will need to use another constructor node and create a Message object.  You can then use the property and invoke nodes to change the values of that object and call the functions of that Message object.  You then only need to put this newly created Message object on your queue and you are good to go.
 
As a reference, you may want to check out the documentation on Microsoft's website about these particular objects.  It is located here:
 
<a href="http://www.microsoft.com/windowsserver2003/technologies/msmq/default.mspx" target="_blank">http://www.microsoft.com/windowsserver2003/technologies/msmq/default.mspx</a>
&nbsp;
I hope this helps.
P.C. Lindsey
2007-06-04 17:10:08 UTC
Permalink
Brian:
Thanks for your help! I'm making progress in getting the information I need to get Microsoft Message Queues to work&nbsp;with LabVIEW.
I seem to be missing only one thing: There is an object&nbsp;called Body that is used to input and output messages in Message. It is wired to the Message property Body.&nbsp;It seems to be called using an invoke node. Do you know where that is found and called?
Thanks,
&nbsp;
&nbsp;
&nbsp;
P.C. Lindsey
2007-06-04 18:10:16 UTC
Permalink
Brian:
I'm trying to construct something like the attached diagram, but I can't figure out how to find the class and method for the invoke node named&nbsp;Object in this diagram.
Thanks,
P.C.
&nbsp;


Receive and dispose.JPG:
http://forums.ni.com/attachments/ni/170/251088/1/Receive and dispose.JPG
Coal Man
2007-06-04 19:10:11 UTC
Permalink
P.C.
&nbsp;
I'm a little confused by what you mean.&nbsp; I thought you were sending messages through the MSMQ, but the code there would receive a message, get the body, then display the body of the message.&nbsp; The Object that the invoke node refers to is the Body of the Message, which has no properties, but has a few methods like ToString that you can use to get the string from the Body.&nbsp;
&nbsp;
You need to wire up the references into the invoke and property nodes to get the selection of the methods or properties that are available.&nbsp; Do they just not appear when you are using the invoke node with a reference to the body?Message Edited by Coal Man on 06-04-2007 01:56 PM


msmq.Jpg:
Loading Image...
P.C. Lindsey
2007-06-04 21:40:11 UTC
Permalink
Brian:
When I place an invoke node on the diagram and connect a wire from the Message property node with the "Body" property, the invoke node shows not methods, no title (Object), and the VI indicates that an error of the incorrect class or method is applied to the invoke node.
P.C.
&nbsp;
Coal Man
2007-06-04 22:10:07 UTC
Permalink
P.C.&nbsp;
&nbsp;
I'm not sure why it would be giving you that error.&nbsp; What versioin of MSMQ do you have?&nbsp; I have attached a VI that I got the screenshot from.&nbsp; Are you able to open it and see the same error?
&nbsp;
&nbsp;


MSMQ[1].vi:
http://forums.ni.com/attachments/ni/170/251164/1/MSMQ[1].vi
Coal Man
2007-06-05 16:40:10 UTC
Permalink
P.C.
&nbsp;
It sounds like you have the .NET 2.0 framework installed.&nbsp; Unfortunately, as some people have discovered, LabVIEW 7 is not compatible with .NET 2.0. This has to do with the fact that Microsoft has completely redesigned the way the framework is installed (specifically the GAC) and this has broken the code that provides you with the list of installed assemblies.&nbsp; This would be the reason that you can't see any of the property nodes or invoke nodes for that particular class.&nbsp;The workaround for this problem is to not install .NET 2.0 or use a newer version of LabVIEW, such as 8.2.1.&nbsp; Even if you have not manually installed .NET 2.0, it has probably been installed on the system as part of another application that requires the .NET 2.0 framework.
&nbsp;
P.C. Lindsey
2007-09-28 22:10:09 UTC
Permalink
I have installed LabVIEW 8.5 and NI-DAQmax 8.6 on my computer. I am usingWindows XP.&nbsp;I have both .Net 1.1&nbsp;and .Net 2.0.I am attaching the send and receive VIs that I am using. When I run thesend VI, I can see that I have successfully put a message in the Message Queue.However, when I try to read from the Message Queue, I get the error messagethat I have attached.
Has anyone seen this problem and knows a solution?
Thanks,


Error Message from MSMQ Receive.JPG:
http://forums.ni.com/attachments/ni/170/274944/1/Error Message from MSMQ Receive.JPG


MSMQ Send.vi:
http://forums.ni.com/attachments/ni/170/274944/2/MSMQ Send.vi


MSMQ Receive.vi:
http://forums.ni.com/attachments/ni/170/274944/3/MSMQ Receive.vi
jason_w
2007-10-01 20:10:07 UTC
Permalink
P.C.,
&nbsp;
Here are a few things I have found&nbsp;that cause&nbsp;this error code.&nbsp; I would verify that you have this identical structure.
&nbsp;

From a KnowledgeBase I found to resolve this error,&nbsp;try the following:


- Make sure you saved the VI in the same directory as the .NET assembly.
- Add the .NET assembly as a reference to LabVIEW

In LabVIEW 8.5 however the second half of this is inherent in the creation.&nbsp; Let me know if you have tried this and are still experiencing problems.
Jason Whaylen
Applications Engineer - National Instruments
P.C. Lindsey
2007-10-01 21:40:11 UTC
Permalink
Jason:
Thanks for your response.
&nbsp;I have moved the entire Microsoft .NET folder into the LabVIEW 8.5 folder. I have also moved both the .NET 1.1 and the .NET 2.0 folders into the LabVIEW 8.5 folder.
&nbsp;I have&nbsp;written a configuration file to specify that I am using .NET 1.1 and a configuration file for .NET 2.0 and put each, in turn, in the LabVIEW 8.5 folder.
I can see the dialog box indicating that the DLLs are loading when I open the MSMQ Send and the MSMQ Receive VIs. I can successfully send a message to Message Queue. The problem occurs in the MSMQ Receive VI when the data flow reaches the property node "Message" with the property "Body". I&nbsp;get the error message when this property node starts to run. If I check back in Computer Management, I see that the message has been removed from the Message Queue before the data flow enters this property node. This would suggest to me that the problem is not in addressing Message Queue, but in finding a way to get the message from the Message Queue format to a string that my program can use.
Can you run the two VIs that I attached to my last posting on your computer to see if&nbsp;they work there?
Do you have any other ideas I can try?
Thanks,
&nbsp;
&nbsp;
Jonathan N
2007-10-02 13:40:11 UTC
Permalink
HI P.C.
Lindsey,
&nbsp;
I just saw this post and thought I might chime in here.
&nbsp;
First off, you don?t need to move those folders you mentioned into the LabVIEW
8.5 folder. I am not sure which KnowledgeBase Jason was referring to, but the
requirement for placing your .NET assemblies in the same folder as your
top-level VI is no longer valid in LabVIEW 8.0 and later.&nbsp; This was a
requirement for LabVIEW 7.x because we created an AppDomain for each top-level VI. In LabVIEW
8.0 and later, we create separate AppDomains for LabVIEW projects and thus it?s
recommended that any VI that uses .NET assemblies be part of a LabVIEW
project.&nbsp; Additionally, you will want to put any private .NET assemblies
you are using in the LabVIEW project directory or any of its subdirectories. As
a side note, we also store the relative path to the .NET assemblies (for
non-GAC assemblies) inside the VI so we do attempt to locate the assembly that
way as well if needed.
&nbsp;
Now in your case, you don?t have to worry about placing .NET assemblies in the
project directory because you are referencing assemblies that live in the GAC.
&nbsp;
To address your real question, by default when an instance of the MessageQueue is created, an instance of XmlMessageFormatter is created for you and it is
associated with the MessageQueue. By default, the XmlMessageFormater instance
can be used to write to the queue, but it cannot be used to read from the queue
until you set the TargetTypeNames property on the formatter. To do this, I created
a new instance of the formatter and set that value automatically by passing
them as arguments to the constructor.

Basically, the C# code that you will be doing would be something like:

&nbsp;myQueue.Formatter
= new XmlMessageFormatter(new Type[] {typeof(String)});

I have attached an image that shows how to do this in LabVIEW. I tested the VIs
out with my new addition and it worked fine.

Best Regards,


Formatter.jpg:
Loading Image...
P.C. Lindsey
2007-10-02 18:40:07 UTC
Permalink
Jonathan:
Thanks for your suggestions.
Can you either tell me where to find the Invoke Node "Type" or attach a copy of your VI to your reply rather than the image of the VI.
Thanks,
&nbsp;
&nbsp;
Jonathan N
2007-10-02 19:10:09 UTC
Permalink
Hi P.C.
Lindsey,The GetType method I am using is a static method associated with System.Type class. It is found in the mscorlib assembly under the System namespace. I have attached the updated MSMQ Receive.vi.Best Regards,


MSMQ Receive.vi:
http://forums.ni.com/attachments/ni/170/275639/1/MSMQ Receive.vi

Loading...