2016-09-12 11 views
1

Я пытаюсь получить приложение JMS Spring 4 для динамического масштабирования после обработки большого количества сообщений. В настоящее время у меня есть параллелизм 1-3 потребителей, и я могу видеть успешное масштабирование по отношению к максимальным потребителям, но как только потребители были созданы, они не исчезают. Они остаются там в состоянии WAIT. Я хотел бы знать, есть ли настройка или конфигурация, которая позволяет потребителям отключиться после отключения нагрузки. Кто-нибудь знает?DefaultJmsListenerContainerFactory/DefaultMessageListenerContainer Динамическое масштабирование: как это работает?

Спасибо,

Juan

ответ

1

Посмотрите на этот вариант:

/** 
* Specify the limit for idle executions of a consumer task, not having 
* received any message within its execution. If this limit is reached, 
* the task will shut down and leave receiving to other executing tasks. 
* <p>The default is 1, closing idle resources early once a task didn't 
* receive a message. This applies to dynamic scheduling only; see the 
* {@link #setMaxConcurrentConsumers "maxConcurrentConsumers"} setting. 
* The minimum number of consumers 
* (see {@link #setConcurrentConsumers "concurrentConsumers"}) 
* will be kept around until shutdown in any case. 
* <p>Within each task execution, a number of message reception attempts 
* (according to the "maxMessagesPerTask" setting) will each wait for an incoming 
* message (according to the "receiveTimeout" setting). If all of those receive 
* attempts in a given task return without a message, the task is considered 
* idle with respect to received messages. Such a task may still be rescheduled; 
* however, once it reached the specified "idleTaskExecutionLimit", it will 
* shut down (in case of dynamic scaling). 
* <p>Raise this limit if you encounter too frequent scaling up and down. 
* With this limit being higher, an idle consumer will be kept around longer, 
* avoiding the restart of a consumer once a new load of messages comes in. 
* Alternatively, specify a higher "maxMessagesPerTask" and/or "receiveTimeout" value, 
* which will also lead to idle consumers being kept around for a longer time 
* (while also increasing the average execution time of each scheduled task). 
* <p><b>This setting can be modified at runtime, for example through JMX.</b> 
* @see #setMaxMessagesPerTask 
* @see #setReceiveTimeout 
*/ 
public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit) { 

Также вы можете изучить все другие варианты в DefaultMessageListenerContainer через их JavaDocs.

+0

Я прочитал это и максимальное количество сообщений для каждой задачи и получаю документы с таймаутом, и все они указывают на то, что он функционирует из коробки. Кроме того, я не вижу, как это свойство можно установить на фабрике контейнеров-слушателей JMS по умолчанию. Я хотел бы знать, как люди получили работу с фабрикой контейнеров-слушателей JMS по умолчанию. – jcb

+0

Эти параметры не отображаются в 'DefaultJmsListenerContainerFactory', но вы всегда можете реализовать логику делегирования через' initializeContainer (DefaultMessageListenerContainer) 'override. –

+0

Это отличный вариант, спасибо! – jcb