@Named @Dependent public class JmsItemReader extends JmsItemReaderWriterBase implements javax.batch.api.chunk.ItemReader
javax.batch.api.chunk.ItemReader
that reads data items from a JMS destination. It can
reads the following JMS message types:
ObjectMessage
: the object contained in the message is retrieved and returned;
MapMessage
: a new java.util.Map
is created, populated with the data contained in the
incoming MapMessage
, and returned;
TextMessage
: the text contained in the message is retrieved and returned;
Message
: but not one of its subtype, null is returned.
If beanType
is set to javax.jms.Message
, readItem()
returns the incoming JMS message as is.
Otherwise, readItem()
method determines the actual data type based on the message type.
This reader ends when any of the following occurs:
receiveTimeout
(in milliseconds) has elapsed when trying to receive a message from the destination;
null
body is retrieved from a message;
Message
, but not one of its subtype.
JmsItemWriter
,
JmsItemReaderWriterBase
Modifier and Type | Field and Description |
---|---|
protected Class |
beanType
The fully-qualified class name of the data item to be returned from
readItem() method. |
protected javax.jms.MessageConsumer |
consumer |
protected String |
messageSelector
Only messages with properties matching the message selector expression are delivered.
|
protected long |
receiveTimeout
The number of milliseconds a JMS
MessageConsumer blocks until a message arrives. |
connection, connectionFactory, connectionFactoryInstance, connectionFactoryLookupName, destination, destinationInstance, destinationLookupName, session, sessionMode
NEW_LINE, resource, skipBeanValidation
Constructor and Description |
---|
JmsItemReader() |
Modifier and Type | Method and Description |
---|---|
Serializable |
checkpointInfo() |
void |
close() |
void |
open(Serializable checkpoint) |
Object |
readItem() |
getInputStream, getOutputStream, getValidator, validate
@Inject protected long receiveTimeout
MessageConsumer
blocks until a message arrives. Optional property, and
defaults to 0, which means it blocks indefinitely.@Inject protected String messageSelector
Session.createConsumer(javax.jms.Destination, java.lang.String)
@Inject protected Class beanType
readItem()
method. Optional
property and defaults to null. If it is specified, its valid value is:
javax.jms.Message
: an incoming JMS message is returned as is.
When this property is not specified, readItem()
method returns an object whose actual type is
determined by the incoming JMS message type.
protected javax.jms.MessageConsumer consumer
public void open(Serializable checkpoint) throws Exception
open
in interface javax.batch.api.chunk.ItemReader
open
in class JmsItemReaderWriterBase
Exception
public Object readItem() throws Exception
readItem
in interface javax.batch.api.chunk.ItemReader
Exception
public Serializable checkpointInfo() throws Exception
checkpointInfo
in interface javax.batch.api.chunk.ItemReader
Exception
public void close()
close
in interface javax.batch.api.chunk.ItemReader
close
in class JmsItemReaderWriterBase
Copyright © 2018 JBoss by Red Hat. All rights reserved.