public class JmsBolt extends BaseTickTupleAwareRichBolt
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:
JmsProvider
implementation.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.
Constructor and Description |
---|
JmsBolt() |
Modifier and Type | Method and Description |
---|---|
void |
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 |
process(Tuple input)
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
|
execute, onTickTuple
getComponentConfiguration
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getComponentConfiguration
public void setJmsProvider(JmsProvider provider)
Set the JmsProvider used to connect to the JMS destination topic/queue
provider
- public void setJmsMessageProducer(JmsMessageProducer producer)
Set the JmsMessageProducer used to convert tuples into JMS messages.
producer
- public void setJmsAcknowledgeMode(int acknowledgeMode)
Sets the JMS acknowledgement mode for JMS messages sent by this bolt.
Possible values:
acknowledgeMode
- (constant defined in javax.jms.Session)public void setAutoAck(boolean autoAck)
Sets whether or not tuples should be acknowledged by this bolt.
autoAck
- protected void process(Tuple input)
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.
process
in class BaseTickTupleAwareRichBolt
input
- The input tuple to be processed.public void cleanup()
Releases JMS resources.
cleanup
in interface IBolt
cleanup
in class BaseRichBolt
public void declareOutputFields(OutputFieldsDeclarer declarer)
IComponent
Declare the output schema for all the streams of this topology.
declarer
- this is used to declare output stream ids, output fields, and whether or not each output stream is a direct streampublic void prepare(Map<String,Object> topoConf, TopologyContext context, OutputCollector collector)
Initializes JMS resources.
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.Copyright © 2019 The Apache Software Foundation. All rights reserved.