Java Doc for DefaultMessageListenerContainer.java in  » J2EE » spring-framework-2.0.6 » org » springframework » jms » listener » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.jms.listener 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.jms.listener.AbstractJmsListeningContainer
   org.springframework.jms.listener.AbstractMessageListenerContainer
      org.springframework.jms.listener.AbstractPollingMessageListenerContainer
         org.springframework.jms.listener.DefaultMessageListenerContainer

All known Subclasses:   org.springframework.jms.listener.DefaultMessageListenerContainer102,
DefaultMessageListenerContainer
public class DefaultMessageListenerContainer extends AbstractPollingMessageListenerContainer (Code)
Message listener container variant that uses plain JMS client API, specifically a loop of MessageConsumer.receive() calls that also allow for transactional reception of messages (registering them with XA transactions). Designed to work in a native JMS environment as well as in a J2EE environment, with only minimal differences in configuration.

This is a simple but nevertheless powerful form of message listener container. On startup, it obtains a fixed number of JMS Sessions to invoke the listener, and optionally allows for dynamic adaptation at runtime (up until a maximum number). Like SimpleMessageListenerContainer , its main advantage is its low level of runtime complexity, in particular the minimal requirements on the JMS provider: Not even the JMS ServerSessionPool facility is required. Beyond that, it is fully self-recovering in case of the broker being temporarily unavailable, and allows for stops/restarts as well as runtime changes to its configuration.

Actual MessageListener execution happens in asynchronous work units which are created through Spring's org.springframework.core.task.TaskExecutor abstraction. By default, the specified number of invoker tasks will be created on startup, according to the DefaultMessageListenerContainer.setConcurrentConsumers "concurrentConsumers" setting. Specify an alternative TaskExecutor to integrate with an existing thread pool facility (such as a J2EE server's), for example using a org.springframework.scheduling.commonj.WorkManagerTaskExecutor CommonJ WorkManager . With a native JMS setup, each of those listener threads is going to use a cached JMS Session and MessageConsumer (only refreshed in case of failure), using the JMS provider's resources as efficiently as possible.

