473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

using 2 applications to talk through MSMQ

Hello,

I have a question about MSMQ as I'm new to using this system in the .NET framework.

Here is my following application that I run 2 instances of to test the ability to communicate through the MSMQ.

It's just a basic form with 2 textboxes, and 2 buttons, first textbox is to "send" or put on the queue (with a send button), second is to receive (take from the queue with a receive button).

My question is, why before I specified the message.Formatter did it not allow the apps to take and put on the queue, before I added the formatter I was receiving an error of "Cannot find a formatter capable of reading this message" IF and only if you tried for the first time to remove the message from the other application, not if within the same instance of the application you send and received, that worked with no problem.

And even stranger, after each application sent and received within itself (meaning sent something to the queue and received it back, but not receiving something the other instance of the application put on the queue) they could then read what was put on the queue by the other application.

Shouldn't the formatter be default for both? Why should I have to declare it?

Expand|Select|Wrap|Line Numbers
  1.  
  2. namespace MSMQSender
  3. {
  4. public partial class Form1 : Form
  5. {
  6. private MessageQueue messageQueue1;
  7.  
  8. public Form1()
  9. {
  10. try
  11. {
  12. InitializeComponent();
  13.  
  14. string queuePath = "******\\private$\\test1";
  15.  
  16. if (MessageQueue.Exists(queuePath))
  17. messageQueue1 = new MessageQueue(queuePath);
  18. else
  19. messageQueue1 = MessageQueue.Create(queuePath);
  20.  
  21. // messageQueue1.Purge();
  22. messageQueue1.DenySharedReceive = false;
  23. }
  24. catch (Exception ex)
  25. {
  26. MessageBox.Show(ex.Message);
  27. }
  28. }
  29.  
  30. /// Send button
  31. private void button1_Click(object sender, EventArgs e)
  32. {
  33. messageQueue1.Send(textBox1.Text); 
  34. }
  35.  
  36. /// Receive button
  37. private void button2_Click(object sender, EventArgs e)
  38. try
  39. {
  40. if (messageQueue1.Peek(TimeSpan.FromMilliseconds(100)) != null)
  41. {
  42. System.Messaging.Message message = messageQueue1.Receive();
  43.  
  44. string myMessage = ConvertToString(message.Body);
  45.  
  46. textBox2.Text = myMessage;
  47. }
  48. }
  49. catch (Exception ex)
  50. {
  51. MessageBox.Show(ex.Message);
  52. }
  53. }
  54.  
  55.  
  56. }
  57. }
  58.  

what fixed the issue was adding this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. message.Formatter = new System.Messaging.XmlMessageFormatter(new string[] { "System.String" });
  3.  
after the messageQueue1.Receive(); statement.
Jun 27 '08 #1
0 2100

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andrew Gordon | last post by:
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...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
2
by: Ash | last post by:
Hi, I'm working on an application that takes csv files then converts it to XML. It then write the XML to a msmq where another service is reading the queue and sends it to the DB. My question...
14
by: Webbee | last post by:
I have a service built that is trying to read messages from a private que. When this tries to happen I get this error.... A workgroup installation computer does not support the operation From...
1
by: Ted | last post by:
I managed to get it installed OK, along side MS Visual Studio 2005 (with which I received it). During the install, I made sure I installed everything. I have developed a number of applications...
1
by: Florence Tissot | last post by:
We are seeing some kind of resource leak in our performance lab running an ASP.NET (2.0) application that sends and receives messages from 2 public MSMQ queues. Here's a brief summary of what are...
3
by: jmcgrew | last post by:
I'm not very familiar with ASP.NET, so any pointers would be appreciated. I'm developing a C# program which will basically run in the background as a server. I want to have a web-based front end...
10
by: Andrew Ducker | last post by:
I have an application, and I'd like it to be able to generate "log" messages. Other applications can then attach to it and listen to these messages, but the main application shouldn't have to...
1
by: lmod | last post by:
I am developing an application using WPF and WCF. This app on the server side will need for WCF services hosted in IIS6 to communicate with WCF services that are hosted as Windows services on the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.