[rabbitmq-discuss] RabbitMQ Message consuming issue (when consumer keepting idle)

Mahendrakumar Yadavalli Mahendrakumary at neelinfo.com
Thu Apr 10 11:56:18 BST 2014


Hi Teaches,

  This is Mahendra working as software engineer . In our project we are using RabbitMq to push the messages from server to client applications. Here client is android based application. Whenever there is a change in Database, we need to pushing the new data to the clients without client server call. We got the sample code form the RabbitMQ site and implemented an application where the producer implemented in web application and consumer was implemented in android application.

   Both the producer and consumer are working fine. We got an issue like "when the android device kept idle for a long time, and start working on it after some time, then messages are not consuming from consumer side. once we delete the queue then it will work fine". The problem is when we kept the client device idle for long time this issue occurs.

   I have gone through the google ,I didn't find the solution. Please help me. Thanks in Adv.

Can you please find the attached mail which contains Android client consumer application sample code(from android client application).
And Here is the sample code for  java producer code(from java application):  Whenever we need to push the data from producer to consumer, we just invoke this below "pushData"method.

Sample code:

public void pushData(Set<String> queueNames, String message) {


            try {
                  conn = factory.newConnection();
                  channel = conn.createChannel();
            } catch (Exception e) {
                  log.error("Error while creating connetion/channel for RabbitMQ Server:"+e);
            }
            try {
                  for (String queueName : queueNames) {
                              try{
                        // channel.exchangeDeclare(EXCHANGE_NAME, "direct", true);

channel.queueDeclare(queueName, false, false, false, null);
                        channel.basicPublish("", queueName, null, message.getBytes());
                              }
                              catch (Exception e) {
                                    log.error("Error while RabbitMQ Server publishing the message"+ message+
                                                "\n and for the queue "+queueName+"\n" +e);

                              }

                  }
                  message = "";
                  channel.close();
                  conn.close();
            } catch (IOException e) {
                  log.error("Error while RabbitMQ Server publishing the message"+ e);

            }
      }



Let me know any information needed.


Thanks&Regards
Mahendra.y
Software Engineer
Neelinfo Software Solutions,Hyderbad,India.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140410/32e8e2e6/attachment.html>
-------------- next part --------------
An embedded message was scrubbed...
From: Manasa Potula <ManasaP at neelinfo.com>
Subject: RabbitMQ Client side consumer code.
Date: Thu, 10 Apr 2014 03:04:54 -0700
Size: 33520
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140410/32e8e2e6/attachment.mht>


More information about the rabbitmq-discuss mailing list