Message reception and listener execution can automatically be wrapped in transactions through passing a Spring org.springframework.transaction.PlatformTransactionManager into the DefaultMessageListenerContainer.setTransactionManager "transactionManager" property. This will usually be a org.springframework.transaction.jta.JtaTransactionManager in a J2EE enviroment, in combination with a JTA-aware JMS ConnectionFactory obtained from JNDI (check your J2EE server's documentation). Note that this listener container will automatically reobtain all JMS handles for each transaction in case of an external transaction manager specified, for compatibility with all J2EE servers (in particular JBoss). This non-caching behavior can be overridden through the DefaultMessageListenerContainer.setCacheLevel "cacheLevel" / DefaultMessageListenerContainer.setCacheLevelName "cacheLevelName" property, enforcing caching of the Connection (or also Session and MessageConsumer) even in case of an external transaction manager being involved.

Dynamic scaling of the number of concurrent invokers can be activated through specifying a DefaultMessageListenerContainer.setMaxConcurrentConsumers "maxConcurrentConsumers" value that is higher than the DefaultMessageListenerContainer.setConcurrentConsumers "concurrentConsumers" value. Since the latter's default is 1, you can also simply specify a "maxConcurrentConsumers" of e.g. 5, which will lead to dynamic scaling up to 5 concurrent consumers in case of increasing message load, as well as dynamic shrinking back to the standard number of consumers once the load decreases. Consider adapting the DefaultMessageListenerContainer.setIdleTaskExecutionLimit "idleTaskExecutionLimit" setting to control the lifespan of each new task, to avoid frequent scaling up and down, in particular if the ConnectionFactory does not pool JMS Sessions and/or the TaskExecutor does not pool threads (check your configuration!). Note that dynamic scaling only really makes sense for a queue in the first place; for a topic, you will typically stick with the default number of 1 consumer, else you'd receive the same message multiple times on the same node.

It is strongly recommended to either set DefaultMessageListenerContainer.setSessionTransacted"sessionTransacted" to "true" or specify an external DefaultMessageListenerContainer.setTransactionManager"transactionManager" . See the AbstractMessageListenerContainer javadoc for details on acknowledge modes and native transaction options, as well as the AbstractPollingMessageListenerContainer javadoc for details on configuring an external transaction manager.

This class requires a JMS 1.1+ provider, because it builds on the domain-independent API. Use the DefaultMessageListenerContainer102 subclass for JMS 1.0.2 providers.
author:
   Juergen Hoeller
since:
   2.0
See Also:   DefaultMessageListenerContainer.setTransactionManager
See Also:   DefaultMessageListenerContainer.setCacheLevel
See Also:   javax.jms.MessageConsumer.receive(long)
See Also:   SimpleMessageListenerContainer
See Also:   org.springframework.jms.listener.serversession.ServerSessionMessageListenerContainer
See Also:   DefaultMessageListenerContainer102



Field Summary
final public static  intCACHE_CONNECTION
     Constant that indicates to cache a shared JMS Connection.
final public static  intCACHE_CONSUMER
     Constant that indicates to cache a shared JMS Connection and a JMS Session for each listener thread, as well as a JMS MessageConsumer for each listener thread.
final public static  intCACHE_NONE
     Constant that indicates to cache no JMS resources at all.
final public static  intCACHE_SESSION
     Constant that indicates to cache a shared JMS Connection and a JMS Session for each listener thread.
final public static  longDEFAULT_RECOVERY_INTERVAL
     The default recovery interval: 5000 ms = 5 seconds.
final public static  StringDEFAULT_THREAD_NAME_PREFIX
     Default thread name prefix: "DefaultMessageListenerContainer-".


Method Summary
protected  TaskExecutorcreateDefaultTaskExecutor()
     Create a default TaskExecutor.
protected  voiddoInitialize()
     Creates the specified number of concurrent consumers, in the form of a JMS Session plus associated MessageConsumer running in a separate thread.
protected  voiddoRescheduleTask(Object task)
     Re-executes the given task via this listener container's TaskExecutor.
protected  voiddoShutdown()
     Destroy the registered JMS Sessions and associated MessageConsumers.
protected  voidestablishSharedConnection()
     Overridden to accept a failure in the initial setup - leaving it up to the asynchronous invokers to establish the shared Connection on first access.
final public  intgetActiveConsumerCount()
     Return the number of currently active consumers.
public  intgetCacheLevel()
     Return the level of caching that this listener container is allowed to apply.
final public  intgetConcurrentConsumers()
     Return the "concurrentConsumer" setting.
public  intgetIdleTaskExecutionLimit()
     Return the limit for idle executions of a receive task.
final public  intgetMaxConcurrentConsumers()
     Return the "maxConcurrentConsumer" setting.
public  intgetMaxMessagesPerTask()
     Return the maximum number of messages to process in one task.
final public  intgetScheduledConsumerCount()
     Return the number of currently scheduled consumers.
protected  voidhandleListenerSetupFailure(Throwable ex, boolean alreadyRecovered)
     Handle the given exception that arose during setup of a listener.
public  voidinitialize()
    
protected  voidmessageReceived(Message message, Session session)
    
protected  voidrecoverAfterListenerSetupFailure()
     Recover this listener container after a listener failed to set itself up, for example reestablishing the underlying Connection.
protected  voidrefreshConnectionUntilSuccessful()
     Refresh the underlying Connection, not returning before an attempt has been successful.
protected  voidrefreshDestination()
     Refresh the JMS destination that this listener container operates on.
protected  voidscheduleNewInvokerIfAppropriate()
     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.
public  voidsetCacheLevel(int cacheLevel)
     Specify the level of caching that this listener container is allowed to apply.

Default is CACHE_NONE if an external transaction manager has been specified (to reobtain all resources freshly within the scope of the external transaction), and CACHE_CONSUMER else (operating with local JMS resources).

Some J2EE servers only register their JMS resources with an ongoing XA transaction in case of a freshly obtained JMS Connection and Session, which is why this listener container does by default not cache any of those. However, if you want to optimize for a specific server, consider switching this setting to at least CACHE_CONNECTION or CACHE_SESSION even in conjunction with an external transaction manager.

Currently known servers that absolutely require CACHE_NONE for XA transaction processing: JBoss 4.

public  voidsetCacheLevelName(String constantName)
     Specify the level of caching that this listener container is allowed to apply, in the form of the name of the corresponding constant: e.g.
public  voidsetConcurrentConsumers(int concurrentConsumers)
     Specify the number of concurrent consumers to create.
public  voidsetIdleTaskExecutionLimit(int idleTaskExecutionLimit)
     Specify the limit for idle executions of a receive task, not having received any message within its execution.
public  voidsetMaxConcurrentConsumers(int maxConcurrentConsumers)
     Specify the maximum number of concurrent consumers to create.
public  voidsetMaxMessagesPerTask(int maxMessagesPerTask)
     Specify the maximum number of messages to process in one task. More concretely, this limits the number of message reception attempts per task, which includes receive iterations that did not actually pick up a message until they hit their timeout (see "receiveTimeout" property).

Default is unlimited (-1) in case of a standard TaskExecutor, and 1 in case of a SchedulingTaskExecutor that indicates a preference for short-lived tasks.

public  voidsetRecoveryInterval(long recoveryInterval)
     Specify the interval between recovery attempts, in milliseconds.
public  voidsetTaskExecutor(TaskExecutor taskExecutor)
     Set the Spring TaskExecutor to use for running the listener threads.

Default is a org.springframework.core.task.SimpleAsyncTaskExecutor , starting up a number of new threads, according to the specified number of concurrent consumers.

Specify an alternative TaskExecutor for integration with an existing thread pool.

final protected  booleansharedConnectionEnabled()
     Use a shared JMS Connection depending on the "cacheLevel" setting.
protected  voidsleepInbetweenRecoveryAttempts()
     Sleep according to the specified recovery interval.
protected  voidstartSharedConnection()
     This implementations proceeds even after an exception thrown from Connection.start(), relying on listeners to perform appropriate recovery.
protected  voidstopSharedConnection()
     This implementations proceeds even after an exception thrown from Connection.stop(), relying on listeners to perform appropriate recovery after a restart.
protected  voidvalidateConfiguration()
    

Field Detail
CACHE_CONNECTION
final public static int CACHE_CONNECTION(Code)
Constant that indicates to cache a shared JMS Connection.
See Also:   DefaultMessageListenerContainer.setCacheLevel



CACHE_CONSUMER
final public static int CACHE_CONSUMER(Code)
Constant that indicates to cache a shared JMS Connection and a JMS Session for each listener thread, as well as a JMS MessageConsumer for each listener thread.
See Also:   DefaultMessageListenerContainer.setCacheLevel



CACHE_NONE
final public static int CACHE_NONE(Code)
Constant that indicates to cache no JMS resources at all.
See Also:   DefaultMessageListenerContainer.setCacheLevel



CACHE_SESSION
final public static int CACHE_SESSION(Code)
Constant that indicates to cache a shared JMS Connection and a JMS Session for each listener thread.
See Also:   DefaultMessageListenerContainer.setCacheLevel



DEFAULT_RECOVERY_INTERVAL
final public static long DEFAULT_RECOVERY_INTERVAL(Code)
The default recovery interval: 5000 ms = 5 seconds.



DEFAULT_THREAD_NAME_PREFIX
final public static String DEFAULT_THREAD_NAME_PREFIX(Code)
Default thread name prefix: "DefaultMessageListenerContainer-".





Method Detail
createDefaultTaskExecutor
protected TaskExecutor createDefaultTaskExecutor()(Code)
Create a default TaskExecutor. Called if no explicit TaskExecutor has been specified.

The default implementation builds a org.springframework.core.task.SimpleAsyncTaskExecutor with the specified bean name (or the class name, if no bean name specified) as thread name prefix.
See Also:   org.springframework.core.task.SimpleAsyncTaskExecutor.SimpleAsyncTaskExecutor(String)




doInitialize
protected void doInitialize() throws JMSException(Code)
Creates the specified number of concurrent consumers, in the form of a JMS Session plus associated MessageConsumer running in a separate thread.
See Also:   DefaultMessageListenerContainer.scheduleNewInvoker
See Also:   DefaultMessageListenerContainer.setTaskExecutor



doRescheduleTask
protected void doRescheduleTask(Object task)(Code)
Re-executes the given task via this listener container's TaskExecutor.
See Also:   DefaultMessageListenerContainer.setTaskExecutor



doShutdown
protected void doShutdown() throws JMSException(Code)
Destroy the registered JMS Sessions and associated MessageConsumers.



establishSharedConnection
protected void establishSharedConnection()(Code)
Overridden to accept a failure in the initial setup - leaving it up to the asynchronous invokers to establish the shared Connection on first access.
See Also:   DefaultMessageListenerContainer.refreshConnectionUntilSuccessful()



getActiveConsumerCount
final public int getActiveConsumerCount()(Code)
Return the number of currently active consumers.

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).
See Also:   DefaultMessageListenerContainer.getConcurrentConsumers()
See Also:   DefaultMessageListenerContainer.getMaxConcurrentConsumers()
See Also:   DefaultMessageListenerContainer.getActiveConsumerCount()




