Click here to Skip to main content
15,891,849 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionHelp regarding hosting/Development server? Pin
callousfantom17-Feb-10 0:05
callousfantom17-Feb-10 0:05 
AnswerRe: Help regarding hosting/Development server? Pin
Not Active17-Feb-10 0:26
mentorNot Active17-Feb-10 0:26 
AnswerRe: Help regarding hosting/Development server? Pin
Eddy Vluggen17-Feb-10 5:02
professionalEddy Vluggen17-Feb-10 5:02 
AnswerRe: Help regarding hosting/Development server? [modified] Pin
callousfantom17-Feb-10 18:00
callousfantom17-Feb-10 18:00 
QuestionJava in Visual Studio 2008 Team Suite? Pin
mauricemcse16-Feb-10 11:01
mauricemcse16-Feb-10 11:01 
AnswerRe: Java in Visual Studio 2008 Team Suite? Pin
Not Active16-Feb-10 12:21
mentorNot Active16-Feb-10 12:21 
AnswerRe: Java in Visual Studio 2008 Team Suite? Pin
Richard MacCutchan16-Feb-10 12:33
mveRichard MacCutchan16-Feb-10 12:33 
QuestionOne MSMQ Queue works but another one doesn't Pin
Hypermommy16-Feb-10 6:03
Hypermommy16-Feb-10 6:03 
Hi everyone,

I'm so confused right now I'm hardly sure where to begin. I've been tasked with writing an application using MSMQ. Basically, the app listens to a file folder, notices when a file's been added, sends a message to a router queue which then figures out what to do and sends a message to the appropriate processing queue. The router queue is receiving messages and it seems to be sending them on to the processing queue but the processing queue never receives the message. I've tried everything I can think of to get this working but cannot seem to do so and have no clue why not. No matter what I try, the processing queue never seems to receive the message that was sent to it.

Here's how the main program creates the router object (this is the one that works):

Private Sub StartRouter(ByVal myNode As XmlNode)
    Try
        m_RouterQueueName = myNode.Attributes("queuename").Value
        TheRouter = New Router(m_RouterQueueName)
        AddHandler TheRouter.onRouterStarted, AddressOf LogActivity
        AddHandler TheRouter.onRouterMessageReceived, AddressOf LogActivity
        AddHandler TheRouter.onRouterError, AddressOf LogError
    Catch ex As Exception
        LogError(ex)
    End Try

End Sub


And here's the constructor in the router object:

Public Sub New(ByVal QueueName As String)
       Try
           m_QueueName = QueueName
           StartListening()
       Catch ex As Exception
           RaiseEvent onRouterError(ex)
       End Try
   End Sub


You'll notice that it has a "start listening" routine. Here is that routine:

Private Sub StartListening()
    myReceiveQueue = New MessageQueue(m_QueueName, QueueAccessMode.SendAndReceive, False, QueueAccessMode.SendAndReceive)
    Try
        'myReceiveQueue = New MessageQueue()
        'myReceiveQueue.Path = m_QueueName
        myReceiveQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(System.String)})
        myReceiveQueue.UseJournalQueue = True
        RaiseEvent onRouterStarted("Router listening to " & m_QueueName, "Started")
        AddHandler myReceiveQueue.ReceiveCompleted, AddressOf MSMQ_ReceiveCompleted
        myResult = myReceiveQueue.BeginReceive()
    Catch ex As Exception
        RaiseEvent onRouterError(ex)
    End Try
End Sub



Now as to the processor (this is the part that's not working), here's how the calling program creates it:

Private Sub SpawnProcessors(ByVal myNode As XmlNode)
    Try
        For Each childnode As XmlNode In myNode
            Dim myNewProcessor As New Processor(childnode)
            AddHandler myNewProcessor.onProcessorStarted, AddressOf LogActivity
            AddHandler myNewProcessor.onProcessorError, AddressOf LogError
            AddHandler myNewProcessor.onProcessorMessageReceived, AddressOf LogActivity
            ProcessorCollection.Add(myNewProcessor)
        Next

        ' once we've been through all the processors and started them all, introduce this list to the router
        TheRouter.IntroduceProceduresToRouter(ProcessorCollection)
    Catch ex As Exception
        LogError(ex)
    End Try
End Sub


Since the router sends messages to the processors you'll see that I have a line in there that introduces the processes to the router. All this does is take the collection of processors and "copy" it to the router so the router can know what's going on (maybe the problem is in doing this???):

Public Sub IntroduceProceduresToRouter(ByVal myList As List(Of Processor))
     m_KnownProcesses = myList
 End Sub


The constructor for the processor object is like this:

Public Sub New(ByVal myNode As XmlNode)
    Try
        Config = myNode
        m_QueueName = myNode.Attributes("queuename").Value
        m_Type = myNode.Attributes("processtype").Value
        StartListening()

    Catch ex As Exception
        RaiseEvent onProcessorError(ex)
    End Try
End Sub


It also has a "start listening" subroutine associated which looks like this:

Private Sub StartListening()
    Try
        myProcQueue = New MessageQueue(m_QueueName, False, False, QueueAccessMode.SendAndReceive)
        myProcQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(System.String)})
        myProcQueue.UseJournalQueue = True
        RaiseEvent onProcessorStarted("Processor listening to " & m_QueueName, "Started")
        AddHandler myProcQueue.ReceiveCompleted, AddressOf MSMQ_ReceiveCompleted
        myResult = myProcQueue.BeginReceive()
    Catch ex As Exception
        RaiseEvent onProcessorError(ex)
    End Try
End Sub



