|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.jms.support.JmsAccessor
org.springframework.jms.support.destination.JmsDestinationAccessor
org.springframework.jms.listener.AbstractJmsListeningContainer
org.springframework.jms.listener.AbstractMessageListenerContainer
org.apache.servicemix.jbi.cluster.requestor.AbstractJmsRequestorPool
org.apache.servicemix.jbi.cluster.requestor.AbstractPollingRequestorPool
org.apache.servicemix.jbi.cluster.requestor.GenericJmsRequestorPool
public class GenericJmsRequestorPool
A pool of session / consumer / producer.
Pool items are obtained using the getRequestor(String) method and
released using Requestor#close() method.
| Nested Class Summary | |
|---|---|
class |
GenericJmsRequestorPool.AsyncMessageListenerInvoker
|
| Nested classes/interfaces inherited from class org.apache.servicemix.jbi.cluster.requestor.AbstractPollingRequestorPool |
|---|
AbstractPollingRequestorPool.Requestor, AbstractPollingRequestorPool.TransactionException |
| Nested classes/interfaces inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer |
|---|
org.springframework.jms.listener.AbstractJmsListeningContainer.SharedConnectionNotInitializedException |
| Field Summary | |
|---|---|
static long |
DEFAULT_RECEIVE_TIMEOUT
The default receive timeout: 1000 ms = 1 second. |
| Fields inherited from class org.apache.servicemix.jbi.cluster.requestor.AbstractPollingRequestorPool |
|---|
listener, parked, transacted, transactionManager |
| Fields inherited from class org.apache.servicemix.jbi.cluster.requestor.AbstractJmsRequestorPool |
|---|
concurrentConsumers, DEFAULT_RECOVERY_INTERVAL, DEFAULT_THREAD_NAME_PREFIX, maxConcurrentConsumers |
| Fields inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer |
|---|
lifecycleMonitor, sharedConnectionMonitor |
| Fields inherited from class org.springframework.jms.support.JmsAccessor |
|---|
logger |
| Constructor Summary | |
|---|---|
GenericJmsRequestorPool()
|
|
| Method Summary | |
|---|---|
protected AbstractPollingRequestorPool.Requestor |
createRequestor(boolean consume)
|
void |
doInitialize()
|
int |
getActiveConsumerCount()
Return the number of currently active consumers. |
int |
getIdleTaskExecutionLimit()
Return the limit for idle executions of a receive task. |
int |
getMaxMessagesPerTask()
Return the maximum number of messages to process in one task. |
long |
getReceiveTimeout()
|
AbstractPollingRequestorPool.Requestor |
getRequestor(String id)
Retrieve a parked session/consumer/producer triplet from the pool or a newly created one. |
int |
getScheduledConsumerCount()
Return the number of currently scheduled consumers. |
boolean |
isSharedConnectionEnabled()
|
protected void |
messageReceived(Object invoker,
javax.jms.Session session)
Tries scheduling a new invoker, since we know messages are coming in... |
protected void |
noMessageReceived(Object invoker,
javax.jms.Session session)
Marks the affected invoker as idle. |
protected void |
scheduleNewInvokerIfAppropriate()
Schedule a new invoker, increasing the total number of scheduled invokers for this listener container, but only if the specified "maxConcurrentConsumers" limit has not been reached yet, and only if this listener container does not currently have idle invokers that are waiting for new messages already. |
void |
setIdleTaskExecutionLimit(int idleTaskExecutionLimit)
Specify the limit for idle executions of a receive task, not having received any message within its execution. |
void |
setMaxMessagesPerTask(int maxMessagesPerTask)
Specify the maximum number of messages to process in one task. |
void |
setMessageSelector(String selector)
|
void |
setReceiveTimeout(long receiveTimeout)
Set the timeout to use for receive calls, in milliseconds. |
void |
setSharedConnectionEnabled(boolean sharedConnectionEnabled)
|
protected boolean |
sharedConnectionEnabled()
|
| Methods inherited from class org.apache.servicemix.jbi.cluster.requestor.AbstractPollingRequestorPool |
|---|
doShutdown, getListener, getTransacted, getTransactionManager, newRequestor, parkItem, resume, setListener, setTransacted, setTransactionManager |
| Methods inherited from class org.springframework.jms.listener.AbstractMessageListenerContainer |
|---|
checkMessageListener, commitIfNecessary, doExecuteListener, doInvokeListener, doInvokeListener, executeListener, getDefaultSubscriptionName, getDestination, getDestinationDescription, getDestinationName, getDurableSubscriptionName, getExceptionListener, getMessageListener, getMessageSelector, handleListenerException, invokeErrorHandler, invokeExceptionListener, invokeListener, isAcceptMessagesWhileStopping, isExposeListenerSession, isSessionLocallyTransacted, isSubscriptionDurable, rollbackIfNecessary, rollbackOnExceptionIfNecessary, setAcceptMessagesWhileStopping, setDestination, setDestinationName, setDurableSubscriptionName, setErrorHandler, setExceptionListener, setExposeListenerSession, setMessageListener, setSubscriptionDurable, validateConfiguration |
| Methods inherited from class org.springframework.jms.listener.AbstractJmsListeningContainer |
|---|
afterPropertiesSet, createSharedConnection, destroy, doStart, doStop, getBeanName, getClientId, getPausedTaskCount, getPhase, getSharedConnection, isActive, isAutoStartup, isRunning, logRejectedTask, prepareSharedConnection, refreshSharedConnection, rescheduleTaskIfNecessary, resumePausedTasks, runningAllowed, setAutoStartup, setBeanName, setClientId, setPhase, shutdown, start, stop, stop |
| Methods inherited from class org.springframework.jms.support.destination.JmsDestinationAccessor |
|---|
getDestinationResolver, isPubSubDomain, resolveDestinationName, setDestinationResolver, setPubSubDomain |
| Methods inherited from class org.springframework.jms.support.JmsAccessor |
|---|
createConnection, createSession, getConnectionFactory, getSessionAcknowledgeMode, isClientAcknowledge, isSessionTransacted, setConnectionFactory, setSessionAcknowledgeMode, setSessionAcknowledgeModeName, setSessionTransacted |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.springframework.context.Lifecycle |
|---|
isRunning, start, stop |
| Field Detail |
|---|
public static final long DEFAULT_RECEIVE_TIMEOUT
| Constructor Detail |
|---|
public GenericJmsRequestorPool()
| Method Detail |
|---|
public void setReceiveTimeout(long receiveTimeout)
NOTE: This value needs to be smaller than the transaction timeout used by the transaction manager (in the appropriate unit, of course). -1 indicates no timeout at all; however, this is only feasible if not running within a transaction manager.
MessageConsumer.receive(long),
MessageConsumer.receive(),
#setTransactionTimeoutpublic long getReceiveTimeout()
public boolean isSharedConnectionEnabled()
public void setSharedConnectionEnabled(boolean sharedConnectionEnabled)
protected boolean sharedConnectionEnabled()
sharedConnectionEnabled in class org.springframework.jms.listener.AbstractJmsListeningContainer
protected AbstractPollingRequestorPool.Requestor createRequestor(boolean consume)
throws javax.jms.JMSException
createRequestor in class AbstractPollingRequestorPooljavax.jms.JMSExceptionpublic final int getScheduledConsumerCount()
This number will always be inbetween "concurrentConsumers" and "maxConcurrentConsumers", but might be higher than "activeConsumerCount" (in case of some consumers being scheduled but not executed at the moment).
AbstractJmsRequestorPool.getConcurrentConsumers(),
AbstractJmsRequestorPool.getMaxConcurrentConsumers(),
getActiveConsumerCount()public final int getActiveConsumerCount()
This number will always be inbetween "concurrentConsumers" and "maxConcurrentConsumers", but might be lower than "scheduledConsumerCount". (in case of some consumers being scheduled but not executed at the moment).
AbstractJmsRequestorPool.getConcurrentConsumers(),
AbstractJmsRequestorPool.getMaxConcurrentConsumers(),
getActiveConsumerCount()public void setMaxMessagesPerTask(int maxMessagesPerTask)
"receiveTimeout" property).
Default is unlimited (-1) in case of a standard TaskExecutor, reusing the original invoker threads until shutdown (at the expense of limited dynamic scheduling).
In case of a SchedulingTaskExecutor indicating a preference for short-lived tasks, the default is 10 instead. Specify a number of 10 to 100 messages to balance between rather long-lived and rather short-lived tasks here.
Long-lived tasks avoid frequent thread context switches through sticking with the same thread all the way through, while short-lived tasks allow thread pools to control the scheduling. Hence, thread pools will usually prefer short-lived tasks.
This setting can be modified at runtime, for example through JMX.
AbstractJmsRequestorPool.setTaskExecutor(org.springframework.core.task.TaskExecutor),
setReceiveTimeout(long),
SchedulingTaskExecutor.prefersShortLivedTasks()public int getMaxMessagesPerTask()
public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit)
Default is 1, closing idle resources early once a task didn't
receive a message. This applies to dynamic scheduling only; see the
"maxConcurrentConsumers" setting.
The minimum number of consumers
(see "concurrentConsumers")
will be kept around until shutdown in any case.
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 "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).
This setting can be modified at runtime, for example through JMX.
setMaxMessagesPerTask(int),
setReceiveTimeout(long)public int getIdleTaskExecutionLimit()
protected void messageReceived(Object invoker,
javax.jms.Session session)
scheduleNewInvokerIfAppropriate()
protected void noMessageReceived(Object invoker,
javax.jms.Session session)
protected void scheduleNewInvokerIfAppropriate()
Called once a message has been received, to scale up while processing the message in the invoker that originally received it.
AbstractJmsRequestorPool.setTaskExecutor(org.springframework.core.task.TaskExecutor),
AbstractJmsRequestorPool.getMaxConcurrentConsumers()
public AbstractPollingRequestorPool.Requestor getRequestor(String id)
throws javax.jms.JMSException
id - the parking id
javax.jms.JMSException - if an error occur
public void doInitialize()
throws javax.jms.JMSException
doInitialize in class org.springframework.jms.listener.AbstractJmsListeningContainerjavax.jms.JMSExceptionpublic void setMessageSelector(String selector)
setMessageSelector in interface JmsRequestorPoolsetMessageSelector in class org.springframework.jms.listener.AbstractMessageListenerContainer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||