public class JmsSpout extends BaseRichSpout implements javax.jms.MessageListener
A Storm Spout implementation that listens to a JMS topic or queue and outputs tuples based on the messages it receives.
JmsSpout instances rely on JmsProducer implementations to obtain the JMS ConnectionFactory and Destination objects necessary to connect to a JMS topic/queue.
When a JmsSpout receives a JMS message, it delegates to an internal JmsTupleProducer instance to create a Storm tuple from the incoming message.
Typically, developers will supply a custom JmsTupleProducer implementation appropriate for the expected message content.
| Modifier and Type | Field and Description |
|---|---|
Serializable |
recoveryMutex |
| Constructor and Description |
|---|
JmsSpout() |
| Modifier and Type | Method and Description |
|---|---|
void |
ack(Object msgId) |
void |
close() |
void |
declareOutputFields(OutputFieldsDeclarer declarer) |
void |
fail(Object msgId) |
int |
getJmsAcknowledgeMode()
Returns the JMS Session acknowledgement mode for the JMS seesion associated with this spout.
|
protected javax.jms.Session |
getSession() |
boolean |
hasFailures()
Returns
true if the spout has received failures from which it has not yet recovered. |
boolean |
isDistributed() |
void |
nextTuple() |
void |
onMessage(javax.jms.Message msg)
javax.jms.MessageListener implementation. |
void |
open(Map conf,
TopologyContext context,
SpoutOutputCollector collector)
ISpout implementation. |
protected void |
recovered() |
void |
setDistributed(boolean distributed)
Sets the “distributed” mode of this spout.
|
void |
setJmsAcknowledgeMode(int mode)
Sets the JMS Session acknowledgement mode for the JMS seesion associated with this spout.
|
void |
setJmsProvider(JmsProvider provider)
Set the
JmsProvider implementation that this Spout will use to connect to a JMS javax.jms.Desination |
void |
setJmsTupleProducer(JmsTupleProducer producer)
Set the
JmsTupleProducer implementation that will convert javax.jms.Message object to org.apache.storm.tuple.Values objects to be emitted. |
void |
setRecoveryPeriod(long period)
Sets the periodicity of the timer task that checks for failures and recovers the JMS session.
|
activate, deactivategetComponentConfigurationclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetComponentConfigurationpublic final Serializable recoveryMutex
public void setJmsAcknowledgeMode(int mode)
Sets the JMS Session acknowledgement mode for the JMS seesion associated with this spout.
Possible values:
mode - JMS Session Acknowledgement modeIllegalArgumentException - if the mode is not recognized.public int getJmsAcknowledgeMode()
Returns the JMS Session acknowledgement mode for the JMS seesion associated with this spout.
public void setJmsProvider(JmsProvider provider)
Set the JmsProvider implementation that this Spout will use to connect to a JMS javax.jms.Desination
provider - public void setJmsTupleProducer(JmsTupleProducer producer)
Set the JmsTupleProducer implementation that will convert javax.jms.Message object to org.apache.storm.tuple.Values objects to be emitted.
producer - public void onMessage(javax.jms.Message msg)
javax.jms.MessageListener implementation.
Stored the JMS message in an internal queue for processing by the nextTuple() method.
onMessage in interface javax.jms.MessageListenerpublic void open(Map conf, TopologyContext context, SpoutOutputCollector collector)
ISpout implementation.
Connects the JMS spout to the configured JMS destination topic/queue.
public void close()
close in interface ISpoutclose in class BaseRichSpoutpublic void ack(Object msgId)
ack in interface ISpoutack in class BaseRichSpoutpublic void fail(Object msgId)
fail in interface ISpoutfail in class BaseRichSpoutpublic void declareOutputFields(OutputFieldsDeclarer declarer)
declareOutputFields in interface IComponentpublic boolean hasFailures()
Returns true if the spout has received failures from which it has not yet recovered.
protected void recovered()
public void setRecoveryPeriod(long period)
Sets the periodicity of the timer task that checks for failures and recovers the JMS session.
period - public boolean isDistributed()
public void setDistributed(boolean distributed)
Sets the “distributed” mode of this spout.
If true multiple instances of this spout may be created across the cluster (depending on the “parallelism_hint” in the topology configuration).
Setting this value to false essentially means this spout will run as a singleton within the cluster (“parallelism_hint” will be ignored).
In general, this should be set to false if the underlying JMS destination is a topic, and true if it is a JMS queue.
distributed - protected javax.jms.Session getSession()
Copyright © 2018 The Apache Software Foundation. All Rights Reserved.