Now when the router receives a message, it reads it from the queue like this:

Private Sub MSMQ_ReceiveCompleted(ByVal p_source As Object, ByVal p_objAsyncResult As ReceiveCompletedEventArgs)
     Try
         Dim myMessage As Message
         myMessage = myReceiveQueue.EndReceive(p_objAsyncResult.AsyncResult)
         RaiseEvent onRouterMessageReceived("Router", "New message Received in Router Queue" & Chr(13) & myMessage.ToString)
         RouteMessage(myMessage)
         myResult = myReceiveQueue.BeginReceive()
     Catch ex As Exception
         RaiseEvent onRouterError(ex)
     End Try
 End Sub


And it uses the RouteMessage function to send a call to the proper processor (right now there's just the one and until I can get it to accept messages there's no use to add any more). But here's the RouteMessage sub:

Private Sub RouteMessage(ByVal msgToProcess As Message)
      Try
          ' get the XML from the body of the message
          Dim xmlDoc As New Xml.XmlDocument
          xmldoc.LoadXml(msgToProcess.Body)
          Dim myNode As XmlNode
          myNode = xmlDoc.SelectSingleNode("descendant::process")

          ' read the first child to determine what the next process is
          Dim NextAction As String
          NextAction = myNode.ChildNodes(0).Attributes("type").Value

          For Each SingleProcess As Processor In m_KnownProcesses
              If NextAction = SingleProcess.Config.Attributes("processtype").Value Then
                  'Dim myQueue As New MessageQueue(SingleProcess.myProcQueue.Path)
                  '                    myQueue.Send(myNode.OuterXml)
                  SingleProcess.myProcQueue.Send("Test Message")
                  'myQueue.Send("Test Message")
                  'myQueue = Nothing
                  'SingleProcess.myProcQueue.Send(myNode.OuterXml)
                  Exit For
              End If
          Next
      Catch ex As Exception
          RaiseEvent onRouterError(ex)
      End Try
  End Sub


As you can see in my for loop I've tried several different things. But nothing's working. I'm not even getting the processor to recognize the simple text message that I sent. No errors are being thrown that I can see... it's just not doing anything. I put a breakpoint on the processor's MSMQ_ReceiveCompleted subroutine and it never ever gets hit.

I saw an article somewhere in my research today that helped me find where the MSMQ queuing properties control panel is and it says that the message files folder, message logging folder and transaction logging folder is all the same one -- C:\Windows\System32\msmq\storage. I looked in there and opened what I found in notepad but can't read any of it.

How can I tell if the processor queue is even receiving the message at all? I'm so lost.

I hope someone can please help me understand what I'm doing wrong. I'd greatly, greatly appreciate it.
Denise "Hypermommy" Duggan

QuestionUnable to print multiple copies for crystal report in vb.net. Pin
jgotlt15-Feb-10 0:06
jgotlt15-Feb-10 0:06 
QuestionHosting XNA in a windows forms control and in turn hosting that control in WPF Pin
Ekoj Lirpa13-Feb-10 8:23
Ekoj Lirpa13-Feb-10 8:23 
AnswerRe: Hosting XNA in a windows forms control and in turn hosting that control in WPF Pin
Hessam Jalali13-Feb-10 11:33
Hessam Jalali13-Feb-10 11:33 
GeneralRe: Hosting XNA in a windows forms control and in turn hosting that control in WPF Pin
Ekoj Lirpa13-Feb-10 13:04
Ekoj Lirpa13-Feb-10 13:04 
QuestionIE create object to com wrapped dotnet dll launch exe Pin
nlarson1113-Feb-10 3:08
nlarson1113-Feb-10 3:08 
QuestionLooking for FTP component Pin
Hypermommy13-Feb-10 2:20
Hypermommy13-Feb-10 2:20 
AnswerRe: Looking for FTP component Pin
Dimitri Witkowski13-Feb-10 3:54
Dimitri Witkowski13-Feb-10 3:54 
AnswerRe: Looking for FTP component Pin
Not Active13-Feb-10 7:26
mentorNot Active13-Feb-10 7:26 
GeneralRe: Looking for FTP component Pin
Hypermommy15-Feb-10 6:09
Hypermommy15-Feb-10 6:09 
Question.NET Configuration Tools (caspol.exe) with visual studio 2008 express? Pin
giohappy12-Feb-10 7:17
giohappy12-Feb-10 7:17 
QuestionHelp with a gauge control [modified] Pin
Bob Beaubien12-Feb-10 4:34
Bob Beaubien12-Feb-10 4:34 
AnswerRe: Help with a gauge control Pin
Richard MacCutchan12-Feb-10 5:57
mveRichard MacCutchan12-Feb-10 5:57 
GeneralRe: Help with a gauge control Pin
Bob Beaubien12-Feb-10 10:56
Bob Beaubien12-Feb-10 10:56 
QuestionUpdate .Net Framework 3.5 to .Net Framework 3.5 SP1 Pin
xodeblack11-Feb-10 23:32
xodeblack11-Feb-10 23:32 
AnswerRe: Update .Net Framework 3.5 to .Net Framework 3.5 SP1 Pin
Richard MacCutchan12-Feb-10 0:20
mveRichard MacCutchan12-Feb-10 0:20 
AnswerRe: Update .Net Framework 3.5 to .Net Framework 3.5 SP1 Pin
Kevin McFarlane13-Feb-10 9:14
Kevin McFarlane13-Feb-10 9:14 
QuestionGetting Error while opening .NET project in Visual Studio 2005 Pin
deadlyabbas11-Feb-10 22:12
deadlyabbas11-Feb-10 22:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.