getCacheLevel
public int getCacheLevel()(Code)
Return the level of caching that this listener container is allowed to apply.



getConcurrentConsumers
final public int getConcurrentConsumers()(Code)
Return the "concurrentConsumer" setting.

This returns the currently configured "concurrentConsumers" value; the number of currently scheduled/active consumers might differ.
See Also:   DefaultMessageListenerContainer.getScheduledConsumerCount()
See Also:   DefaultMessageListenerContainer.getActiveConsumerCount()




getIdleTaskExecutionLimit
public int getIdleTaskExecutionLimit()(Code)
Return the limit for idle executions of a receive task.



getMaxConcurrentConsumers
final public int getMaxConcurrentConsumers()(Code)
Return the "maxConcurrentConsumer" setting.

This returns the currently configured "maxConcurrentConsumers" value; the number of currently scheduled/active consumers might differ.
See Also:   DefaultMessageListenerContainer.getScheduledConsumerCount()
See Also:   DefaultMessageListenerContainer.getActiveConsumerCount()




getMaxMessagesPerTask
public int getMaxMessagesPerTask()(Code)
Return the maximum number of messages to process in one task.



getScheduledConsumerCount
final public int getScheduledConsumerCount()(Code)
Return the number of currently scheduled consumers.

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).
See Also:   DefaultMessageListenerContainer.getConcurrentConsumers()
See Also:   DefaultMessageListenerContainer.getMaxConcurrentConsumers()
See Also:   DefaultMessageListenerContainer.getActiveConsumerCount()




