Package com.adaptris.core.jms
Class AggregatingQueueConsumer
- java.lang.Object
-
- com.adaptris.core.services.aggregator.AggregatingConsumerImpl<AggregatingJmsConsumeService>
-
- com.adaptris.core.jms.AggregatingQueueConsumer
-
- All Implemented Interfaces:
ComponentLifecycle
,AggregatingJmsConsumer
,AggregatingConsumer<AggregatingJmsConsumeService>
public class AggregatingQueueConsumer extends AggregatingConsumerImpl<AggregatingJmsConsumeService> implements AggregatingJmsConsumer
AggregatingConsumer
implementation that allows you to read a separate message(s) from a queue that need to be aggregated with the current message.- If the first message is received within the correct timeframe (based on
getTimeout()
), then additional messages are waited for based on the same timeout. Once the timeout expires then all the messages are aggregated using the configured aggregator. - If the first message is not received within the correct timeframe than an exception is thrown
- In the worst case scenario, then this consumer will take 2*Timeout to process a single message (e.g. you wait 59 seconds for the first message, and then subsequently wait for another minute if the Timeout is 1 minute).
In the adapter configuration file this class is aliased as aggregating-queue-consumer which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.aggregator.AggregatingConsumerImpl
log
-
-
Constructor Summary
Constructors Constructor Description AggregatingQueueConsumer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
aggregateMessages(AdaptrisMessage msg, AggregatingJmsConsumeService cfg)
Perform the aggregation.MessageTypeTranslator
getMessageTranslator()
TimeInterval
getTimeout()
void
setMessageTranslator(MessageTypeTranslator translator)
Set the jms message translator.void
setTimeout(TimeInterval t)
Set the timeout to wait for the correlated message.protected void
startMessageTranslator(JmsActorConfig cfg, AdaptrisMessageFactory factory)
-
Methods inherited from class com.adaptris.core.services.aggregator.AggregatingConsumerImpl
close, getEndpoint, getFilterExpression, getMessageAggregator, init, rethrowServiceException, setEndpoint, setFilterExpression, setMessageAggregator, start, start, stop, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
-
-
-
Method Detail
-
aggregateMessages
public void aggregateMessages(AdaptrisMessage msg, AggregatingJmsConsumeService cfg) throws ServiceException
Description copied from interface:AggregatingConsumer
Perform the aggregation.- Specified by:
aggregateMessages
in interfaceAggregatingConsumer<AggregatingJmsConsumeService>
- Parameters:
msg
- the current message being processed.cfg
- the service that relates to this consumer implementation.- Throws:
ServiceException
-
getTimeout
public TimeInterval getTimeout()
- Returns:
- the timeout
-
setTimeout
public void setTimeout(TimeInterval t)
Set the timeout to wait for the correlated message.- Parameters:
t
- the timeout to set, if not specified then it defaults to 30 seconds.
-
startMessageTranslator
protected void startMessageTranslator(JmsActorConfig cfg, AdaptrisMessageFactory factory) throws CoreException
- Throws:
CoreException
-
getMessageTranslator
public MessageTypeTranslator getMessageTranslator()
-
setMessageTranslator
public void setMessageTranslator(MessageTypeTranslator translator)
Set the jms message translator.- Parameters:
translator
- the translator.
-
-