Transmit events to the event bus.
More...
#include <EventTransmitter.h>
|
void | init (const std::string &hostName, const std::string &topicName, int port) |
|
Transmit events to the event bus.
Definition at line 60 of file EventTransmitter.h.
lsst::ctrl::events::EventTransmitter::EventTransmitter |
( |
const std::string & |
hostName, |
|
|
const std::string & |
topicName, |
|
|
int |
hostPort = EventBroker::DEFAULTHOSTPORT |
|
) |
| |
Transmits events to the specified host and topic.
- Parameters
-
hostName | the machine hosting the message broker |
topicName | the topic to transmit events to |
hostPort | the port number which the message broker is listening to |
- Exceptions
-
RuntimeError | if local socket can't be created |
RuntimeError | if connect to local socket fails |
RuntimeError | if connect to remote ActiveMQ host fails |
Definition at line 64 of file EventTransmitter.cc.
65 EventLibrary().initializeLibrary();
67 init(hostName, topicName, hostPort);
void init(const std::string &hostName, const std::string &topicName, int port)
lsst::ctrl::events::EventTransmitter::~EventTransmitter |
( |
| ) |
|
destructor
Definition at line 147 of file EventTransmitter.cc.
156 }
catch ( cms::CMSException& e ) {
167 }
catch ( cms::CMSException& e ) {
174 }
catch ( cms::CMSException& e ) {
182 }
catch ( cms::CMSException& e ) {
cms::Connection * _connection
cms::MessageProducer * _producer
activemq::commands::ActiveMQTopic * _topic
std::string lsst::ctrl::events::EventTransmitter::getTopicName |
( |
| ) |
|
get the topic name of this EventTransmitter
- Returns
- a std::string containing the topic name
Definition at line 143 of file EventTransmitter.cc.
void lsst::ctrl::events::EventTransmitter::init |
( |
const std::string & |
hostName, |
|
|
const std::string & |
topicName, |
|
|
int |
port |
|
) |
| |
|
private |
Definition at line 73 of file EventTransmitter.cc.
91 string brokerUri =
"tcp://"+hostName+
":"+ss.str()+
"?wireFormat=openwire&transport.useAsyncSend=true";
93 activemq::core::ActiveMQConnectionFactory* connectionFactory =
94 new activemq::core::ActiveMQConnectionFactory( brokerUri );
98 _connection = connectionFactory->createConnection();
100 delete connectionFactory;
102 catch (cms::CMSException& e) {
103 delete connectionFactory;
104 std::string msg(
"Failed to connect to broker: ");
105 msg += e.getMessage();
106 msg +=
" (is broker running?)";
107 throw LSST_EXCEPT(pexExceptions::RuntimeError, msg);
121 _producer->setDeliveryMode( cms::DeliveryMode::NON_PERSISTENT );
122 }
catch ( cms::CMSException& e ) {
123 throw LSST_EXCEPT(pexExceptions::RuntimeError, std::string(
"Trouble creating EventTransmitter: ") + e.getMessage());
cms::Connection * _connection
cms::MessageProducer * _producer
#define LSST_EXCEPT(type,...)
activemq::commands::ActiveMQTopic * _topic
void lsst::ctrl::events::EventTransmitter::publishEvent |
( |
Event & |
event | ) |
|
Publish an Event to this object's topic.
- Parameters
-
Definition at line 127 of file EventTransmitter.cc.
129 cms::TextMessage* message =
_session->createTextMessage();
131 event.marshall(message);
133 message->setStringProperty(
"TOPIC",
_topicName);
137 message->setLongProperty(
"PUBTIME", pubtime);
static DateTime now(void)
long long nsecs(Timescale scale=TAI) const
cms::MessageProducer * _producer
activemq::commands::ActiveMQTopic * _topic
std::string lsst::ctrl::events::EventTransmitter::_brokerUri |
|
private |
cms::Connection* lsst::ctrl::events::EventTransmitter::_connection |
|
private |
cms::Destination* lsst::ctrl::events::EventTransmitter::_destination |
|
private |
cms::MessageProducer* lsst::ctrl::events::EventTransmitter::_producer |
|
private |
cms::Session* lsst::ctrl::events::EventTransmitter::_session |
|
private |
activemq::commands::ActiveMQTopic* lsst::ctrl::events::EventTransmitter::_topic |
|
private |
std::string lsst::ctrl::events::EventTransmitter::_topicName |
|
private |
The documentation for this class was generated from the following files: