I am using spring amqp. Simple POJOs get message automatically upon arrival of a new message or rabbitMQ&#39;s delivery.<br><br><u>spring configurations for template :</u><br><br>&lt;!-- Define a RabbitMQ connectionFactory --&gt;<br>

��� &lt;bean id=&quot;connectionFactory&quot;<br>��� ��� class=&quot;org.springframework.amqp.rabbit.connection.SingleConnectionFactory&quot;&gt;<br>��� ��� &lt;constructor-arg value=&quot;localhost&quot; /&gt;<br>��� ��� &lt;property name=&quot;username&quot; value=&quot;guest&quot; /&gt;<br>

��� ��� &lt;property name=&quot;password&quot; value=&quot;guest&quot; /&gt;<br>��� &lt;/bean&gt;<br><br><div class="gmail_quote"><u>use that template in ur POJO to become a &quot;magical&quot; consumer:</u><br><br>&lt;bean id=&quot;msgHandler&quot; class=&quot;com.xyz.MsgHandler&quot; /&gt;<br>

��� <br>��� &lt;bean id=&quot;msgHandlerAdaptor&quot; class=&quot;org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter&quot;&gt;<br>��� ��� &lt;constructor-arg ref=&quot;msgHandler&quot; /&gt;<br>��� &lt;/bean&gt;<br>

<br>��� &lt;bean id=&quot;msgListener&quot; class=&quot;org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer&quot;<br>��� ��� p:connectionFactory-ref=&quot;connectionFactory&quot; p:queueName=&quot;Queue1&quot; p:autoAck=&quot;false&quot; p:concurrentConsumers=&quot;20&quot;� p:messageListener-ref=&quot;msgHandlerAdaptor&quot; /&gt;<br>

<br><u>Bean has</u><br><br>��� public void handleMessage(String msg) {<br><br>��� }<br><br><br>That&#39;s it !!!<br><br><br>On Thu, Oct 14, 2010 at 12:05 PM, sam_mis <span dir="ltr">&lt;<a href="mailto:sameek@arosys.com">sameek@arosys.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br>
Hi<br>
<br>
i am using the following code to read an queue and extract the messages from<br>
queue. I want to know that there is another approach to retrieve message<br>
from queue? if there is another approach please describe the details<br>
information to get the messages from queue.<br>
<br>
�while (runInfinite)<br>
�{<br>
 � � QueueingConsumer.Delivery delivery;<br>
 � � � � � �try<br>
 � � � � � �{<br>
 � � � � � � �delivery = consumer.nextDelivery();<br>
 � � � � � �} catch (InterruptedException ie)<br>
 � � � � � �{<br>
 � � � � � � � continue;<br>
 � � � � � �}<br>
 � � � � System.out.println(&quot;Message received-&quot;<br>
+ new String(delivery.getBody()));<br>
<br>
file included that contain the �code for reading and extracting message:<br>
--------------------------------------------------------------------------<br>
<a href="http://old.nabble.com/file/p29959643/Result.java" target="_blank">http://old.nabble.com/file/p29959643/Result.java</a> Result.java<br>
<br>
Thanks<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://old.nabble.com/another-approach-to-retrieve-message-from-queue--tp29959643p29959643.html" target="_blank">http://old.nabble.com/another-approach-to-retrieve-message-from-queue--tp29959643p29959643.html</a><br>


Sent from the RabbitMQ mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</font></blockquote></div><br>