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

Kshitiz Garg stephanion2002 at gmail.com
Thu Oct 14 07:55:31 BST 2010


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20101014/ee44f983/attachment-0001.htm>


More information about the rabbitmq-discuss mailing list