Как использовать очередь приоритетов с Spring Boot AsyncConfigurerJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Гость
 Как использовать очередь приоритетов с Spring Boot AsyncConfigurer

Сообщение Гость »


I have a application where I have multiple threads reading messages from a jms destination. The listener thread reads the message, makes some changes to it and calls several other methods of different classes. These methods are annotated with @Async annotation that all the methods gets executed in parallel using a custom ThreadPoolTaskExecutor.

@Override public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); executor.setKeepAliveSeconds(keepAliveSeconds); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); executor.setTaskDecorator(new LoggingTaskDecorator()); executor.initialize(); return executor; } Until now all the messages were considered to be of equal priority everything was fine, as all messages were going into LinkedBlockingQueue if none of the Executor threads left available.

Now, there comes a requirement where a particular type of message read from the queue is expected to be given higher priority than any other message read from the queue.

Currently, I am using "org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor", which doesn't provide any method where I can set Priority Queue as my Blocking queue implementation.

Could, you please help me solve this scenario? Or is that the existing design of the system could not accommodate this change? Or what could be the best solution to handle such scenarios?

Thanks !


Источник: https://stackoverflow.com/questions/525 ... configurer
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»