Receive events from the event bus.
More...
#include <EventReceiver.h>
|
void | init (const std::string &hostName, const std::string &topicName, const std::string &selector, int hostPort) |
|
Receive events from the event bus.
Definition at line 59 of file EventReceiver.h.
lsst::ctrl::events::EventReceiver::EventReceiver |
( |
const std::string & |
hostName, |
|
|
const std::string & |
topicName, |
|
|
int |
hostPort = EventBroker::DEFAULTHOSTPORT |
|
) |
| |
Receives events from the specified host and topic.
- Parameters
-
hostName | the machine hosting the message broker |
topicName | the topic to receive events from |
hostPort | the port the message broker is listening on |
- Exceptions
-
throws | lsst::pex::exceptions::RuntimeError if connection fails to initialize |
Definition at line 60 of file EventReceiver.cc.
61 init(hostName, topicName,
"", hostPort);
void init(const std::string &hostName, const std::string &topicName, const std::string &selector, int hostPort)
lsst::ctrl::events::EventReceiver::EventReceiver |
( |
const std::string & |
hostName, |
|
|
const std::string & |
topicName, |
|
|
const std::string & |
selector, |
|
|
int |
hostPort = EventBroker::DEFAULTHOSTPORT |
|
) |
| |
Receives events from the specified host and topic.
- Parameters
-
hostName | the machine hosting the message broker |
topicName | the topic to receive events from |
selector | the message selector expression to use. A selector value of "" is equivalent to no selector. |
hostPort | the port the message broker is listening on |
- Exceptions
-
throws | lsst::pex::exceptions::RuntimeError if connection fails to initialize |
Definition at line 64 of file EventReceiver.cc.
65 init(hostName, topicName, selector, hostPort);
void init(const std::string &hostName, const std::string &topicName, const std::string &selector, int hostPort)
lsst::ctrl::events::EventReceiver::~EventReceiver |
( |
| ) |
|
|
virtual |
destructor
Definition at line 147 of file EventReceiver.cc.
153 }
catch ( cms::CMSException& e ) {
161 }
catch ( cms::CMSException& e ) {
170 }
catch ( cms::CMSException& e ) {
176 }
catch ( cms::CMSException& e ) {
183 }
catch ( cms::CMSException& e ) {
191 }
catch ( cms::CMSException& e ) {
cms::Connection * _connection
cms::Destination * _destination
cms::MessageConsumer * _consumer
std::string lsst::ctrl::events::EventReceiver::getTopicName |
( |
| ) |
|
get topic name
- Returns
- the topic name used by this EventReceiver
Definition at line 143 of file EventReceiver.cc.
void lsst::ctrl::events::EventReceiver::init |
( |
const std::string & |
hostName, |
|
|
const std::string & |
topicName, |
|
|
const std::string & |
selector, |
|
|
int |
hostPort |
|
) |
| |
|
private |
private method for initialization of EventReceiver.
Definition at line 70 of file EventReceiver.cc.
72 EventLibrary().initializeLibrary();
85 string jmsURL =
"tcp://"+hostName+
":"+ss.str()+
"?wireFormat=openwire";
87 activemqCore::ActiveMQConnectionFactory* connectionFactory =
88 new activemqCore::ActiveMQConnectionFactory( jmsURL );
92 _connection = connectionFactory->createConnection();
94 delete connectionFactory;
96 catch (cms::CMSException& e) {
97 delete connectionFactory;
98 std::string msg(
"Failed to connect to broker: ");
99 msg += e.getMessage();
100 msg +=
" (is broker running?)";
101 throw LSST_EXCEPT(pexExceptions::RuntimeError, msg);
113 }
catch ( cms::CMSException& e ) {
114 throw LSST_EXCEPT(pexExceptions::RuntimeError, std::string(
"Trouble creating EventReceiver: ") + e.getMessage());
cms::Connection * _connection
cms::Destination * _destination
#define LSST_EXCEPT(type,...)
cms::MessageConsumer * _consumer
Event * lsst::ctrl::events::EventReceiver::receiveEvent |
( |
| ) |
|
Wait until an Event is received.
- Note
- Caller is responsible for deleting received Event.
Definition at line 118 of file EventReceiver.cc.
static const long infiniteTimeout
Event * receiveEvent()
Wait until an Event is received.
Event * lsst::ctrl::events::EventReceiver::receiveEvent |
( |
long |
timeout | ) |
|
wait for a length of time for an event to be received.
- Parameters
-
timeout | the length of time to wait in milliseconds; value of -1 waits indefinately. |
- Note
- Caller is responsible for deleting received Event.
Definition at line 122 of file EventReceiver.cc.
125 cms::TextMessage* textMessage;
127 cms::Message* msg =
_consumer->receive(timeout);
128 if (msg == NULL)
return NULL;
129 textMessage =
dynamic_cast<cms::TextMessage*
>(msg);
130 if (textMessage == NULL)
131 throw LSST_EXCEPT(pexExceptions::RuntimeError,
"Unexpected JMS Message type");
132 }
catch (activemq::exceptions::ActiveMQException& e) {
133 throw LSST_EXCEPT(pexExceptions::RuntimeError, e.getMessage());
137 Event*
event = EventFactory().createEvent(textMessage);
boost::shared_ptr< PropertySet > Ptr
#define LSST_EXCEPT(type,...)
cms::MessageConsumer * _consumer
cms::Connection* lsst::ctrl::events::EventReceiver::_connection |
|
private |
cms::MessageConsumer* lsst::ctrl::events::EventReceiver::_consumer |
|
private |
cms::Destination* lsst::ctrl::events::EventReceiver::_destination |
|
private |
std::string lsst::ctrl::events::EventReceiver::_selector |
|
private |
cms::Session* lsst::ctrl::events::EventReceiver::_session |
|
private |
std::string lsst::ctrl::events::EventReceiver::_topic |
|
private |
const long lsst::ctrl::events::EventReceiver::infiniteTimeout = -1 |
|
static |
The documentation for this class was generated from the following files:
- /home/lsstsw/stack/Linux64/ctrl_events/11.0.rc2+8/include/lsst/ctrl/events/EventReceiver.h
- /home/lsstsw/stack/Linux64/ctrl_events/11.0.rc2+8/src/EventReceiver.cc