Discussion:
MSMQ code works under XP, fails under Server 2003
(too old to reply)
"Trey Carroll"
2009-05-14 03:25:52 UTC
Permalink
Hello all,

I have a problem that is giving me fits. I have created an
application that uses MSMQ and a private queue. An ASP.NET
application sends xml to the queue and a windows services takes them
out and processes them. This all works beautifully on my XP
development box. Last Friday I started working on deploying this app
to its new home on a production Widows Sever 2003 sp1 box. I don't
think I have ever been so frustrated in my entire career. The send
statements throw no exceptions, but nothing ever shows up in the
queue.

I used a private queue in order to keep things simple. The 2003 box
is part of an Active Directory domain but I don't think this plays
into it since we're not using a public queue.

Here is the command line app that I coded up to test just the send:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Messaging;
using System.IO;

class Debug
{
public const string QUEUE_PATH = @".\private$
\AtHocSDKRequestQueue";
public const bool LOGGING_MODE_ENABLED = true;
public const bool DEBUGGING_MODE_ENABLED = true;
public const string QUEUE_TRANSACTION_LOG = @"c:\codemaroon\logs
\dbgQueueTransLog.txt";
public const string QUEUE_ERR_LOG_FILE = @"c:\codemaroon\logs
\dbgQueueErrLog.txt";


public static void Main()
{
//get the messageQueue inst. var. ready for use
MessageQueue messageQueue;
if (MessageQueue.Exists(QUEUE_PATH))
messageQueue = new MessageQueue(QUEUE_PATH);
else
messageQueue = MessageQueue.Create(QUEUE_PATH, true);

MessageQueueTransaction mqTrans = new MessageQueueTransaction
();

string strXml = "<tamu><test><comment value='Marlin is the
coolest'/></test></tamu>";

mqTrans.Begin();
try
{
messageQueue.Send(new Message(strXml, new
XmlMessageFormatter()));
mqTrans.Commit();
if (LOGGING_MODE_ENABLED)
{
TextWriter tw = File.AppendText
(QUEUE_TRANSACTION_LOG);
tw.WriteLine();
tw.Close();
}
}
catch (Exception ex)
{
if (DEBUGGING_MODE_ENABLED)
{
TextWriter tw = File.AppendText(QUEUE_ERR_LOG_FILE);
tw.WriteLine(ex.Message + ex.StackTrace +
ex.StackTrace + ex.ToString());
tw.Close();
}
mqTrans.Abort();
}
finally
{
messageQueue.Close();

}

}
}

After this executes the queue is empty and so is the log.

Any help that you can offer would be appreciated at a level that
transcends words. All I can think is that there is some freakish
setting having to do with the setup of the box that is causing these
problems. (It is a virtual server set up through virtuozzzo.)
After 3 solid days of reading, googling and tinkering I am at a
complete loss.
Trey Carroll
2009-05-14 15:52:12 UTC
Permalink
Post by "Trey Carroll"
Hello all,
I have a problem that is giving me fits.  I have created an
application that uses MSMQ and a private queue.   An ASP.NET
application sends xml to the queue and a windows services takes them
out and processes them.  This all works beautifully on my XP
development box.   Last Friday I started working on deploying this app
to its new home on a production Widows Sever 2003 sp1 box.   I don't
think I have ever been so frustrated in my entire career.  The send
statements throw no exceptions, but nothing ever shows up in the
queue.
I used a private queue in order to keep things simple.  The 2003 box
is part of an Active Directory domain but I don't think this plays
into it since we're not using a public queue.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Messaging;
using System.IO;
class Debug
{
\AtHocSDKRequestQueue";
    public const bool LOGGING_MODE_ENABLED = true;
    public const bool DEBUGGING_MODE_ENABLED = true;
\dbgQueueTransLog.txt";
\dbgQueueErrLog.txt";
    public static void Main()
    {
        //get the messageQueue inst. var. ready for use
        MessageQueue messageQueue;
        if (MessageQueue.Exists(QUEUE_PATH))
            messageQueue = new MessageQueue(QUEUE_PATH);
        else
            messageQueue = MessageQueue.Create(QUEUE_PATH, true);
        MessageQueueTransaction mqTrans = new MessageQueueTransaction
();
        string strXml = "<tamu><test><comment value='Marlin is the
coolest'/></test></tamu>";
        mqTrans.Begin();
        try
        {
            messageQueue.Send(new Message(strXml, new
XmlMessageFormatter()));
            mqTrans.Commit();
            if (LOGGING_MODE_ENABLED)
            {
                TextWriter tw = File.AppendText
(QUEUE_TRANSACTION_LOG);
                tw.WriteLine();
                tw.Close();
            }
        }
        catch (Exception ex)
        {
            if (DEBUGGING_MODE_ENABLED)
            {
                TextWriter tw = File.AppendText(QUEUE_ERR_LOG_FILE);
                tw.WriteLine(ex.Message + ex.StackTrace +
ex.StackTrace + ex.ToString());
                tw.Close();
            }
            mqTrans.Abort();
        }
        finally
        {
            messageQueue.Close();
        }
    }
}
After this executes the queue is empty and so is the log.
Any help that you can offer would be appreciated at a level that
transcends words.    All I can think is that there is some freakish
setting having to do with the setup of the box that is causing these
problems.   (It is a virtual server set up through virtuozzzo.)
After 3 solid days of reading, googling and tinkering I am at a
complete loss.
OK. Several things were at play here.

1. The server was out of memory which was causing it to behave
erratically.
2. The fact that this is a virtuozzo virtual server on SP1 means that
there is a problem when you set permissions which don't actually get
set.
3. For the above mentioned reasons I was not receiving my exceptions -
the error is actually a really obvious oversight! (Which I am shocked
nobody caught.) When using transactions you have to send a reference
to the MessageQueueTransaction object as the second parameter when
calling Send.
John Breakwell (MSFT)
2009-05-14 16:25:34 UTC
Permalink
Hi Trey,

Thanks for sharing.

Surprised you didn't see any Insufficient Resources (0xC00E0027) exceptions
bubbling up.

Unfortunately I'm not a coder so I missed that you were effectively sending
non-transactional messages to a transactional queue (which explains why they
disappeared).
Negative Source Journaling would help here by putting the rejected message
into the Dead Letter Queue with a class explaining what the problem was.
Assuming the lack of memory didn't get in the way, of course!

Note - SP1 is now retired (as of April 14th, 2009).
http://blogs.msdn.com/johnbreakwell/archive/2009/02/05/windows-2003-service-pack-1-approaching-end-of-support.aspx

Cheers
John Breakwell (MSFT)


"Trey Carroll" <***@gmail.com> wrote in message news:055a5a5c-2a7d-4bcb-923c-***@i28g2000prd.googlegroups.com...

OK. Several things were at play here.

1. The server was out of memory which was causing it to behave erratically.
2. The fact that this is a virtuozzo virtual server on SP1 means that there
is a problem when you set permissions which don't actually get set.
3. For the above mentioned reasons I was not receiving my exceptions - the
error is actually a really obvious oversight! (Which I am shocked nobody
caught.) When using transactions you have to send a reference to the
MessageQueueTransaction object as the second parameter when calling Send.
Loading...