handleListenerSetupFailure
protected void handleListenerSetupFailure(Throwable ex, boolean alreadyRecovered)(Code)
Handle the given exception that arose during setup of a listener. Called for every such exception in every concurrent listener.

The default implementation logs the exception at error level if not recovered yet, and at debug level if already recovered. Can be overridden in subclasses.
Parameters:
  ex - the exception to handle
Parameters:
  alreadyRecovered - whether a previously executing listeneralready recovered from the present listener setup failure(this usually indicates a follow-up failure than be ignoredother than for debug log purposes)
See Also:   DefaultMessageListenerContainer.recoverAfterListenerSetupFailure()




initialize
public void initialize()(Code)



messageReceived
protected void messageReceived(Message message, Session session)(Code)



recoverAfterListenerSetupFailure
protected void recoverAfterListenerSetupFailure()(Code)
Recover this listener container after a listener failed to set itself up, for example reestablishing the underlying Connection.

The default implementation delegates to DefaultMessageListenerContainer's recovery-capable DefaultMessageListenerContainer.refreshConnectionUntilSuccessful() method, which will try to re-establish a Connection to the JMS provider both for the shared and the non-shared Connection case.
See Also:   DefaultMessageListenerContainer.refreshConnectionUntilSuccessful()
See Also:   DefaultMessageListenerContainer.refreshDestination()




refreshConnectionUntilSuccessful
protected void refreshConnectionUntilSuccessful()(Code)
Refresh the underlying Connection, not returning before an attempt has been successful. Called in case of a shared Connection as well as without shared Connection, so either needs to operate on the shared Connection or on a temporary Connection that just gets established for validation purposes.

The default implementation retries until it successfully established a Connection, for as long as this message listener container is active. Applies the specified recovery interval between retries.
See Also:   DefaultMessageListenerContainer.setRecoveryInterval




refreshDestination
protected void refreshDestination()(Code)
Refresh the JMS destination that this listener container operates on.

Called after listener setup failure, assuming that a cached Destination object might have become invalid (a typical case on WebLogic JMS).

The default implementation removes the destination from a DestinationResolver's cache, in case of a CachingDestinationResolver.
See Also:   DefaultMessageListenerContainer.setDestinationName
See Also:   org.springframework.jms.support.destination.CachingDestinationResolver




