Question

I have been using azure service bus to send messages to and fro between web role and worker role and i really thought that it was a really good solution but lately i have found that service bus is very erratic, sometimes it works and sometimes the messages go into dead letter for no reason at all. I dont know if its a problem in my code, but it looks to me that it is just erratic because sometimes it works and sometimes it doesnt. So i wanted to know if there are any alternative solution to service bus or i would be very happy to know any mistakes am doing in service bus implementation which is resulting in my above problem. Below is my code

public override void Run()
{
    while (!IsStopped)
    {
        try
        {
            if (BroadcastReceived)
                {
                    BroadcastReceived = false;
                    // Receive the message from Web Role to upload the broadcast to queue
                    BroadcastClient.BeginReceive(OnWebRoleMessageReceived, null);
                }

                if (SignalRMessageReceived)
                {
                    SignalRMessageReceived = false;
                    // Receive the message from SignalR BroadcastHub
                    SignalRClient.BeginReceive(OnSignalRMessageReceived, null);
                }

                if (SignalRFirstTimeMessageReceived)
                {
                    SignalRFirstTimeMessageReceived = false;
                    // Receive the message from SignalR BroadcastHub
                    SignalRFirstTimeClient.BeginReceive(OnSignalRFirstTimeMessageReceived, null);
                } 
     }
 }
public void OnWebRoleMessageReceived(IAsyncResult iar)
{
    BrokeredMessage receivedBroadcastMessage = null;
    receivedBroadcastMessage = BroadcastClient.EndReceive(iar);

    if (receivedBroadcastMessage != null)
    {
        // Process the message
       receivedBroadcastMessage.Complete();
    }
BroadcastReceived = true;
 }

In the above code I am showing the method of only one service bus client. In my worker role there is use of 3 service bus clients, i.e am asynchronously sending and receiving messages from different queues. Its really weird how some messages work and some go to dead letter without any reason, sometimes its alternate so i thought there must be a problem in my code but i cant find any. Please let me know if anyone has nay idea what the problem is

Était-ce utile?

La solution

Have you considered NServiceBus? I'm not sure if there are alot of examples about integrating SignalR and NServiceBus, but googling around should get you started

http://ben.onfabrik.com/posts/push-notifications-with-nservicebus-and-signalr

Autres conseils

There are a few reasons why message go into DeadLetter Queue without the explicit call to message.DeadLetter(). Check the following: 1) TimeToLive on the Queue and the message, if this time expires then messages are deadlettered and not delivered. By default this is infinite. 2) Delivery count determines how many times a message is received before being deadlettered. Above I do not see any exception handling so say you were getting an error during message processing and complete was not called on the message, the delivery count would increase. On the Queue you have the option to set how many times the message should be delivered before it is dead-lettered.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top