[rabbitmq-discuss] another approach to retrieve message from queue?

sam_mis sameek at arosys.com
Thu Oct 14 12:15:42 BST 2010


Thanks for reply but i am not using spring amqp.
-------

Kshitiz Garg-2 wrote:
> 
> I am using spring amqp. Simple POJOs get message automatically upon
> arrival
> of a new message or rabbitMQ's delivery.
> 
> *spring configurations for template :*
> 
> <!-- Define a RabbitMQ connectionFactory -->
>     <bean id="connectionFactory"
> 
> class="org.springframework.amqp.rabbit.connection.SingleConnectionFactory">
>         <constructor-arg value="localhost" />
>         <property name="username" value="guest" />
>         <property name="password" value="guest" />
>     </bean>
> 
> *use that template in ur POJO to become a "magical" consumer:*
> 
> <bean id="msgHandler" class="com.xyz.MsgHandler" />
> 
>     <bean id="msgHandlerAdaptor"
> class="org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter">
>         <constructor-arg ref="msgHandler" />
>     </bean>
> 
>     <bean id="msgListener"
> class="org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer"
>         p:connectionFactory-ref="connectionFactory" p:queueName="Queue1"
> p:autoAck="false" p:concurrentConsumers="20"
> p:messageListener-ref="msgHandlerAdaptor" />
> 
> *Bean has*
> 
>     public void handleMessage(String msg) {
> 
>     }
> 
> 
> That's it !!!
> 
> 
> On Thu, Oct 14, 2010 at 12:05 PM, sam_mis <sameek at arosys.com> wrote:
> 
>>
>> Hi
>>
>> i am using the following code to read an queue and extract the messages
>> from
>> queue. I want to know that there is another approach to retrieve message
>> from queue? if there is another approach please describe the details
>> information to get the messages from queue.
>>
>>  while (runInfinite)
>>  {
>>     QueueingConsumer.Delivery delivery;
>>            try
>>            {
>>              delivery = consumer.nextDelivery();
>>            } catch (InterruptedException ie)
>>            {
>>               continue;
>>            }
>>         System.out.println("Message received-"
>> + new String(delivery.getBody()));
>>
>> file included that contain the  code for reading and extracting message:
>> --------------------------------------------------------------------------
>> http://old.nabble.com/file/p29959643/Result.java Result.java
>>
>> Thanks
>>
>> --
>> View this message in context:
>> http://old.nabble.com/another-approach-to-retrieve-message-from-queue--tp29959643p29959643.html
>> Sent from the RabbitMQ mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
> 
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> 
> 

-- 
View this message in context: http://old.nabble.com/another-approach-to-retrieve-message-from-queue--tp29959643p29961403.html
Sent from the RabbitMQ mailing list archive at Nabble.com.



More information about the rabbitmq-discuss mailing list