delard
2007-02-01 16:15:02 UTC
Hi,
We develop an application which has been using MSMQ for some time
successfully. However recently I’ve noticed some problems with messages
getting ‘lost’.
Originally I noticed this problem when some clients started losing about 70%
of all messages. This behaviour was very rare – and a reboot of the client
seemed to fix it. It could be that this behaviour was caused by a client
specific setup problem? However – more seriously - because of that issue I
started systematically testing MSMQ end-end connectivity from each client –
and this showed that very occasionally (maybe 1 in 1500) a message is getting
lost on all the clients!
When I say ‘lost’, I mean that the application calls the Send without any
errors – but there is no sign of the message on the source or destination
machines that I can see (though I’m far from an MQ expert).
The setup is a central Windows 2003 x64 server, with a variety of clients we
use for testing (note – all the clients seem to suffer from the ‘very
occasional loss’ problem) :
- clients running Windows server 2003 (32bit) in Workstation mode
- clients running XP Pro x64 in Domain mode
- clients running Windows XP Pro SP2, both 32bit and x64).in both Domain and
Workstation modes.
I’m using Visual Studio .NET 2003 to create the application – which is
running as a simple console app – written in C#. Its using the
System.Messaging MessageQueue class (.NET Framework 1.1). The queues are
setup as non-transactional, without journaling, and with full permissions for
‘Everyone’ and ‘Anonymous User’.
Here is a small test program which reproduces the problem. This just opens a
remote private queue, sends a message to it, then tries to receive that
message. It’s the only thing using that queue – but after a while (avg 1.5k
iterations) a message gets lost and it times out waiting to receive it. Note
– adding a pause between the send and receive doesn’t prevent this problem –
and I’ve left that out so it runs much faster.
using System;
using System.Threading;
using System.Messaging;
namespace TestMQ
{
class Class1
{
// Small test program to loop endlessly - sending a message via MSMQ and
testing it can be received
static void Main(string[] args)
{
int attemptcount = 0;
int failurecount = 0;
while(true)
{
Console.WriteLine("Starting attempt " + attemptcount++ + ". " +
failurecount + " problems so far...");
// Open the queue. Its a private queue on Windows 2003 x64 server
MessageQueue queue = new
MessageQueue(@"FormatName:DIRECT=OS:theserver\private$\heartbeatclientqueue");
queue.Formatter = new BinaryMessageFormatter();
queue.Purge(); // just in case there was anything already on queue...
// Create a message...
string messagebody = "TestMessageBody";
Message m = new Message(messagebody, new BinaryMessageFormatter());
m.Label = "TestMessageLabel";
// set some attributes on message... I've no idea if these make any
difference - I've set them in attempt to stop lost messages
m.Recoverable = true;
m.UseDeadLetterQueue = true;
m.UseAuthentication = false;
m.AcknowledgeType = AcknowledgeTypes.NotAcknowledgeReachQueue;
// send message - then close queue (google told me I had to do it!).
queue.Send(m);
queue.Close();
// Try to get the message back from the queue - give it 2 whole
minutes to be very generous!
Message received = null;
try
{
received = queue.Receive(TimeSpan.FromMinutes(2.0));
queue.Close();
}
catch (Exception e)
{
Console.WriteLine("Exception from MSMQ receive : " + e.Message);
}
if (received == null || (string)received.Body != messagebody)
Console.WriteLine("Message lost on attempt " + failurecount++);
}
}
}
}
I guess there must be something wrong with one of :
1) my MQ client setup. I installed the full MQ client options.
2) my MQ server setup or queue setup on the server
3) the code I’m using to use the queue – maybe I’m missing some flags etc?
4) the network – though everything else is fine here
Any advice on how to avoid this problem would be greatly appreciated.
Thanks - Delard
We develop an application which has been using MSMQ for some time
successfully. However recently I’ve noticed some problems with messages
getting ‘lost’.
Originally I noticed this problem when some clients started losing about 70%
of all messages. This behaviour was very rare – and a reboot of the client
seemed to fix it. It could be that this behaviour was caused by a client
specific setup problem? However – more seriously - because of that issue I
started systematically testing MSMQ end-end connectivity from each client –
and this showed that very occasionally (maybe 1 in 1500) a message is getting
lost on all the clients!
When I say ‘lost’, I mean that the application calls the Send without any
errors – but there is no sign of the message on the source or destination
machines that I can see (though I’m far from an MQ expert).
The setup is a central Windows 2003 x64 server, with a variety of clients we
use for testing (note – all the clients seem to suffer from the ‘very
occasional loss’ problem) :
- clients running Windows server 2003 (32bit) in Workstation mode
- clients running XP Pro x64 in Domain mode
- clients running Windows XP Pro SP2, both 32bit and x64).in both Domain and
Workstation modes.
I’m using Visual Studio .NET 2003 to create the application – which is
running as a simple console app – written in C#. Its using the
System.Messaging MessageQueue class (.NET Framework 1.1). The queues are
setup as non-transactional, without journaling, and with full permissions for
‘Everyone’ and ‘Anonymous User’.
Here is a small test program which reproduces the problem. This just opens a
remote private queue, sends a message to it, then tries to receive that
message. It’s the only thing using that queue – but after a while (avg 1.5k
iterations) a message gets lost and it times out waiting to receive it. Note
– adding a pause between the send and receive doesn’t prevent this problem –
and I’ve left that out so it runs much faster.
using System;
using System.Threading;
using System.Messaging;
namespace TestMQ
{
class Class1
{
// Small test program to loop endlessly - sending a message via MSMQ and
testing it can be received
static void Main(string[] args)
{
int attemptcount = 0;
int failurecount = 0;
while(true)
{
Console.WriteLine("Starting attempt " + attemptcount++ + ". " +
failurecount + " problems so far...");
// Open the queue. Its a private queue on Windows 2003 x64 server
MessageQueue queue = new
MessageQueue(@"FormatName:DIRECT=OS:theserver\private$\heartbeatclientqueue");
queue.Formatter = new BinaryMessageFormatter();
queue.Purge(); // just in case there was anything already on queue...
// Create a message...
string messagebody = "TestMessageBody";
Message m = new Message(messagebody, new BinaryMessageFormatter());
m.Label = "TestMessageLabel";
// set some attributes on message... I've no idea if these make any
difference - I've set them in attempt to stop lost messages
m.Recoverable = true;
m.UseDeadLetterQueue = true;
m.UseAuthentication = false;
m.AcknowledgeType = AcknowledgeTypes.NotAcknowledgeReachQueue;
// send message - then close queue (google told me I had to do it!).
queue.Send(m);
queue.Close();
// Try to get the message back from the queue - give it 2 whole
minutes to be very generous!
Message received = null;
try
{
received = queue.Receive(TimeSpan.FromMinutes(2.0));
queue.Close();
}
catch (Exception e)
{
Console.WriteLine("Exception from MSMQ receive : " + e.Message);
}
if (received == null || (string)received.Body != messagebody)
Console.WriteLine("Message lost on attempt " + failurecount++);
}
}
}
}
I guess there must be something wrong with one of :
1) my MQ client setup. I installed the full MQ client options.
2) my MQ server setup or queue setup on the server
3) the code I’m using to use the queue – maybe I’m missing some flags etc?
4) the network – though everything else is fine here
Any advice on how to avoid this problem would be greatly appreciated.
Thanks - Delard