From: Michal Voců Date: Wed, 20 Jan 2010 19:23:24 +0000 (+0000) Subject: first skeleton X-Git-Tag: glite-lb-harvester_R_1_0_3_1~11 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=574baa17ec1cbdc4e859530c1fb6b40b7e114ac4;p=jra1mw.git first skeleton --- diff --git a/org.glite.lb.logger/src/activemq_cpp_plugin.cpp b/org.glite.lb.logger/src/activemq_cpp_plugin.cpp new file mode 100644 index 0000000..e6ca060 --- /dev/null +++ b/org.glite.lb.logger/src/activemq_cpp_plugin.cpp @@ -0,0 +1,104 @@ +#ident "$Header$" + +/* + * activemq_cpp_plugin.cpp + * + * Created on: Jan 20, 2010 + * Author: michal + */ + +#include "interlogd.h" + +#include +#include + +class OutputPlugin { + +public: + + OutputPlugin() : connection(NULL) {}; + + virtual void onException(const cms::CMSException &ex); + +public: + + cms::Session *session; + cms::Topic *destination; + cms::MessageProducer *producer; + + static cms::Connection *connection; + static cms::ConnectionFactory *connectionFactory = NULL; + +}; + + +extern "C" +int +event_queue_connect(struct event_queue *eq) +{ + OutputPlugin *output; + std::string topicName; + + if(eq->plugin_data == NULL) { + output = new OutputPlugin(); + eq->plugin_data = (void*)output; + } else { + output = (OutputPlugin*)eq->plugin_data; + } + + output->session = OutputPlugin::connection->createSession(/* TODO: ackMode */); + output->destination = output->session->createTopic(topicName); + output->producer = output->session->createProducer(output->destination); + OutputPlugin::connection->start(); + + return 0; +} + + +extern "C" +int +event_queue_send(struct event_queue *eq) +{ + return 0; +} + + +extern "C" +int +event_queue_close(struct event_queue *eq) +{ + OutputPlugin *output = (OutputPlugin*)eq->plugin_data; + + assert(output != NULL); + + OutputPlugin::connection->stop(); + + return 0; +} + + +extern "C" +int +plugin_init() +{ + std::string brokerURI; + + try { + activemq::library::ActiveMQCPP::initializeLibrary(); + + OutputPlugin::connectionFactory = cms::ConnectionFactory::createCMSConnectionFactory(brokerURI); + OutputPlugin::connection = output->connectionFactory->createConnection(); + } catch (cms::CMSException e) { + return -1; + } + + return 0; +} + + +extern "C" +int +plugin_supports_scheme(const char *scheme) +{ + +}