I have configured a spring boot application which when run reads messages from the queue and processes them accordingly. I also have configured the concurrency flag to run multiple such readers. However in an ideal world i would like the receiver to keep running like a thread and keep checking for any messages. My question is that whether there is any way i can configure this in spring boot or i have to fallback to using threading mechanism using executor or anything else. Thanks, - Vaibhav
I found a nice way from Spring Boot, the concurrency was of course taken case by concurrent attribute e.g.
@JmsListener(destination = "myqueue", concurrency="2-10")
However for the Thread part below was something which is a neat way:
@SpringBootApplication
@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
@EnableJms
public class MyApplication implements CommandLineRunner{
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
@Override
public void run(String... arg0) throws Exception {
// TODO Auto-generated method stub
System.out.println("Joining Thread ctrl+c to bring down application");
Thread.currentThread().join();
}
}