473,385 Members | 1,863 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.

question about MessageQueue

question about MessageQueue

Hi, friends:

I try to send a message into MSMQ and then read it out.
But I find the message is not be removed after being accessed.
How can I read and remove it ?

Thanks

Charles Shao
================================================== ==============
myNewPrivateQueue1.Send("My message data.",
MessageQueueTransactionType.Single);
MessageEnumerator myEnumerator =
myNewPrivateQueue1.GetMessageEnumerator();

// Specify that the messages's priority should be read.
myNewPrivateQueue1.MessageReadPropertyFilter.Prior ity = true;

// Move to the next message and examine its priority.
while(myEnumerator.MoveNext())
{
// Increase the count if priority is Lowest.
if(myEnumerator.Current.Priority ==
MessagePriority.Lowest)

Console.WriteLine("Received MSG: " +
myEnumerator.Current.Body.ToString());
}

Nov 17 '05 #1
2 1427
Charles,

The MessageEnumerator provides a forward-only cursor to enumerate through
messages in a message queue. In other words, you can view them, but you
can't remove them. In order to remove them, you need to get a reference to
the queue the message is in.
In your case, if myNewPrivateQueue1 is that reference, you can simply call
the Receive method like this:

myNewPrivateQueue1.Receive();

Keep in mind that queues are just that, queues. They operate in a FIFO
(First-in first-out) manner. So when you call receive, you're essentially
getting the message that has been waiting the longest (and has the highest
priority as I understand it).

Hope this helps,

Dan Cox
DISCLAIMER: This *should* work. =)
"Charles Shao" <ad****@263.net> wrote in message
news:eu**************@TK2MSFTNGP12.phx.gbl...
question about MessageQueue

Hi, friends:

I try to send a message into MSMQ and then read it out.
But I find the message is not be removed after being accessed.
How can I read and remove it ?

Thanks

Charles Shao
================================================== ==============
myNewPrivateQueue1.Send("My message data.",
MessageQueueTransactionType.Single);
MessageEnumerator myEnumerator =
myNewPrivateQueue1.GetMessageEnumerator();

// Specify that the messages's priority should be read.
myNewPrivateQueue1.MessageReadPropertyFilter.Prior ity = true;

// Move to the next message and examine its priority.
while(myEnumerator.MoveNext())
{
// Increase the count if priority is Lowest.
if(myEnumerator.Current.Priority ==
MessagePriority.Lowest)

Console.WriteLine("Received MSG: " +
myEnumerator.Current.Body.ToString());
}

Nov 17 '05 #2
Thank you very much :-)
I will go to have a try

"CSharper" <do**@botherme.com> дÈëÓʼþ
news:8l********************@bignews4.bellsouth.net ...
Charles,

The MessageEnumerator provides a forward-only cursor to enumerate through
messages in a message queue. In other words, you can view them, but you
can't remove them. In order to remove them, you need to get a reference to
the queue the message is in.
In your case, if myNewPrivateQueue1 is that reference, you can simply call
the Receive method like this:

myNewPrivateQueue1.Receive();

Keep in mind that queues are just that, queues. They operate in a FIFO
(First-in first-out) manner. So when you call receive, you're essentially
getting the message that has been waiting the longest (and has the highest
priority as I understand it).

Hope this helps,

Dan Cox
DISCLAIMER: This *should* work. =)
"Charles Shao" <ad****@263.net> wrote in message
news:eu**************@TK2MSFTNGP12.phx.gbl...
question about MessageQueue

Hi, friends:

I try to send a message into MSMQ and then read it out.
But I find the message is not be removed after being accessed.
How can I read and remove it ?

Thanks

Charles Shao
================================================== ==============
myNewPrivateQueue1.Send("My message data.",
MessageQueueTransactionType.Single);
MessageEnumerator myEnumerator =
myNewPrivateQueue1.GetMessageEnumerator();

// Specify that the messages's priority should be read.
myNewPrivateQueue1.MessageReadPropertyFilter.Prior ity = true;

// Move to the next message and examine its priority.
while(myEnumerator.MoveNext())
{
// Increase the count if priority is Lowest.
if(myEnumerator.Current.Priority ==
MessagePriority.Lowest)

Console.WriteLine("Received MSG: " +
myEnumerator.Current.Body.ToString());
}


Nov 17 '05 #3

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

Similar topics

3
by: Gerhard Swart | last post by:
Hi all. I'm writing a queue browser that reads queues from a specified machine and then display the data that's on the queue. I am using the MessageQueue Class in .Net(C#). I get the problem...
1
by: Tony Hamill | last post by:
Hi, I am trying to create a C# application ( eventually a windows Service ) which will pick up the event when a message enters MSMQ. When this happens I want to log isome message details.This...
1
by: DalePres | last post by:
I am trying to create a custom HttpHandler that will load a page but keep the response object open while waiting for a message from a MessageQueue. In the ProcessRequest method I call: public...
5
by: felecha | last post by:
I have a VB.Net application that runs as a Windows Service and monitors a MessageQueue on another machine. At times that machine will have to be rebooted, so I've been working on how to get my...
2
by: felecha | last post by:
I'm stumped. I'm working on an application in VB.Net that uses System.Messaging.MessageQueue to listen for messages sent to a private queue on a remote machine. Both machines are in the same...
4
by: Risen | last post by:
Hi,All, I read MSDN about MessageQueue,and then I want to write some code to test MessageQueue in Vb.Net 2003. But there are some errors in code,and I don't know which code are incorrect. Who...
3
by: Claudia | last post by:
Hi all... I'm working on a project that uses MSMQ as its core for inter-process communication. At the moment there is a single process that listens for inbound TCP-based messages on a socket,...
5
by: Jason Richmeier | last post by:
I have been unable to locate an answer for this question because (1) it is late in the day and my eyes are tired of looking at code and documentation, (2) I am new to this area of the .NET...
0
by: chi.chung.ko | last post by:
Dear Pals local:Windows XP Sp2 server:Windows 2K3 Sever R2 When Use to Receive MessageQueue On Server System.Messaging.MessageQueue IQ = new MessageQueue(); IQ.Path =...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...

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.