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 Object
implements ItemReader<T>, org.springframework.beans.factory.InitializingBean
An
The implementation is thread-safe after its properties are set (normal singleton behavior).
ItemReader for JMS using a JmsTemplate. The template should have a
default destination, which will be used to provide items in read().The implementation is thread-safe after its properties are set (normal singleton behavior).
- Author:
- Dave Syer, Mahmoud Ben Hassine
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.jms.core.JmsOperationsprotected org.apache.commons.logging.Log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidread()Reads a piece of input data and advance to the next one.voidsetItemType(Class<? extends T> itemType) Set the expected type of incoming message payloads.voidsetJmsTemplate(org.springframework.jms.core.JmsOperations jmsTemplate) Setter for JMS template.
-
Field Details
-
logger
protected org.apache.commons.logging.Log logger -
itemType
-
jmsTemplate
protected org.springframework.jms.core.JmsOperations jmsTemplate
-
-
Constructor Details
-
JmsItemReader
public JmsItemReader()
-
-
Method Details
-
setJmsTemplate
public void setJmsTemplate(org.springframework.jms.core.JmsOperations jmsTemplate) Setter for JMS template.- Parameters:
jmsTemplate- aJmsOperationsinstance
-
setItemType
Set the expected type of incoming message payloads. Set this toMessageto receive the raw underlying message.- Parameters:
itemType- the java class of the items to be delivered. Typically the same as the class parameter- Throws:
IllegalStateException- if the message payload is of the wrong type.
-
read
Description copied from interface:ItemReaderReads a piece of input data and advance to the next one. Implementations must returnnullat 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:
readin interfaceItemReader<T>- Returns:
- T the item to be processed or
nullif the data source is exhausted
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-