spring amqp - Processing message from rabbitmq at specified rate -


we have been trying make listener read messages rabbitmq @ rate 1 msg/2 seconds. did not find such utility rabbit mq far. thought of doing db i.e. listener read messages , store db , later scheduler process @ desired rate db. if there better way of doing this, please suggest. developing our application in spring. in advance.

you can't listener, can rabbittemplate ...

@springbootapplication public class so40446967application {      public static void main(string[] args) throws exception {         configurableapplicationcontext context = springapplication.run(so40446967application.class, args);         rabbitadmin admin = context.getbean(rabbitadmin.class);         anonymousqueue queue = new anonymousqueue();         admin.declarequeue(queue);         rabbittemplate template = context.getbean(rabbittemplate.class);         (int = 0; < 10; i++) {             template.convertandsend(queue.getname(), "foo" + i);         }         string out = (string) template.receiveandconvert(queue.getname());         while (out != null) {             system.out.println(new date() + " " + out);             thread.sleep(2000);             out = (string) template.receiveandconvert(queue.getname());         }         context.close();     }  } 

of course can use more sophisticated task scheduler or spring @async method rather sleeping.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -