<div>Hi ,</div>
<div> </div>
<div>Please find the attached code for Consumer.java.</div>
<div> </div>
<div>public class SingleConsumer{</div>
<div> </div>
<div> public static void main(String args[]) {</div>
<div> </div>
<div> </div>
<div> ConnectionParameters params = new ConnectionParameters();<br>            params.setUsername(janusProperties.getProperty(&quot;rabbitmq_userName&quot;).trim());<br>            params.setPassword(janusProperties.getProperty(&quot;rabbitmq_password&quot;).trim());<br>
            params.setVirtualHost(&quot;/&quot;);<br>            params.setRequestedHeartbeat(0);<br>            ConnectionFactory factory = new ConnectionFactory(params);<br>            com.rabbitmq.client.Connection connRMQ = factory.newConnection(janusProperties.getProperty(&quot;rabbitmq_server_ip&quot;).trim(), Integer.parseInt(janusProperties.getProperty(&quot;rabbitmq_server_port&quot;).trim())); </div>

<div> </div>
<div> </div>
<div>            Channel channel = connRMQ.createChannel();</div>
<div><br>            String exchangeName = janusProperties.getProperty(&quot;rabbitmq_exchangeName&quot;).trim();<br>            String queueName = janusProperties.getProperty(&quot;rabbitmq_queueName&quot;).trim();<br>            String routingKey = janusProperties.getProperty(&quot;rabbitmq_routingKey&quot;).trim();</div>

<div> </div>
<div>            QueueingConsumer consumer = new QueueingConsumer(channel);<br>            channel.basicConsume(queueName, true, consumer);</div>
<div>           QueueingConsumer.Delivery delivery;</div>
<div>            while (!runInfinite) </div>
<div>            {</div>
<div>                      try {</div>
<div>                   </div>
<div>                     delivery = consumer.nextDelivery();<br>                    <br>                         } catch (InterruptedException ie) {<br>                    log.debug(&quot;Problem in Deliverying the message&quot;);<br>
                    continue;<br>                }</div>
<div> </div>
<div>                  /* 1 . Do some operation on the consumed data which will take 2 -3 sec of time.</div>
<div>                      2. if above operation is success than continue to receive next data</div>
<div>                      3. if above operation fails than resend the message back to the queue( Consumer acting as Producer) using channel.basicPublish</div>
<div> </div>
<div>                  */</div>
<div>                    channel.basicPublish(exchangeName, routingKey, true, false, MessageProperties.PERSISTENT_TEXT_PLAIN, bao.toByteArray());</div>
<div>             </div>
<div>}</div>
<div> </div>
<div>}<br>        }<br></div>
<div> </div>
<div>Memory leakage is because of operating on the data which take times. In that time the QueueingDelivery objects are created as many as the the messages sent by the Producer.</div>
<div><br>Thanks,</div>
<div>Seema</div>
<div class="gmail_quote">On Tue, Feb 2, 2010 at 5:01 PM, Gustavo Aquino <span dir="ltr">&lt;<a href="mailto:aquino.gustavo@gmail.com">aquino.gustavo@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Seema, 
<div><br></div>
<div>You can&#39;t control when your GC will run, if you declare this objects into loop and don&#39;t are using hash tables or maps to reutilize it, so it will be eligible to GC automatically, because your life cycle over in next loop.</div>

<div><br></div>
<div>Today I have a consumer in Java consuming about 1.000 m/s and never used more than 15Mb and this objects never go throw eden memory, if you don&#39;t forward this objects created inside consumer loop, this objects will be automatic eligible for GC but GC don&#39;t run immediately you need to wait.</div>

<div><br></div>
<div>Can you post your consumer code ?</div>
<div><br></div>
<div><br><br>
<div class="gmail_quote">
<div>
<div></div>
<div class="h5">On Tue, Feb 2, 2010 at 3:48 AM, Seema Biradar <span dir="ltr">&lt;<a href="mailto:seemasbiradar@gmail.com" target="_blank">seemasbiradar@gmail.com</a>&gt;</span> wrote:<br></div></div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="h5">
<div>Hi All,<br><br>i tried the rabbit MQ with Producer and Consumer Program.<br><br>in Consumer side i am getting the all the Message, but the following objects<br><br>com.rabbitmq.client.QueueingConsumer.Delivery<br>com.rabbitmq.client.Envelop<br>
com.rabbitmq.client.AMQP.BasicProperties<br><br>are created for each message and not garbage collected immediately after consuming.<br><br><strong>in Producer.java<br></strong><br>used basic publish as shown below.<br><br>
channel.basicPublish(exchangeName, routingKey, true, false, MessageProperties.PERSISTENT_TEXT_PLAIN, bao.toByteArray()) ;<br><br><br><strong>Consumer.java<br></strong><br>channel.basicConsume(queueName, true, consumer);<br>
<br>with no-acknowledgement <strong>true</strong>.<br><br>Please let me know, how to make the above object eligible for garbage collection immediately after consuming.</div>
<div>for Consumer program The Heap Memory allocated is more , as this is performace issue</div>
<div> </div>
<div> </div>
<div>Thanks,</div>
<div>Seema</div><br></div></div>_______________________________________________<br>rabbitmq-discuss mailing list<br><a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br><br></blockquote></div><br></div></blockquote></div>
<br>