0

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.

vbNewbie
  • 3,291
  • 15
  • 71
  • 155
  • Could it be that your MessageQueue was created as a transactional MessageQueue? You could also try to use [MessageQueue.Receive(TimeSpan)](http://msdn.microsoft.com/en-us/library/ks4025f4) to set a timeout and you should try [MessageQueue.Peek()](http://msdn.microsoft.com/en-us/library/829zyck7). Also check security settings on your queue. – Filburt Jun 12 '12 at 16:27
  • I set the timeout to 30 and 60 seconds and it timedout. I am not sure abt the transactional messagequeue but edited my post to show how the queue was created. – vbNewbie Jun 12 '12 at 16:46
  • never mind I just refreshed and saw the message was removed. Is this done automatically? Is it possible to restore it somehow. – vbNewbie Jun 12 '12 at 17:13
  • Yes, if you `Receive` the Message it is removed from the Queue and cannot be restored. – Filburt Jun 12 '12 at 17:18

1 Answers1

0

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.

user229044
  • 232,980
  • 40
  • 330
  • 338