473,507 Members | 11,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Monitoring a Messaging Queue

I am trying to use the Microsoft Messaging Queue for an application I am
writing. I am able to create, push and pull messages with this app. The
problem right now though is: my "pull / pop" of the messages is based upon a
click of a button by the user. What I would like to do is automate the
process in which when an item is entered in the queue: a process is called /
spawned to will handle the item. Or perhaps every couple seconds: check the
queue for items (get the count) and perform a loop until that count is 0.

I am unsure how to go about "automating" the pop / pull of hte messages.

Would anyone be able to give me some pointers or advice?

Thanks
Andy
Feb 9 '06 #1
1 2575
You never really automate the posting of a message, an action such as clicking the button or uploading a file nearly always fires the event / calls the code. Reading the queue, we've set up a windows service that creates an object containing the following code (note: I've removed / change certain bits have been removed to make it generic - but it should give you a good starting point). As the windows service starts ProcessMessageQueue on a separate thread, it carries on processing the queue until the flag is set to false (normally on shutting down the service).

public override void ProcessMessageQueue()
{
MyObject emptyObj = new MyObject()
while (flag) // Property of class, set to false by calling object to terminate processing queue
{
try
{
MyObject myObject;
myObject = (MyObject)GetMessage(emptyObj.GetType());
if (myObject != null)
ProcessMessage(myObject);
}
catch(Exception e)
{
LogError(e);
}
}
}

private object GetMessage(Type objectType)
{
MessageQueue msmqQueue;
if( MessageQueue.Exists( msgQueue))
msmqQueue = new MessageQueue( msgQueue);
else
msmqQueue = MessageQueue.Create( msgQueue);

msmqQueue.UseJournalQueue = true;

Type[] targetTypes = new Type[1];
targetTypes[0] = objectType;
msmqQueue.Formatter = new XmlMessageFormatter( targetTypes);

Message message;
try
{
message = msmqQueue.Receive(new TimeSpan(0,0,3));
return (object)message.Body;
}
catch (MessageQueueException e)
{
if (e.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout)
{
return null;
}
else
throw e;
}
}
"Andy" <An**@discussions.microsoft.com> wrote in message news:8E**********************************@microsof t.com...
I am trying to use the Microsoft Messaging Queue for an application I am
writing. I am able to create, push and pull messages with this app. The
problem right now though is: my "pull / pop" of the messages is based upon a
click of a button by the user. What I would like to do is automate the
process in which when an item is entered in the queue: a process is called /
spawned to will handle the item. Or perhaps every couple seconds: check the
queue for items (get the count) and perform a loop until that count is 0.

I am unsure how to go about "automating" the pop / pull of hte messages.

Would anyone be able to give me some pointers or advice?

Thanks
Andy

Feb 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2328
by: Sarah Wang | last post by:
Does python have JMS-like messaging service? (open-source preferred) or any kind of message queue server?
1
2862
by: Peter Ang | last post by:
I was wondering if the CPU is the bottleneck. Hence I used the Performance Monitor to look up some values. Here are the results. Counter Scale Average ...
2
7438
by: Tony Hamill | last post by:
Hi, I am trying to set up a VERY simple project to send message to MSMQ from ..Net using C#. When I run my code it throws an exception "An unhandled exception of type...
1
10822
by: Hai Nguyen | last post by:
Hello everyone I'm trying to use the namespace using System.Messaging. My Visual Studio.Net could not recognize this namespace. Should I have to install a plug in or what should I do to have this...
3
2775
by: Webbee | last post by:
What would be the recommended way to monitor a high traffic message queue? I need to import data from the que into another program via the other programs API. When a message is added to the que I...
7
5053
by: =?Utf-8?B?Q2FybG8gRm9saW5p?= | last post by:
Hi, I implemented asynchronous calls to a web resource (using HttpWebRequest) from asp.net 2.0. The request it's made asyncronously (I see that beginGetResponse returns immediately). The number...
5
2000
by: wink | last post by:
Hello, I'm getting my feet wet in Python and thought I'd try to see how well Python works for asynchronous messaging. I've been using asynchronous messaging for 5 years and find it advantageous...
1
1274
by: Craig Buchanan | last post by:
I am trying to develop a queue-monitoring agent. The queue will be either MSMQ or Amazon's SQS. The message will contain instructions on how a worker should process (could be lengthy) a file...
2
1696
by: mirin | last post by:
From my ASP.NET 2.0 web application running on a Windows 2003 server, I want to write a message to a WebSphere messaging queue running on a UNIX Solaris machine. I have the destination hostname,...
0
7221
marktang
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,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5619
agi2029
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,...
1
5039
isladogs
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...
0
4702
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
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 ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
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...

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.