requeue the message in rabbitmq using Spring ampq -


i new rabbitmq , trying following scenario

--> producer sends message
--> consumer receives message
-- execute own logic

if logic fails - requeue

--> requeue message if consumer fails(machine goes down)

i have implemented basic sender using spring rabbittemplate

rabbittemplate.convertandsend(.....); 

and consumer implemented message listener

public class custommessagelistener implements messagelistener { @override     public void onmessage(message message) {        //** own logic**    } } 

and added container through spring

  <bean id="alistener" class="com.sample.custommessagelistener" autowire="byname"/>   <rabbit:listener-container id="mylistenercontainer" connection-factory="connectionfactory"  acknowledge="auto" prefetch="750" concurrency="5" >     <rabbit:listener ref="alistener" queues="reportqueue"/> </rabbit:listener-container> 

its working fine till part.

now if ** own logic** mentioned in listener fails. want requeue message. how can implement this. blogs have gone through looks returnedmessage needs overridden. not sure how can done through listener.

with acknowledge="auto", message won't ack'd until listener exits normally, there's nothing need do; if listener throws exception or server crashes, message remain in queue.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -