You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2009/01/15 17:48:25 UTC
svn commit: r734753 - in
/servicemix/components/bindings/servicemix-jms/trunk/src:
main/java/org/apache/servicemix/jms/endpoints/JmsConsumerEndpoint.java
test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java
Author: gnodet
Date: Thu Jan 15 08:48:25 2009
New Revision: 734753
URL: http://svn.apache.org/viewvc?rev=734753&view=rev
Log:
SM-1670: smx-jms consumer endpoints should support maxConcurrentConsumers property from Spring JMS
Modified:
servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerEndpoint.java
servicemix/components/bindings/servicemix-jms/trunk/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java
Modified: servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerEndpoint.java?rev=734753&r1=734752&r2=734753&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-jms/trunk/src/main/java/org/apache/servicemix/jms/endpoints/JmsConsumerEndpoint.java Thu Jan 15 08:48:25 2009
@@ -79,6 +79,8 @@
private int concurrentConsumers = 1;
// default listener properties
+ private int idleTaskExecutionLimit = 1;
+ private int maxConcurrentConsumers = 1;
private int cacheLevel = DefaultMessageListenerContainer.CACHE_NONE;
private long receiveTimeout = DefaultMessageListenerContainer.DEFAULT_RECEIVE_TIMEOUT;
private long recoveryInterval = DefaultMessageListenerContainer.DEFAULT_RECOVERY_INTERVAL;
@@ -260,6 +262,40 @@
}
/**
+ * @return the idleTaskExecutionLimit
+ */
+ public int getIdleTaskExecutionLimit() {
+ return idleTaskExecutionLimit;
+ }
+
+ /**
+ * Specifies the limit for idle executions of a receive 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
+ * (in case of dynamic scheduling; see the "maxConcurrentConsumers" setting).
+ * 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).
+ * 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 "maxMessagePerTask" 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).
+ *
+ * This property is only used for consumers whose <code>listenerType</code>
+ * property is set to <code>default</code>.
+ *
+ * @param idleTaskExecutionLimit the number of concurrent consumers to create
+ * @see org.springframework.jms.listener.DefaultMessageListenerContainer#setIdleTaskExecutionLimit(int)
+ */
+ public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit) {
+ this.idleTaskExecutionLimit = idleTaskExecutionLimit;
+ }
+
+ /**
* @return the listenerType
*/
public String getListenerType() {
@@ -277,6 +313,29 @@
}
/**
+ * @return the maxConcurrentConsumers
+ */
+ public int getMaxConcurrentConsumers() {
+ return maxConcurrentConsumers;
+ }
+
+ /**
+ * Specifies the maximum number of concurrent consumers created by the listener.
+ * If this setting is higher than "concurrentConsumers", the listener container
+ * will dynamically schedule new consumers at runtime, provided that enough incoming
+ * messages are encountered. Once the load goes down again, the number of consumers
+ * will be reduced to the standard level ("concurrentConsumers") again.
+ * This property is only used for consumers whose <code>listenerType</code>
+ * property is set to <code>default</code>.
+ *
+ * @param maxConcurrentConsumers the maximum number of concurrent consumers to create
+ * @see org.springframework.jms.listener.DefaultMessageListenerContainer#setMaxConcurrentConsumers(int)
+ */
+ public void setMaxConcurrentConsumers(int maxConcurrentConsumers) {
+ this.maxConcurrentConsumers = maxConcurrentConsumers;
+ }
+
+ /**
* @return the maxMessagesPerTask
*/
public int getMaxMessagesPerTask() {
@@ -569,6 +628,8 @@
}
cont.setCacheLevel(cacheLevel);
cont.setConcurrentConsumers(concurrentConsumers);
+ cont.setIdleTaskExecutionLimit(idleTaskExecutionLimit);
+ cont.setMaxConcurrentConsumers(maxConcurrentConsumers);
cont.setMaxMessagesPerTask(maxMessagesPerTask);
cont.setPubSubNoLocal(pubSubNoLocal);
cont.setReceiveTimeout(receiveTimeout);
Modified: servicemix/components/bindings/servicemix-jms/trunk/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-jms/trunk/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java?rev=734753&r1=734752&r2=734753&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-jms/trunk/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java (original)
+++ servicemix/components/bindings/servicemix-jms/trunk/src/test/java/org/apache/servicemix/jms/JmsConsumerEndpointTest.java Thu Jan 15 08:48:25 2009
@@ -147,6 +147,9 @@
endpoint.setListenerType("default");
endpoint.setConnectionFactory(connectionFactory);
endpoint.setDestinationName("destination");
+ endpoint.setConcurrentConsumers(1);
+ endpoint.setIdleTaskExecutionLimit(1);
+ endpoint.setMaxConcurrentConsumers(1);
component.setEndpoints(new JmsConsumerEndpoint[] {endpoint});
container.activateComponent(component, "servicemix-jms");