|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.item.support.AbstractItemReader org.springframework.batch.item.jms.JmsItemReader
public class JmsItemReader
An ItemReader
for JMS using a JmsTemplate
. The template
should have a default destination, which will be used to provide items in
read()
. If a recovery step is needed, set the error destination and
the item will be sent there if processing fails in a stateful retry.
The implementation is thread safe after its properties are set (normal
singleton behaviour).
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
---|---|
JmsItemReader()
|
Method Summary | |
---|---|
Object |
getKey(Object item)
If the message is a Message then returns the JMS message ID. |
boolean |
isNew(Object item)
If the item is a message, check the JMS re-delivered flag, otherwise return false to be on the safe side. |
Object |
read()
Reads a piece of input data and advance to the next one. |
Object |
recover(Object item,
Throwable cause)
Send the message back to the provider using the specified error destination property of this reader. |
void |
setErrorDestination(Destination errorDestination)
Set the error destination. |
void |
setErrorDestinationName(String errorDestinationName)
Set the error destination by name. |
void |
setItemType(Class itemType)
Set the expected type of incoming message payloads. |
void |
setJmsTemplate(JmsOperations jmsTemplate)
Setter for jms template. |
Methods inherited from class org.springframework.batch.item.support.AbstractItemReader |
---|
mark, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.apache.commons.logging.Log logger
Constructor Detail |
---|
public JmsItemReader()
Method Detail |
---|
public void setErrorDestination(Destination errorDestination)
errorDestination
- a JMS Destinationpublic void setErrorDestinationName(String errorDestinationName)
errorDestinationName
- the name of a JMS Destinationpublic void setJmsTemplate(JmsOperations jmsTemplate)
jmsTemplate
- a JmsOperations
instancepublic void setItemType(Class itemType)
Message
to receive the raw underlying message.
itemType
- the java class of the items to be delivered.
IllegalStateException
- if the message payload is of the wrong
type.public Object read()
ItemReader
null
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.
read
in interface ItemReader
public Object recover(Object item, Throwable cause)
recover
in interface ItemRecoverer
item
- the item that failed.cause
- the cause of the failure that led to this recovery.
ItemRecoverer.recover(Object,
Throwable)
public Object getKey(Object item)
Message
then returns the JMS message ID.
Otherwise just delegate to parent class.
getKey
in interface ItemKeyGenerator
item
- the current item.
UnexpectedInputException
- if the JMS id cannot be determined from
a JMS MessageItemKeyGenerator.getKey(java.lang.Object)
public boolean isNew(Object item)
isNew
in interface NewItemIdentifier
item
- the current item.
NewItemIdentifier.isNew(java.lang.Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |