Scheduled/Delay messaging in Spring AMQP RabbitMq -


i struggling hard find out way scheduled/delaying messages in spring amqp/rabbit mq.
after hell lot of searching still not able in spring amqp. can please tell me how x-delay in spring amqp.
i want delay message if exception occurs in consumer side. rabbitmq says add x-delay , install plugin have done, still messages comming without delay



i getting in message
received <(body:'[b@60a4ae5f(byte[26])'messageproperties [headers={x-delay=15000}

 @bean connectionfactory connectionfactory(){      cachingconnectionfactory connectionfactory=new cachingconnectionfactory("127.0.0.1");     connectionfactory.setusername("guest");     connectionfactory.setpassword("guest");     connectionfactory.setport(1500);     connectionfactory.setpublisherreturns(true);     return connectionfactory;  }  @bean binding binding(@qualifier("queue")queue queue, directexchange exchange) {     return new binding(queue.getname(), binding.destinationtype.queue, exchange.getname(), queue.getname(), null);     //return bindingbuilder.bind(queue).to(exchange).with(queuename);    }  @bean directexchange exchange() {     directexchange exchange=new directexchange("delay-exchange");     return exchange; } 

consumer---
@override

public void onmessage(message message, channel channel) throws exception {      system.out.println("received <" + message+ ">" +rabbittemplate);      if(i==1){         amqp.basicproperties.builder props = new amqp.basicproperties.builder();         map<string,object> headers = message.getmessageproperties().getheaders();         headers.put("x-delay", 15000);         props.headers(headers);         i++;         channel.basicpublish(message.getmessageproperties().getreceivedexchange(), message.getmessageproperties().getreceivedroutingkey(),                 props.build(), message.getbody());     }     } 

first of looks don't follow scheduling messages rabbitmq article:

to use delayed message exchange need declare exchange providing "x-delayed-message" exchange type follows:

map<string, object> args = new hashmap<string, object>(); args.put("x-delayed-type", "direct"); channel.exchangedeclare("my-exchange", "x-delayed-message", true, false, args); 

i'd same can achieved spring amqp:

@bean customexchange delayexchange() {     map<string, object> args = new hashmap<string, object>();     args.put("x-delayed-type", "direct");     return new customexchange("my-exchange", "x-delayed-message", true, false, args); } 

another concern should publish messages delay-exchange, not other. again: mentioned in doc anyway.

update

since spring amqp 1.6 delayed messages supported out-of-the-box feature: https://spring.io/blog/2016/02/16/spring-amqp-1-6-0-milestone-1-and-1-5-4-available.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -