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>
50 using namespace AlarmNotifications;
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();