shared_ptr<cms::Destination>
Destination::toCMSDestination(cms::Session &session) const {
    if (isTopic())
        return shared_ptr<cms::Destination>(session.createTopic(str()));
    else
        return shared_ptr<cms::Destination>(session.createQueue(str()));
}
void
OutputPlugin::connect(const std::string &topic)
{
	try {
		current_connection = getConnection();
		if(session == NULL) {
			session = current_connection->createSession(/* TODO: ackMode */);
			destination = session->createTopic(topic);
			producer = session->createProducer(destination);
		}
		current_connection->start();
		releaseConnection();
	} catch (cms::CMSException &e) {
		glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_DEBUG, "OutputPlugin::connect exception: %s", e.what());
		releaseConnection();
		cleanup();
		throw e;
	}
}