Tags: alli, code, enumerates, message, messagequeueexception, net, public, queues, readhandle, remote, run, servers, sharp, snag, snippet, various

MessageQueueException in ReadHandle

On .Net » .Net C# (C sharp)

7,340 words with 1 Comments; publish: Mon, 31 Dec 2007 13:07:00 GMT; (10061.52, « »)

Hi All

I've got some code that enumerates the public message queues on various remote servers and I've run into a snag..

First, here's a code snippet that is mostly working

MessageQueue[] qList = MessageQueue.GetPublicQueuesByMachine( mName )

foreach(MessageQueue queueItem in qList

tr

queueItem.Formatter = new BinaryMessageFormatter()

queueItem.MessageReadPropertyFilter.SetAll()

MessageEnumerator myEnumerator = queueItem.GetMessageEnumerator()

while(myEnumerator.MoveNext()

tr

mMessageCount++

catch (Exception exp

MessageBox.Show( exp.Message, "Error Getting Message" )

catch (Exception exp

MessageBox.Show( exp.Message, "Error Getting Queue" )

MessageBox.Show( queueItem.Path + ":" + mMessageCount, "Message Count for Queue" )

OK. For most of the servers this works great... Except for 1. It's a newly installed Windows 2003 Server and the myEnumerator.MoveNext() call throws a MessageQueueException with no message text..

Well, I say that but the _message element says "External component has thrown an exception." and _stackTraceString shows

at System.Messaging.MQCacheableInfo.get_ReadHandle(

at System.Messaging.MessageEnumerator.get_CursorHandl e(

at System.Messaging.MessageEnumerator.MoveNext(TimeSp an timeout

at System.Messaging.MessageEnumerator.MoveNext(

at QueueMonitor.EnumerateQueues() in c:\projects\queuemonitor\queuemonitor.cs:line 5

So, I put in a breakpoint on the queueItem.Formatter line and hit Shift+F9 to QuickWatch queueItem... That's when I noticed

ReadHandle <error: an exception of type: {System.Messaging.MessageQueueException} occurred

I step through to after the myEnumerator construction and take a look at that

Handle

Current <error: an exception of type: {System.InvalidOperationException} occurred

CursorHandle <error: an exception of type: {System.Messaging.MessageQueueException} occurred

Seems I can't get the Handle for the Message Queue, which in turn means I can't get a Handle for the Enumerator... So I checked the security on the remote public queue I was enumerating and ( like everyone else on these NG's seems to do ) it was set to Everyone - Full Control... My machine and the remote machine both belong to the same Active Directory domain, and DNS is correctly setup for that to work... I believe..

Looking at the Exception instance I also see

_COMPlusExceptionCode -53245969

_HResult -214746725

MessageQueueErrorCode -214702307

Searching for 0x80070721 (-2147023071) seems to indicate it's a DCOM Automation error to do with security packages, so maybe there is something extra I need to do in 2K3 to allow me to enumerate the messages in the public queues..

Anyone have any thoughts, comments, ideas, suggestions or, preferably, solutions?

All Comments

Leave a comment...

  • 1 Comments
    • Hi Andrew,

      There seems to be some kind of authentication problem between your

      Windows2003 server and the domain controller. The problem occurs in the

      Active Directory access layer "under" MSMQ.

      I would check the following:

      1. Can you see the queues when running Active Directory Users and Computers

      from the Windows 2003 box?

      2. Does your program run as a service / ASP / COM+ component / Cluster

      resource orany other special security context?

      3. When you installed MSMQ, did it ask you for a DS server? (If it did, it

      cannot locate the Active Directory through DNS, and it uses the old MSMQ 1.0

      / 2.0 interface)

      4. Is your DNS configured right? (simple test: ping your DC using its short

      netbioos name, and see if ping says "pinging <netbios name>" or "pinging

      <full DNS name>. The former usually means that DNS is not configured right.

      HTH,

      Yoel

      --

      This posting is provided "AS IS" with no warranties, and confers no rights.

      "Andrew Hayes" <anonymous.net-csharp.todaysummary.com.discussions.microsoft.com> wrote in message

      news:6E3E14EB-CA46-4E2A-8FAC-962C5A7F7FD4.net-csharp.todaysummary.com.microsoft.com...

      > Hi All,

      > I've got some code that enumerates the public message queues on various

      remote servers and I've run into a snag...

      > First, here's a code snippet that is mostly working:

      > MessageQueue[] qList = MessageQueue.GetPublicQueuesByMachine( mName );

      > foreach(MessageQueue queueItem in qList)

      > {

      > try

      > {

      > queueItem.Formatter = new BinaryMessageFormatter();

      > queueItem.MessageReadPropertyFilter.SetAll();

      > MessageEnumerator myEnumerator = queueItem.GetMessageEnumerator();

      > while(myEnumerator.MoveNext())

      > {

      > try

      > {

      > mMessageCount++;

      > }

      > catch (Exception exp)

      > {

      > MessageBox.Show( exp.Message, "Error Getting Message" );

      > }

      > }

      > }

      > catch (Exception exp)

      > {

      > MessageBox.Show( exp.Message, "Error Getting Queue" );

      > }

      > MessageBox.Show( queueItem.Path + ":" + mMessageCount, "Message Count

      for Queue" );

      > }

      > OK. For most of the servers this works great... Except for 1. It's a newly

      installed Windows 2003 Server and the myEnumerator.MoveNext() call throws a

      MessageQueueException with no message text...

      > Well, I say that but the _message element says "External component has

      thrown an exception." and _stackTraceString shows:

      > at System.Messaging.MQCacheableInfo.get_ReadHandle()

      > at System.Messaging.MessageEnumerator.get_CursorHandl e()

      > at System.Messaging.MessageEnumerator.MoveNext(TimeSp an timeout)

      > at System.Messaging.MessageEnumerator.MoveNext()

      > at QueueMonitor.EnumerateQueues() in

      c:\projects\queuemonitor\queuemonitor.cs:line 59

      > So, I put in a breakpoint on the queueItem.Formatter line and hit Shift+F9

      to QuickWatch queueItem... That's when I noticed:

      > ReadHandle <error: an exception of type:

      {System.Messaging.MessageQueueException} occurred>

      > I step through to after the myEnumerator construction and take a look at

      that:

      > Handle 0

      > Current <error: an exception of type:

      {System.InvalidOperationException} occurred>

      > CursorHandle <error: an exception of type:

      {System.Messaging.MessageQueueException} occurred>

      > Seems I can't get the Handle for the Message Queue, which in turn means I

      can't get a Handle for the Enumerator... So I checked the security on the

      remote public queue I was enumerating and ( like everyone else on these NG's

      seems to do ) it was set to Everyone - Full Control... My machine and the

      remote machine both belong to the same Active Directory domain, and DNS is

      correctly setup for that to work... I believe...

      > Looking at the Exception instance I also see:

      > _COMPlusExceptionCode -532459699

      > _HResult -2147467259

      > MessageQueueErrorCode -2147023071

      > Searching for 0x80070721 (-2147023071) seems to indicate it's a DCOM

      Automation error to do with security packages, so maybe there is something

      extra I need to do in 2K3 to allow me to enumerate the messages in the

      public queues...

      > Anyone have any thoughts, comments, ideas, suggestions or, preferably,

      solutions?

      #1; Mon, 31 Dec 2007 13:08:00 GMT