473,856 Members | 1,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using 2 applications to talk through MSMQ

14 New Member

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.Formatt er 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
  2. namespace MSMQSender
  3. {
  4. public partial class Form1 : Form
  5. {
  6. private MessageQueue messageQueue1;
  8. public Form1()
  9. {
  10. try
  11. {
  12. InitializeComponent();
  14. string queuePath = "******\\private$\\test1";
  16. if (MessageQueue.Exists(queuePath))
  17. messageQueue1 = new MessageQueue(queuePath);
  18. else
  19. messageQueue1 = MessageQueue.Create(queuePath);
  21. // messageQueue1.Purge();
  22. messageQueue1.DenySharedReceive = false;
  23. }
  24. catch (Exception ex)
  25. {
  26. MessageBox.Show(ex.Message);
  27. }
  28. }
  30. /// Send button
  31. private void button1_Click(object sender, EventArgs e)
  32. {
  33. messageQueue1.Send(textBox1.Text); 
  34. }
  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();
  44. string myMessage = ConvertToString(message.Body);
  46. textBox2.Text = myMessage;
  47. }
  48. }
  49. catch (Exception ex)
  50. {
  51. MessageBox.Show(ex.Message);
  52. }
  53. }
  56. }
  57. }

what fixed the issue was adding this:

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

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

Similar topics

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 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 =...
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 support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
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 is: My application flies (when using the Message object to wrap my data in a non-transactional Q. When using MessageQueueTransaction in a transactional Q the memory usage (in task manager) keeps getting larger (as if GC never cleans up)
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 what I read I need to have my system setup on a domain, is this correct? For my dev work I'm not going to have that envirorment available and everything is tested on one laptop. Is there anything I can do? Thank you
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 using MySQL v 5 and PostgreSQL, but I have not worked with MS SQL. Playing with it after installing it, and running through several tutorials, I generally like what I see, but there are a few issues (so far - I am sure others will crop up as...
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 application does: 1. user provides input on a form on an aspx page and clicks continues 2. on postback, the page creates a c# .net object and calls a method on it to process the data provided by the user 3. the object in turns creates an...
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 which people can use to configure the server, edit their accounts, upload new data, etc. One way to implement this would be for the server to accept connections on a special port, and the ASP pages would connect to the server and talk over the...
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 worry about how many other apps are listening in, what they do with the messages, etc. Can I do this with Remoting? Cheers,
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 same server / or network. Also the WCF services hosted in IIS6 has to communicate with the WPF client apps that will be installed on computers that are not in the same network as the server/s. Right now I am creating small test apps so I can...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.