scheduleNewInvokerIfAppropriate
protected void scheduleNewInvokerIfAppropriate()(Code)
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.

Called once a message has been received, to scale up while processing the message in the invoker that originally received it.
See Also:   DefaultMessageListenerContainer.setTaskExecutor
See Also:   DefaultMessageListenerContainer.getMaxConcurrentConsumers()




setCacheLevel
public void setCacheLevel(int cacheLevel)(Code)
Specify the level of caching that this listener container is allowed to apply.

Default is CACHE_NONE if an external transaction manager has been specified (to reobtain all resources freshly within the scope of the external transaction), and CACHE_CONSUMER else (operating with local JMS resources).

Some J2EE servers only register their JMS resources with an ongoing XA transaction in case of a freshly obtained JMS Connection and Session, which is why this listener container does by default not cache any of those. However, if you want to optimize for a specific server, consider switching this setting to at least CACHE_CONNECTION or CACHE_SESSION even in conjunction with an external transaction manager.

Currently known servers that absolutely require CACHE_NONE for XA transaction processing: JBoss 4. For any others, consider raising the cache level.
See Also:   DefaultMessageListenerContainer.CACHE_NONE
See Also:   DefaultMessageListenerContainer.CACHE_CONNECTION
See Also:   DefaultMessageListenerContainer.CACHE_SESSION
See Also:   DefaultMessageListenerContainer.CACHE_CONSUMER
See Also:   DefaultMessageListenerContainer.setCacheLevelName
See Also:   DefaultMessageListenerContainer.setTransactionManager




setCacheLevelName
public void setCacheLevelName(String constantName) throws IllegalArgumentException(Code)
Specify the level of caching that this listener container is allowed to apply, in the form of the name of the corresponding constant: e.g. "CACHE_CONNECTION".
See Also:   DefaultMessageListenerContainer.setCacheLevel



setConcurrentConsumers
public void setConcurrentConsumers(int concurrentConsumers)(Code)
Specify the number of concurrent consumers to create. Default is 1.

Specifying a higher value for this setting will increase the standard level of scheduled concurrent consumers at runtime: This is effectively the minimum number of concurrent consumers which will be scheduled at any given time. This is a static setting; for dynamic scaling, consider specifying the "maxConcurrentConsumers" setting instead.

Raising the number of concurrent consumers is recommendable in order to scale the consumption of messages coming in from a queue. However, note that any ordering guarantees are lost once multiple consumers are registered. In general, stick with 1 consumer for low-volume queues.

Do not raise the number of concurrent consumers for a topic. This would lead to concurrent consumption of the same message, which is hardly ever desirable.

This setting can be modified at runtime, for example through JMX.
See Also:   DefaultMessageListenerContainer.setMaxConcurrentConsumers




setIdleTaskExecutionLimit
public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit)(Code)
Specify 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). Default is 1.

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 setting can be modified at runtime, for example through JMX.
See Also:   DefaultMessageListenerContainer.setMaxMessagesPerTask
See Also:   DefaultMessageListenerContainer.setReceiveTimeout




setMaxConcurrentConsumers
public void setMaxConcurrentConsumers(int maxConcurrentConsumers)(Code)
Specify the maximum number of concurrent consumers to create. Default is 1.

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.

Raising the number of concurrent consumers is recommendable in order to scale the consumption of messages coming in from a queue. However, note that any ordering guarantees are lost once multiple consumers are registered. In general, stick with 1 consumer for low-volume queues.

Do not raise the number of concurrent consumers for a topic. This would lead to concurrent consumption of the same message, which is hardly ever desirable.

This setting can be modified at runtime, for example through JMX.
See Also:   DefaultMessageListenerContainer.setConcurrentConsumers




setMaxMessagesPerTask
public void setMaxMessagesPerTask(int maxMessagesPerTask)(Code)
Specify the maximum number of messages to process in one task. More concretely, this limits the number of message reception attempts per task, which includes receive iterations that did not actually pick up a message until they hit their timeout (see "receiveTimeout" property).

Default is unlimited (-1) in case of a standard TaskExecutor, and 1 in case of a SchedulingTaskExecutor that indicates a preference for short-lived tasks. Specify a number of 10 to 100 messages to balance between extremely long-lived and extremely 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.
See Also:   DefaultMessageListenerContainer.setTaskExecutor
See Also:   DefaultMessageListenerContainer.setReceiveTimeout
See Also:   org.springframework.scheduling.SchedulingTaskExecutor.prefersShortLivedTasks




