[rabbitmq-discuss] RE Rabbit MQ Dead Lock

Joemon Varghese joemonvarghese80 at gmail.com
Thu Sep 6 13:25:39 BST 2012


I have attached the code that i have implemented.


 //declare a Input queue
                strQueue = InputQueue + "." + objMessage.InputKey;
                model = GetModel();
                model.QueueDeclare(strQueue);
                model.QueueBind(strQueue, Exchange, objMessage.InputKey,
true, null);
                //declare a Response queue
                strResponseQueue = ResponseQueue + "." +
objMessage.InputKey; ;
                modelResponse = GetModelForResponse();
                modelResponse.QueueDeclare(strResponseQueue);
                object msgTask = objMessage.Action;
                //Serialize the Message object
                MemoryStream stream = new MemoryStream();
                DataContractJsonSerializer jsonSerializer = new
DataContractJsonSerializer(typeof(Message));
                jsonSerializer.WriteObject(stream, objMessage);
                byte[] messageBody = stream.ToArray();
                IBasicProperties msgProperties =
model.CreateBasicProperties();
                msgProperties.AppId = RabbitHelper.AppID;
                msgProperties.Headers = new Dictionary<string, object>();
                msgProperties.Headers.Add("MessageTask", msgTask);
                msgProperties.MessageId = Guid.NewGuid().ToString();
                MessageID = msgProperties.MessageId;

                modelResponse.QueueBind(strResponseQueue, Exchange,
MessageID, true, null);
                model.BasicPublish(Exchange, objMessage.InputKey,
msgProperties, messageBody);
 subscription = new Subscription(modelResponse, strResponseQueue, false);
                while (subscription.Next(-1, out basicArgs))
                {
                    if (!object.ReferenceEquals(basicArgs, null))
                    {
                        IBasicProperties props = basicArgs.BasicProperties;
                        byte[] responseMessageBody = basicArgs.Body;
                        //Deserialize the message object
                        IMessage recvMessage =
RabbitHelper.ConvertJsonToObject<Message>(responseMessageBody);
 //validate if this is the desired response
                        if (props.MessageId == MessageID)
                        {
                            retVal = recvMessage.ReturnValue;
                            //acknowledge the queue
                            subscription.Ack(basicArgs);
                        }
                    }
                }



Thanks and Regards,
Joe
 On Thu, Sep 6, 2012 at 5:00 PM, Emile Joubert <emile at rabbitmq.com> wrote:

> Hi Joemon,
>
> On 06/09/12 11:53, Joemon Varghese wrote:
> >  We are not able to reproduce this issue.We are  getting thread abort
> error.
>
> Ok, but that does not sound like deadlock.
>
> >    Is there any chances of message being automatically
> > deleted from Queue after certain amount of time.?
>
> Yes: messages may be removed from a queue if the queue was declared with
> TTL: http://www.rabbitmq.com/ttl.html#per-queue-message-ttl
>
> >  because  sometimes my queries will take more than 1 hour but still i am
> > keep on polling for the Response queue  for this     mesage id.
>
> I'm afraid you have not provided enough information for me to
> investigate any further. If you can reproduce the problem then please
> provide a description of the steps to reproduce, or a minimal
> self-contained piece of code that triggers the failure. In the meantime
> here are some suggestions:
>
> - v2.7.1 is very old now. Upgrade to the latest version
> - Try not to use polling
>
>
>
> -Emile
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120906/29482534/attachment.htm>


More information about the rabbitmq-discuss mailing list