From 574baa17ec1cbdc4e859530c1fb6b40b7e114ac4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Voc=C5=AF?= Date: Wed, 20 Jan 2010 19:23:24 +0000 Subject: [PATCH] first skeleton --- org.glite.lb.logger/src/activemq_cpp_plugin.cpp | 104 ++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 org.glite.lb.logger/src/activemq_cpp_plugin.cpp 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) +{ + +} -- 1.8.2.3