Package org.apache.storm.jms.bolt
Class JmsBolt
java.lang.Object
org.apache.storm.topology.base.BaseComponent
org.apache.storm.topology.base.BaseRichBolt
org.apache.storm.topology.base.BaseTickTupleAwareRichBolt
org.apache.storm.jms.bolt.JmsBolt
- All Implemented Interfaces:
Serializable
,IBolt
,IComponent
,IRichBolt
A JmsBolt receives
org.apache.storm.tuple.Tuple
objects from a Storm
topology and publishes JMS Messages to a destination (topic or queue).
To use a JmsBolt in a topology, the following must be supplied:
- A
JmsProvider
implementation. - A
JmsMessageProducer
implementation.
JmsProvider
provides the JMS javax.jms.ConnectionFactory
and javax.jms.Destination
objects requied to publish JMS messages.
The JmsBolt uses a JmsMessageProducer
to translate
org.apache.storm.tuple.Tuple
objects into
javax.jms.Message
objects for publishing.
Both JmsProvider and JmsMessageProducer must be set, or the bolt will fail upon deployment to a cluster.
The JmsBolt is typically an endpoint in a topology -- in other words it does not emit any tuples.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Releases JMS resources.void
declareOutputFields
(OutputFieldsDeclarer declarer) Declare the output schema for all the streams of this topology.void
prepare
(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) Initializes JMS resources.protected void
Consumes a tuple and sends a JMS message.void
setAutoAck
(boolean autoAck) Sets whether or not tuples should be acknowledged by this bolt.void
setJmsAcknowledgeMode
(int acknowledgeMode) Sets the JMS acknowledgement mode for JMS messages sent by this bolt.void
setJmsMessageProducer
(JmsMessageProducer producer) Set the JmsMessageProducer used to convert tuples into JMS messages.void
setJmsProvider
(JmsProvider provider) Set the JmsProvider used to connect to the JMS destination topic/queue.Methods inherited from class org.apache.storm.topology.base.BaseTickTupleAwareRichBolt
execute, onTickTuple
Methods inherited from class org.apache.storm.topology.base.BaseComponent
getComponentConfiguration
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.storm.topology.IComponent
getComponentConfiguration
-
Constructor Details
-
JmsBolt
public JmsBolt()
-
-
Method Details
-
setJmsProvider
Set the JmsProvider used to connect to the JMS destination topic/queue. -
setJmsMessageProducer
Set the JmsMessageProducer used to convert tuples into JMS messages. -
setJmsAcknowledgeMode
public void setJmsAcknowledgeMode(int acknowledgeMode) Sets the JMS acknowledgement mode for JMS messages sent by this bolt.Possible values:
- javax.jms.Session.AUTO_ACKNOWLEDGE
- javax.jms.Session.CLIENT_ACKNOWLEDGE
- javax.jms.Session.DUPS_OK_ACKNOWLEDGE
- Parameters:
acknowledgeMode
- (constant defined in javax.jms.Session)
-
setAutoAck
public void setAutoAck(boolean autoAck) Sets whether or not tuples should be acknowledged by this bolt. -
process
Consumes a tuple and sends a JMS message.If autoAck is true, the tuple will be acknowledged after the message is sent.
If JMS sending fails, the tuple will be failed.
- Specified by:
process
in classBaseTickTupleAwareRichBolt
- Parameters:
input
- The input tuple to be processed.
-
cleanup
public void cleanup()Releases JMS resources.- Specified by:
cleanup
in interfaceIBolt
- Overrides:
cleanup
in classBaseRichBolt
-
declareOutputFields
Description copied from interface:IComponent
Declare the output schema for all the streams of this topology.- Parameters:
declarer
- this is used to declare output stream ids, output fields, and whether or not each output stream is a direct stream
-
prepare
public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) Initializes JMS resources.- Parameters:
topoConf
- The Storm configuration for this bolt. This is the configuration provided to the topology merged in with cluster configuration on this machine.context
- This object can be used to get information about this task's place within the topology, including the task id and component id of this task, input and output information, etc.collector
- The collector is used to emit tuples from this bolt. Tuples can be emitted at any time, including the prepare and cleanup methods. The collector is thread-safe and should be saved as an instance variable of this bolt object.
-