Announcement Announcement Module
Collapse
No announcement yet.
How to get List of Messges From Queue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get List of Messges From Queue

    I am using Spring-RabbitMQ integration. I am new to this.
    I want to expose the Messages in Queue using Rest Api.
    Is there any apito display the messages with out any consumption.

    Thanks for your time.

  • #2
    You should ask questions like this on the Rabbit Mailing list, but I believe the answer is no, you can't browser RabbitMQ queues.

    Comment


    • #3
      Thanks Gary Russell.
      I will do that.

      Comment


      • #4
        Hi!
        Let me to insert my hand too.
        Some prototype based on Spring AMQP with Spring Integration:
        Code:
        	public static void main(String[] args) {
        		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("Test-context.xml", Test.class);
        		RabbitOperations amqpTemplate = ctx.getBean(RabbitOperations.class);
        		final MessageChannel logChannel = ctx.getBean("logChannel", MessageChannel.class);
        
        		amqpTemplate.execute(new ChannelCallback<Void>() {
        			@Override
        			public Void doInRabbit(Channel channel) throws Exception {
        				for (int i = 0; i < 1000; i++) {
        					GetResponse response = channel.basicGet("test.queue", false);
        					if (response != null) {
        						MessageProperties messageProps = new DefaultMessagePropertiesConverter().toMessageProperties(
        								response.getProps(), response.getEnvelope(), "UTF-8");
        						logChannel.send(new GenericMessage<Message>(new Message(response.getBody(), messageProps)));
        					}
        				}
        				channel.basicReject(0, true);
        				return null;
        			}
        		});
        
        	}
        Where the "logChannel" is a simple <logging-channel-adapter>.
        So, what I do here:
        1. I use a generic amqpTemplate.execute and implement my own ChannelCallback stategy
        2. I iterate 1000 times to invoke channel.basicGet and build some object from GetResponse
        3. My "test.queue" contains 100 messages.
        4. I get all messages and log them.
        5. All of them in the Unacknowledged state, so next 900 times my cycle works idle.
        6. And the main point here is channel.basicReject(0, true);. And this one requeues all my messages.

        I dont' know which role plays here deliveryTag as a first parameter for basicReject, but in the debug on break point on this line all mesages in the B]Unacknowledged[/B] state, but after basicReject call all of them go to Ready state.

        Looks it like a desired functionality?

        BTW, the RabbitMQ Management HTTP API uses requeue too: http://hg.rabbitmq.com/rabbitmq-mana...api/index.html (the resource /api/queues/vhost/name/get).

        Cheers,
        Artem

        Comment


        • #5
          Artem,

          Thanks for code snippet. I thought the same way.I am facing the issue while Reque.
          I will share the solution once I got it 100%.

          Thanks,
          Raj.

          Comment

          Working...
          X