system.messaging queue frozen while message.receive

515 views Asked by At

This is the first time I have used this messaging library and used some example code to implement it. The first time I ran it it worked perfectly but I abruptly stopped the code since my parsing method seemed wrong. So when I restarted it, the code freezes at the following line:

message = q.Receive()

Is it possible the message queue got corrupted or something? I checked the server manager and it looks like the queue is still there and number of messages =1 as before. Here is the rest of my code:

 If MessageQueue.Exists(".\private$\TwitterQueue") Then
        q = New MessageQueue(".\private$\TwitterQueue")
    Else
        'GS - If there is no queue then we're done here
        Console.WriteLine("Queue has not been created!")
       Return
 End If
 Try
    While True
            'GS - Try and pull back the next message
            Dim message As Message
            Try
                message = q.Receive()
                message.Formatter = New XmlMessageFormatter(New [String]() {"System.String"})
                 ProcessMessage(message)

             Catch

             end try
End While

EDIT:

how queue is created:

 Dim q As MessageQueue = If((MessageQueue.Exists(".\private$\TwitterQueue")), New MessageQueue(".\private$\TwitterQueue"), MessageQueue.Create(".\private$\TwitterQueue"))

and how it is used:

Dim msg As New Message(responseData)
q.Send(msg)

and just checked if it was transactional;

If q.Transactional = True Then
                    Thread.Sleep(2000)
                End If

and it is not.

1

There are 1 answers

0
Hadi 'Hadijoe' Pribadi On

If you try Create Queue from behind code, you can try to set the permissions

If MessageQueue.Exists(".\private$\TwitterQueue") Then
        q = New MessageQueue(".\private$\TwitterQueue")
        q.SetPermissions("Everyone", MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow)
    Else
        'GS - If there is no queue then we're done here
        Console.WriteLine("Queue has not been created!")
       Return
 End If

If still cannot receive the Queue, I recommend to create Queue manually.