setRecoveryInterval
public void setRecoveryInterval(long recoveryInterval)(Code)
Specify the interval between recovery attempts, in milliseconds. The default is 5000 ms, that is, 5 seconds.
See Also:   DefaultMessageListenerContainer.handleListenerSetupFailure



setTaskExecutor
public void setTaskExecutor(TaskExecutor taskExecutor)(Code)
Set the Spring TaskExecutor to use for running the listener threads.

Default is a org.springframework.core.task.SimpleAsyncTaskExecutor , starting up a number of new threads, according to the specified number of concurrent consumers.

Specify an alternative TaskExecutor for integration with an existing thread pool. Note that this really only adds value if the threads are managed in a specific fashion, for example within a J2EE environment. A plain thread pool does not add much value, as this listener container will occupy a number of threads for its entire lifetime.
See Also:   DefaultMessageListenerContainer.setConcurrentConsumers
See Also:   org.springframework.core.task.SimpleAsyncTaskExecutor
See Also:   org.springframework.scheduling.commonj.WorkManagerTaskExecutor




sharedConnectionEnabled
final protected boolean sharedConnectionEnabled()(Code)
Use a shared JMS Connection depending on the "cacheLevel" setting.
See Also:   DefaultMessageListenerContainer.setCacheLevel
See Also:   DefaultMessageListenerContainer.CACHE_CONNECTION



sleepInbetweenRecoveryAttempts
protected void sleepInbetweenRecoveryAttempts()(Code)
Sleep according to the specified recovery interval. Called inbetween recovery attempts.



startSharedConnection
protected void startSharedConnection()(Code)
This implementations proceeds even after an exception thrown from Connection.start(), relying on listeners to perform appropriate recovery.



stopSharedConnection
protected void stopSharedConnection()(Code)
This implementations proceeds even after an exception thrown from Connection.stop(), relying on listeners to perform appropriate recovery after a restart.



validateConfiguration
protected void validateConfiguration()(Code)



Fields inherited from org.springframework.jms.listener.AbstractPollingMessageListenerContainer
final public static long DEFAULT_RECEIVE_TIMEOUT(Code)(Java Doc)

Methods inherited from org.springframework.jms.listener.AbstractPollingMessageListenerContainer
protected MessageConsumer createConsumer(Session session, Destination destination) throws JMSException(Code)(Java Doc)
protected MessageConsumer createListenerConsumer(Session session) throws JMSException(Code)(Java Doc)
protected boolean doReceiveAndExecute(Session session, MessageConsumer consumer, TransactionStatus status) throws JMSException(Code)(Java Doc)
protected Connection getConnection(JmsResourceHolder holder)(Code)(Java Doc)
protected Session getSession(JmsResourceHolder holder)(Code)(Java Doc)
final protected PlatformTransactionManager getTransactionManager()(Code)(Java Doc)
public void initialize()(Code)(Java Doc)
protected boolean isPubSubNoLocal()(Code)(Java Doc)
protected boolean isSessionLocallyTransacted(Session session)(Code)(Java Doc)
protected void messageReceived(Message message, Session session)(Code)(Java Doc)
protected boolean receiveAndExecute(Session session, MessageConsumer consumer) throws JMSException(Code)(Java Doc)
protected Message receiveMessage(MessageConsumer consumer) throws JMSException(Code)(Java Doc)
public void setPubSubNoLocal(boolean pubSubNoLocal)(Code)(Java Doc)
public void setReceiveTimeout(long receiveTimeout)(Code)(Java Doc)
public void setSessionTransacted(boolean sessionTransacted)(Code)(Java Doc)
public void setTransactionManager(PlatformTransactionManager transactionManager)(Code)(Java Doc)
public void setTransactionName(String transactionName)(Code)(Java Doc)
public void setTransactionTimeout(int transactionTimeout)(Code)(Java Doc)

