<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi Teaches,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> 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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> 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. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> I have gone through the google ,I didn’t find the solution. Please help me. Thanks in Adv.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Can you please find the attached mail which contains Android client consumer application sample code(from android client application).<o:p></o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sample code:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>public</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>void</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> pushData(Set<String> queueNames, String </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>message</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>) {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>try</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>conn</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'> = </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>factory</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.newConnection();</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>channel</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'> = </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>conn</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.createChannel();</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> } </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>catch</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> (Exception e) {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>log</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.error(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"Error while creating connetion/channel for RabbitMQ Server:"</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>+e);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>try</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>for</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> (String queueName : </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>queueNames</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>) {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>try</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>{ </span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#3F7F5F'>// channel.exchangeDeclare(EXCHANGE_NAME, "direct", true);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> <o:p></o:p></span></p><p class=MsoNormal style='margin-left:1.5in;text-indent:.5in;text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>channel</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.queueDeclare(queueName, </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>false</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>, </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>false</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>, </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>false</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>, </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>null</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>channel</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.basicPublish(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>""</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>, queueName, </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>null</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>, </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>message</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.getBytes());</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>catch</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> (Exception e) {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>log</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.error(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"Error while RabbitMQ Server publishing the message"</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>+ </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>message</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>+ </span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"\n and for the queue "</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>+queueName+</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"\n"</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'> +e);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>message</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'> = </span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>""</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>;</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>channel</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.close();</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>conn</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.close();</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> } </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>catch</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> (IOException e) {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>log</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.error(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"Error while RabbitMQ Server publishing the message"</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>+ e);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Let me know any information needed. <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks&Regards<o:p></o:p></p><p class=MsoNormal>Mahendra.y<o:p></o:p></p><p class=MsoNormal>Software Engineer<o:p></o:p></p><p class=MsoNormal>Neelinfo Software Solutions,Hyderbad,India.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>