Class JmsItemReader<T>
- java.lang.Object
- org.springframework.batch.item.jms.JmsItemReader<T>
- All Implemented Interfaces:
ItemReader<T>
,org.springframework.beans.factory.InitializingBean
public class JmsItemReader<T> extends java.lang.Object implements ItemReader<T>, org.springframework.beans.factory.InitializingBean
AnItemReader
for JMS using aJmsTemplate
. The template should have a default destination, which will be used to provide items inread()
.
The implementation is thread-safe after its properties are set (normal singleton behavior).- Author:
- Dave Syer
Field Summary
Fields Modifier and Type Field Description protected java.lang.Class<? extends T>
itemType
protected org.springframework.jms.core.JmsOperations
jmsTemplate
protected org.apache.commons.logging.Log
logger
Constructor Summary
Constructors Constructor Description JmsItemReader()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
T
read()
Reads a piece of input data and advance to the next one.void
setItemType(java.lang.Class<? extends T> itemType)
Set the expected type of incoming message payloads.void
setJmsTemplate(org.springframework.jms.core.JmsOperations jmsTemplate)
Setter for JMS template.
Field Detail
logger
protected org.apache.commons.logging.Log logger
itemType
protected java.lang.Class<? extends T> itemType
jmsTemplate
protected org.springframework.jms.core.JmsOperations jmsTemplate
Method Detail
setJmsTemplate
public void setJmsTemplate(org.springframework.jms.core.JmsOperations jmsTemplate)
Setter for JMS template.- Parameters:
jmsTemplate
- aJmsOperations
instance
setItemType
public void setItemType(java.lang.Class<? extends T> itemType)
Set the expected type of incoming message payloads. Set this toMessage
to receive the raw underlying message.- Parameters:
itemType
- the java class of the items to be delivered. Typically the same as the class parameter- Throws:
java.lang.IllegalStateException
- if the message payload is of the wrong type.
read
public T read()
Description copied from interface:ItemReader
Reads a piece of input data and advance to the next one. Implementations must returnnull
at the end of the input data set. In a transactional setting, caller might get the same item twice from successive calls (or otherwise), if the first call was in a transaction that rolled back.- Specified by:
read
in interfaceItemReader<T>
- Returns:
- T the item to be processed or
null
if the data source is exhausted
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
java.lang.Exception