39 #include <activemq/library/ActiveMQCPP.h>
40 #include <cms/Connection.h>
41 #include <cms/ConnectionFactory.h>
42 #include <cms/Destination.h>
43 #include <cms/MapMessage.h>
44 #include <cms/MessageConsumer.h>
45 #include <cms/Session.h>
61 activemq::library::ActiveMQCPP::initializeLibrary();
63 catch ( std::runtime_error& ex )
65 std::cerr <<
"Runtime error while initializing ActiveMQCPP library!" << std::endl;
66 std::cerr << ex.what() << std::endl;
71 cms::ConnectionFactory* factory = cms::ConnectionFactory::createCMSConnectionFactory (
AlarmConfiguration::instance().getActiveMQURI() );
77 catch ( cms::CMSException& ex )
79 std::cerr <<
"Cannot create CMS connection!" << std::endl;
80 std::cerr << ex.getMessage() << std::endl;
95 catch ( cms::CMSException& ex )
97 std::cerr <<
"Cannot create CMS session/topic!" << std::endl;
98 std::cerr << ex.getMessage() << std::endl;
158 activemq::library::ActiveMQCPP::shutdownLibrary();
165 const cms::MapMessage*
const mapmessage =
dynamic_cast<const cms::MapMessage*
> ( message );
168 if ( mapmessage ==
nullptr )
170 if ( !mapmessage->itemExists (
"TEXT" ) )
173 if ( mapmessage->getString (
"TEXT" ) !=
"STATE" )
175 if ( !mapmessage->itemExists (
"NAME" ) || !mapmessage->itemExists (
"SEVERITY" ) || !mapmessage->itemExists (
"STATUS" ) )
177 std::string rawname = mapmessage->getString (
"NAME" );
178 const std::string name = rawname.replace ( rawname.find (
"epics://" ), 8,
"" );
181 mapmessage->getString (
"SEVERITY" ),
182 mapmessage->getString (
"STATUS" )
184 _asc.notifyStatusChange ( ase );
189 ex.printStackTrace();
#define nullptr
Allow using the nullptr keyword with GCC < 4.6.
virtual void onException(const cms::CMSException &ex) noexcept
Exception listener.
cms::Session * _session
CMS session.
CMSClient(AlarmServerConnector &asc)
Constructor.
Entry in the AlarmServerConnector statusmap.
Interface to the CMS (C++ Messaging Service) library of Apache ActiveMQ.
Namespace for Alarm Notifications application.
virtual void onMessage(const cms::Message *message) noexcept
Message listener.
Provides connectivity to the CSS Alarm Server.
#define noexcept
Allow using the noexcept keyword with GCC < 4.6.
cms::Connection * _connection
CMS connection.
cms::Destination * _topicServer
CMS topic.
cms::MessageConsumer * _consumerServer
CMS receiver.
Singleton to read and change the configuration of this application.
static AlarmConfiguration & instance() noexcept
Get singleton instance.
Connect to a CSS Alarm Server.