Methods inherited from org.springframework.jms.listener.AbstractMessageListenerContainer
protected void checkMessageListener(Object messageListener)(Code)(Java Doc)
protected void commitIfNecessary(Session session, Message message) throws JMSException(Code)(Java Doc)
protected void doExecuteListener(Session session, Message message) throws JMSException(Code)(Java Doc)
protected void doInvokeListener(SessionAwareMessageListener listener, Session session, Message message) throws JMSException(Code)(Java Doc)
protected void doInvokeListener(MessageListener listener, Message message) throws JMSException(Code)(Java Doc)
protected void executeListener(Session session, Message message)(Code)(Java Doc)
public Destination getDestination()(Code)(Java Doc)
public String getDestinationName()(Code)(Java Doc)
public String getDurableSubscriptionName()(Code)(Java Doc)
public ExceptionListener getExceptionListener()(Code)(Java Doc)
public Object getMessageListener()(Code)(Java Doc)
public String getMessageSelector()(Code)(Java Doc)
protected void handleListenerException(Throwable ex)(Code)(Java Doc)
protected void invokeExceptionListener(JMSException ex)(Code)(Java Doc)
protected void invokeListener(Session session, Message message) throws JMSException(Code)(Java Doc)
public boolean isAcceptMessagesWhileStopping()(Code)(Java Doc)
public boolean isExposeListenerSession()(Code)(Java Doc)
protected boolean isSessionLocallyTransacted(Session session)(Code)(Java Doc)
public boolean isSubscriptionDurable()(Code)(Java Doc)
protected void rollbackIfNecessary(Session session) throws JMSException(Code)(Java Doc)
protected void rollbackOnExceptionIfNecessary(Session session, Throwable ex) throws JMSException(Code)(Java Doc)
public void setAcceptMessagesWhileStopping(boolean acceptMessagesWhileStopping)(Code)(Java Doc)
public void setDestination(Destination destination)(Code)(Java Doc)
public void setDestinationName(String destinationName)(Code)(Java Doc)
public void setDurableSubscriptionName(String durableSubscriptionName)(Code)(Java Doc)
public void setExceptionListener(ExceptionListener exceptionListener)(Code)(Java Doc)
public void setExposeListenerSession(boolean exposeListenerSession)(Code)(Java Doc)
public void setMessageListener(Object messageListener)(Code)(Java Doc)
public void setMessageSelector(String messageSelector)(Code)(Java Doc)
public void setSubscriptionDurable(boolean subscriptionDurable)(Code)(Java Doc)
protected void validateConfiguration()(Code)(Java Doc)

Methods inherited from org.springframework.jms.listener.AbstractJmsListeningContainer
public void afterPropertiesSet()(Code)(Java Doc)
protected Connection createSharedConnection() throws JMSException(Code)(Java Doc)
public void destroy()(Code)(Java Doc)
abstract protected void doInitialize() throws JMSException(Code)(Java Doc)
protected void doRescheduleTask(Object task)(Code)(Java Doc)
abstract protected void doShutdown() throws JMSException(Code)(Java Doc)
protected void doStart() throws JMSException(Code)(Java Doc)
protected void doStop() throws JMSException(Code)(Java Doc)
protected void establishSharedConnection() throws JMSException(Code)(Java Doc)
final protected String getBeanName()(Code)(Java Doc)
public String getClientId()(Code)(Java Doc)
final protected Connection getSharedConnection()(Code)(Java Doc)
public void initialize() throws JmsException(Code)(Java Doc)
final public boolean isActive()(Code)(Java Doc)
final public boolean isRunning()(Code)(Java Doc)
protected void prepareSharedConnection(Connection connection) throws JMSException(Code)(Java Doc)
final protected void refreshSharedConnection() throws JMSException(Code)(Java Doc)
final protected boolean rescheduleTaskIfNecessary(Object task)(Code)(Java Doc)
public void setAutoStartup(boolean autoStartup)(Code)(Java Doc)
public void setBeanName(String beanName)(Code)(Java Doc)
public void setClientId(String clientId)(Code)(Java Doc)
abstract protected boolean sharedConnectionEnabled()(Code)(Java Doc)
public void shutdown() throws JmsException(Code)(Java Doc)
public void start() throws JmsException(Code)(Java Doc)
protected void startSharedConnection() throws JMSException(Code)(Java Doc)
public void stop() throws JmsException(Code)(Java Doc)
protected void stopSharedConnection() throws JMSException(Code)(Java Doc)
protected void validateConfiguration()(Code)(Java Doc)
final protected void waitWhileNotRunning()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.