Java Doc for AbstractPollingMessageListenerContainer.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

All known Subclasses:   org.springframework.jms.listener.DefaultMessageListenerContainer,
AbstractPollingMessageListenerContainer
abstract public class AbstractPollingMessageListenerContainer extends AbstractMessageListenerContainer implements BeanNameAware(Code)
Base class for listener container implementations which are based on polling. Provides support for listener handling based on javax.jms.MessageConsumer , optionally participating in externally managed transactions.

This listener container variant is built for repeated polling attempts, each invoking the AbstractPollingMessageListenerContainer.receiveAndExecute method. The MessageConsumer used may be reobtained fo reach attempt or cached inbetween attempts; this is up to the concrete implementation. The receive timeout for each attempt can be configured through the AbstractPollingMessageListenerContainer.setReceiveTimeout "receiveTimeout" property.

The underlying mechanism is based on standard JMS MessageConsumer handling, which is perfectly compatible with both native JMS and JMS in a J2EE environment. Neither the JMS MessageConsumer.setMessageListener facility nor the JMS ServerSessionPool facility is required. A further advantage of this approach is full control over the listening process, allowing for custom scaling and throttling and of concurrent message processing (which is up to concrete subclasses).

Message reception and listener execution can automatically be wrapped in transactions through passing a Spring org.springframework.transaction.PlatformTransactionManager into the AbstractPollingMessageListenerContainer.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).

This base class does not assume any specific mechanism for asynchronous execution of polling invokers. Check out DefaultMessageListenerContainer for a concrete implementation which is based on Spring's org.springframework.core.task.TaskExecutor abstraction, including dynamic scaling of concurrent consumers and automatic self recovery.
author:
   Juergen Hoeller
since:
   2.0.3
See Also:   AbstractPollingMessageListenerContainer.createListenerConsumer(javax.jms.Session)
See Also:   AbstractPollingMessageListenerContainer.receiveAndExecute(javax.jms.Session,javax.jms.MessageConsumer)
See Also:   AbstractPollingMessageListenerContainer.setTransactionManager



Field Summary
final public static  longDEFAULT_RECEIVE_TIMEOUT
     The default receive timeout: 1000 ms = 1 second.


Method Summary
protected  MessageConsumercreateConsumer(Session session, Destination destination)
     Create a JMS MessageConsumer for the given Session and Destination.
protected  MessageConsumercreateListenerConsumer(Session session)
     Create a MessageConsumer for the given JMS Session, registering a MessageListener for the specified listener.
protected  booleandoReceiveAndExecute(Session session, MessageConsumer consumer, TransactionStatus status)
     Actually execute the listener for a message received from the given consumer, fetching all requires resources and invoking the listener.
protected  ConnectiongetConnection(JmsResourceHolder holder)
     Fetch an appropriate Connection from the given JmsResourceHolder.
protected  SessiongetSession(JmsResourceHolder holder)
     Fetch an appropriate Session from the given JmsResourceHolder.
final protected  PlatformTransactionManagergetTransactionManager()
     Return the Spring PlatformTransactionManager to use for transactional wrapping of message reception plus listener execution.
public  voidinitialize()
    
protected  booleanisPubSubNoLocal()
     Return whether to inhibit the delivery of messages published by its own connection.
protected  booleanisSessionLocallyTransacted(Session session)
     This implementation checks whether the Session is externally synchronized.
protected  voidmessageReceived(Message message, Session session)
     Template method that gets called right when a new message has been received, before attempting to process it.
protected  booleanreceiveAndExecute(Session session, MessageConsumer consumer)
     Execute the listener for a message received from the given consumer, wrapping the entire operation in an external transaction if demanded.
protected  MessagereceiveMessage(MessageConsumer consumer)
     Receive a message from the given consumer.
public  voidsetPubSubNoLocal(boolean pubSubNoLocal)
     Set whether to inhibit the delivery of messages published by its own connection.
public  voidsetReceiveTimeout(long receiveTimeout)
     Set the timeout to use for receive calls, in milliseconds. The default is 1000 ms, that is, 1 second.

NOTE: This value needs to be smaller than the transaction timeout used by the transaction manager (in the appropriate unit, of course).

public  voidsetSessionTransacted(boolean sessionTransacted)
    
public  voidsetTransactionManager(PlatformTransactionManager transactionManager)
     Specify the Spring org.springframework.transaction.PlatformTransactionManager to use for transactional wrapping of message reception plus listener execution.

Default is none, not performing any transactional wrapping. If specified, this will usually be a Spring org.springframework.transaction.jta.JtaTransactionManager or one of its subclasses, in combination with a JTA-aware ConnectionFactory that this message listener container obtains its Connections from.

Note: Consider the use of local JMS transactions instead. Simply switch the AbstractPollingMessageListenerContainer.setSessionTransacted "sessionTransacted" flag to "true" in order to use a locally transacted JMS Session for the entire receive processing, including any Session operations performed by a SessionAwareMessageListener (e.g.

public  voidsetTransactionName(String transactionName)
     Specify the transaction name to use for transactional wrapping.
public  voidsetTransactionTimeout(int transactionTimeout)
     Specify the transaction timeout to use for transactional wrapping, in seconds.

Field Detail
DEFAULT_RECEIVE_TIMEOUT
final public static long DEFAULT_RECEIVE_TIMEOUT(Code)
The default receive timeout: 1000 ms = 1 second.





Method Detail
createConsumer
protected MessageConsumer createConsumer(Session session, Destination destination) throws JMSException(Code)
Create a JMS MessageConsumer for the given Session and Destination.

This implementation uses JMS 1.1 API.
Parameters:
  session - the JMS Session to create a MessageConsumer for
Parameters:
  destination - the JMS Destination to create a MessageConsumer for the new JMS MessageConsumer
throws:
  javax.jms.JMSException - if thrown by JMS API methods




createListenerConsumer
protected MessageConsumer createListenerConsumer(Session session) throws JMSException(Code)
Create a MessageConsumer for the given JMS Session, registering a MessageListener for the specified listener.
Parameters:
  session - the JMS Session to work on the MessageConsumer
throws:
  javax.jms.JMSException - if thrown by JMS methods
See Also:   AbstractPollingMessageListenerContainer.receiveAndExecute



doReceiveAndExecute
protected boolean doReceiveAndExecute(Session session, MessageConsumer consumer, TransactionStatus status) throws JMSException(Code)
Actually execute the listener for a message received from the given consumer, fetching all requires resources and invoking the listener.
Parameters:
  session - the JMS Session to work on
Parameters:
  consumer - the MessageConsumer to work on
Parameters:
  status - the TransactionStatus (may be null) whether a message has been received
throws:
  JMSException - if thrown by JMS methods
See Also:   AbstractPollingMessageListenerContainer.doExecuteListener(javax.jms.Session,javax.jms.Message)



getConnection
protected Connection getConnection(JmsResourceHolder holder)(Code)
Fetch an appropriate Connection from the given JmsResourceHolder.

This implementation accepts any JMS 1.1 Connection.
Parameters:
  holder - the JmsResourceHolder an appropriate Connection fetched from the holder,or null if none found




getSession
protected Session getSession(JmsResourceHolder holder)(Code)
Fetch an appropriate Session from the given JmsResourceHolder.

This implementation accepts any JMS 1.1 Session.
Parameters:
  holder - the JmsResourceHolder an appropriate Session fetched from the holder,or null if none found




getTransactionManager
final protected PlatformTransactionManager getTransactionManager()(Code)
Return the Spring PlatformTransactionManager to use for transactional wrapping of message reception plus listener execution.



initialize
public void initialize()(Code)



isPubSubNoLocal
protected boolean isPubSubNoLocal()(Code)
Return whether to inhibit the delivery of messages published by its own connection.



isSessionLocallyTransacted
protected boolean isSessionLocallyTransacted(Session session)(Code)
This implementation checks whether the Session is externally synchronized. In this case, the Session is not locally transacted, despite the listener container's "sessionTransacted" flag being set to "true".
See Also:   org.springframework.jms.connection.ConnectionFactoryUtils.isSessionTransactional



messageReceived
protected void messageReceived(Message message, Session session)(Code)
Template method that gets called right when a new message has been received, before attempting to process it. Allows subclasses to react to the event of an actual incoming message, for example adapting their consumer count.
Parameters:
  message - the received message
Parameters:
  session - the receiving JMS Session



receiveAndExecute
protected boolean receiveAndExecute(Session session, MessageConsumer consumer) throws JMSException(Code)
Execute the listener for a message received from the given consumer, wrapping the entire operation in an external transaction if demanded.
Parameters:
  session - the JMS Session to work on
Parameters:
  consumer - the MessageConsumer to work on whether a message has been received
throws:
  JMSException - if thrown by JMS methods
See Also:   AbstractPollingMessageListenerContainer.doReceiveAndExecute



receiveMessage
protected Message receiveMessage(MessageConsumer consumer) throws JMSException(Code)
Receive a message from the given consumer.
Parameters:
  consumer - the MessageConsumer to use the Message, or null if none
throws:
  JMSException - if thrown by JMS methods



setPubSubNoLocal
public void setPubSubNoLocal(boolean pubSubNoLocal)(Code)
Set whether to inhibit the delivery of messages published by its own connection. Default is "false".
See Also:   javax.jms.TopicSession.createSubscriber(javax.jms.TopicStringboolean)



setReceiveTimeout
public void setReceiveTimeout(long receiveTimeout)(Code)
Set the timeout to use for receive calls, in milliseconds. The default is 1000 ms, that is, 1 second.

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.
See Also:   javax.jms.MessageConsumer.receive(long)
See Also:   javax.jms.MessageConsumer.receive
See Also:   AbstractPollingMessageListenerContainer.setTransactionTimeout




setSessionTransacted
public void setSessionTransacted(boolean sessionTransacted)(Code)



setTransactionManager
public void setTransactionManager(PlatformTransactionManager transactionManager)(Code)
Specify the Spring org.springframework.transaction.PlatformTransactionManager to use for transactional wrapping of message reception plus listener execution.

Default is none, not performing any transactional wrapping. If specified, this will usually be a Spring org.springframework.transaction.jta.JtaTransactionManager or one of its subclasses, in combination with a JTA-aware ConnectionFactory that this message listener container obtains its Connections from.

Note: Consider the use of local JMS transactions instead. Simply switch the AbstractPollingMessageListenerContainer.setSessionTransacted "sessionTransacted" flag to "true" in order to use a locally transacted JMS Session for the entire receive processing, including any Session operations performed by a SessionAwareMessageListener (e.g. sending a response message). Alternatively, a org.springframework.jms.connection.JmsTransactionManager may be used for fully synchronized Spring transactions based on local JMS transactions. Check AbstractMessageListenerContainer 's javadoc for a discussion of transaction choices and message redelivery scenarios.
See Also:   org.springframework.transaction.jta.JtaTransactionManager
See Also:   org.springframework.jms.connection.JmsTransactionManager




setTransactionName
public void setTransactionName(String transactionName)(Code)
Specify the transaction name to use for transactional wrapping. Default is the bean name of this listener container, if any.
See Also:   org.springframework.transaction.TransactionDefinition.getName



setTransactionTimeout
public void setTransactionTimeout(int transactionTimeout)(Code)
Specify the transaction timeout to use for transactional wrapping, in seconds. Default is none, using the transaction manager's default timeout.
See Also:   org.springframework.transaction.TransactionDefinition.getTimeout
See Also:   AbstractPollingMessageListenerContainer.setReceiveTimeout



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.