You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/06/13 01:22:05 UTC
svn commit: r784311 - in
/activemq/activemq-cpp/trunk/activemq-cpp/src/examples: ./ advisories/
Author: tabish
Date: Fri Jun 12 23:22:04 2009
New Revision: 784311
URL: http://svn.apache.org/viewvc?rev=784311&view=rev
Log:
Add a new Sample to demonstrate how to deal with Advisory Topics.
Added:
activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/
activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumerMain.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.h (with props)
activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducerMain.cpp (with props)
Modified:
activemq/activemq-cpp/trunk/activemq-cpp/src/examples/Makefile.am
Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/Makefile.am?rev=784311&r1=784310&r2=784311&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/Makefile.am Fri Jun 12 23:22:04 2009
@@ -47,3 +47,19 @@
chat_SOURCES = $(chat_sources)
chat_LDADD= $(AMQ_TEST_LIBS)
chat_CXXFLAGS = $(AMQ_TEST_CXXFLAGS) -I$(srcdir)/../main
+
+## Advisory Producer Example
+advisory_producer_sources = advisories/AdvisoryProducer.cpp \
+ advisories/AdvisoryProducerMain.cpp
+noinst_PROGRAMS += advisory_producer
+advisory_producer_SOURCES = $(advisory_producer_sources)
+advisory_producer_LDADD= $(AMQ_TEST_LIBS)
+advisory_producer_CXXFLAGS = $(AMQ_TEST_CXXFLAGS) -I$(srcdir)/../main
+
+## Advisory Consumer Example
+advisory_consumer_sources = advisories/AdvisoryConsumer.cpp \
+ advisories/AdvisoryConsumerMain.cpp
+noinst_PROGRAMS += advisory_consumer
+advisory_consumer_SOURCES = $(advisory_consumer_sources)
+advisory_consumer_LDADD= $(AMQ_TEST_LIBS)
+advisory_consumer_CXXFLAGS = $(AMQ_TEST_CXXFLAGS) -I$(srcdir)/../main
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp?rev=784311&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp Fri Jun 12 23:22:04 2009
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AdvisoryConsumer.h"
+
+#include <cms/Topic.h>
+#include <cms/Message.h>
+#include <cms/TextMessage.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+
+#include <activemq/commands/ActiveMQMessage.h>
+#include <activemq/commands/ProducerInfo.h>
+
+using namespace std;
+using namespace activemq;
+using namespace activemq::commands;
+using namespace activemqcpp;
+using namespace activemqcpp::examples;
+using namespace activemqcpp::examples::advisories;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+AdvisoryConsumer::AdvisoryConsumer( cms::Session* session ) {
+
+ if( session == NULL ) {
+ throw NullPointerException(
+ __FILE__, __LINE__, "Session Object passed was Null." );
+ }
+
+ std::auto_ptr<cms::Topic> destination( session->createTopic(
+ "HEART-BEAT-CHANNEL" ) );
+ std::auto_ptr<cms::Topic> advisories( session->createTopic(
+ "ActiveMQ.Advisory.Producer.Topic.HEART-BEAT-CHANNEL" ) );
+
+ this->session = session;
+ this->consumer.reset( session->createConsumer( destination.get() ) );
+ this->advisoryConsumer.reset( session->createConsumer( advisories.get() ) );
+ this->consumer->setMessageListener( this );
+ this->advisoryConsumer->setMessageListener( this );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+AdvisoryConsumer::~AdvisoryConsumer() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AdvisoryConsumer::close() throw( cms::CMSException ) {
+ this->consumer.reset( NULL );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AdvisoryConsumer::onMessage( const cms::Message* message ) {
+
+ if( message->getCMSType() == "Advisory" ) {
+
+ const ActiveMQMessage* amqMessage =
+ dynamic_cast<const ActiveMQMessage*>( message );
+
+ // If you want you can get the ProducerInfo for instance, you could get
+ // the ConsumerInfo and ConnectionInfo.
+ if( amqMessage != NULL && amqMessage->getDataStructure() != NULL ) {
+ const ProducerInfo* info = dynamic_cast<const ProducerInfo*>(
+ amqMessage->getDataStructure().get() );
+ }
+
+ if( message->propertyExists( "producerCount" ) ) {
+ std::string producerCount = message->getStringProperty( "producerCount" );
+ std::cout << "Number of Producers = " << producerCount << std::endl;
+ }
+
+ } else {
+
+ const cms::TextMessage* txtMessage =
+ dynamic_cast<const cms::TextMessage*>( message );
+
+ if( txtMessage != NULL ) {
+ std::cout << "Producer Reports Status as: "
+ << txtMessage->getText() << std::endl;
+ }
+ }
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.h?rev=784311&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.h Fri Jun 12 23:22:04 2009
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQCPP_EXAMPLES_ADVISORIES_ADVISORYCONSUMER_H_
+#define _ACTIVEMQCPP_EXAMPLES_ADVISORIES_ADVISORYCONSUMER_H_
+
+#include <string>
+#include <memory>
+
+#include <cms/Closeable.h>
+#include <cms/Session.h>
+#include <cms/MessageConsumer.h>
+#include <cms/MessageListener.h>
+
+namespace activemqcpp {
+namespace examples {
+namespace advisories {
+
+ class AdvisoryConsumer : public cms::Closeable,
+ public cms::MessageListener {
+ private:
+
+ cms::Session* session;
+ std::auto_ptr<cms::MessageConsumer> consumer;
+ std::auto_ptr<cms::MessageConsumer> advisoryConsumer;
+
+ public:
+
+ AdvisoryConsumer( cms::Session* session );
+ virtual ~AdvisoryConsumer();
+
+ /**
+ * Close down Consumer resources.
+ */
+ virtual void close() throw( cms::CMSException );
+
+ /**
+ * Async Message callback.
+ */
+ virtual void onMessage( const cms::Message* message );
+
+ };
+
+}}}
+
+#endif /* _ACTIVEMQCPP_EXAMPLES_ADVISORIES_ADVISORYCONSUMER_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumer.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumerMain.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumerMain.cpp?rev=784311&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumerMain.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumerMain.cpp Fri Jun 12 23:22:04 2009
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AdvisoryConsumer.h"
+
+#include <activemq/library/ActiveMQCPP.h>
+#include <cms/ConnectionFactory.h>
+#include <cms/Connection.h>
+#include <cms/Session.h>
+#include <stdlib.h>
+#include <iostream>
+#include <memory>
+
+using namespace activemqcpp::examples::advisories;
+using namespace cms;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+int main( int argc AMQCPP_UNUSED, char* argv[] AMQCPP_UNUSED ) {
+
+ // We must always init the library first before using any methods in it.
+ activemq::library::ActiveMQCPP::initializeLibrary();
+
+ std::cout << "=====================================================\n";
+ std::cout << "Starting the example:" << std::endl;
+ std::cout << "-----------------------------------------------------\n";
+
+ // Set the URI to point to the IPAddress of your broker.
+ // add any optional params to the url to enable things like
+ // tightMarshalling or tcp logging etc. See the CMS web site for
+ // a full list of configuration options.
+ //
+ // http://activemq.apache.org/cms/
+ //
+ std::string brokerURI = "failover:(tcp://127.0.0.1:61616)";
+
+ // Create the Connection
+ auto_ptr<cms::ConnectionFactory> connectionFactory(
+ cms::ConnectionFactory::createCMSConnectionFactory( brokerURI ) );
+
+ auto_ptr<cms::Connection> connection;
+
+ // Create a Connection
+ try{
+ connection.reset( connectionFactory->createConnection() );
+ } catch( CMSException& e ) {
+ e.printStackTrace();
+ return 1;
+ }
+
+ // Create the Session
+ std::auto_ptr<cms::Session> session( connection->createSession() );
+
+ // Create the producer and run it.
+ AdvisoryConsumer advisoryConsumer( session.get() );
+
+ // Start the Connection now.
+ connection->start();
+
+ // Wait until we are told to quit.
+ std::cout << "Press 'q' to quit" << std::endl;
+ while( std::cin.get() != 'q') {}
+
+ // Shutdown now
+ advisoryConsumer.close();
+ connection->stop();
+
+ std::cout << "-----------------------------------------------------\n";
+ std::cout << "Finished with the example." << std::endl;
+ std::cout << "=====================================================\n";
+
+ // We must also always remember to shut down the Library when done.
+ activemq::library::ActiveMQCPP::shutdownLibrary();
+
+ return 0;
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryConsumerMain.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp?rev=784311&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp Fri Jun 12 23:22:04 2009
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AdvisoryProducer.h"
+
+#include <cms/Topic.h>
+#include <cms/Message.h>
+#include <cms/TextMessage.h>
+#include <decaf/lang/exceptions/NullPointerException.h>
+#include <decaf/lang/Integer.h>
+
+using namespace std;
+using namespace activemqcpp;
+using namespace activemqcpp::examples;
+using namespace activemqcpp::examples::advisories;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace decaf::lang::exceptions;
+
+////////////////////////////////////////////////////////////////////////////////
+AdvisoryProducer::AdvisoryProducer( cms::Session* session ) : shutdownLatch(1) {
+
+ if( session == NULL ) {
+ throw NullPointerException(
+ __FILE__, __LINE__, "Session Object passed was Null." );
+ }
+
+ std::auto_ptr<cms::Topic> destination( session->createTopic(
+ "HEART-BEAT-CHANNEL" ) );
+ std::auto_ptr<cms::Topic> advisories( session->createTopic(
+ "ActiveMQ.Advisory.Consumer.Topic.HEART-BEAT-CHANNEL" ) );
+
+ this->shutdown = false;
+ this->consumerOnline = false;
+
+ this->session = session;
+ this->producer.reset( session->createProducer( destination.get() ) );
+ this->consumer.reset( session->createConsumer( advisories.get() ) );
+ this->consumer->setMessageListener( this );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+AdvisoryProducer::~AdvisoryProducer() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AdvisoryProducer::stop() {
+ this->shutdown = true;
+ this->shutdownLatch.await( 3000 );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AdvisoryProducer::run() {
+
+ while( !this->shutdown ) {
+
+ if( this->consumerOnline ) {
+
+ std::auto_ptr<cms::TextMessage> message(
+ this->session->createTextMessage( "Alive" ) );
+
+ this->producer->send( message.get() );
+
+ Thread::sleep( 1000 );
+ }
+ }
+
+ this->shutdownLatch.countDown();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void AdvisoryProducer::onMessage( const cms::Message* message ) {
+
+ if( message->getCMSType() == "Advisory" ) {
+
+ std::cout << "Received an Advisory Message!" << std::endl;
+
+ if( message->propertyExists( "consumerCount" ) ) {
+
+ std::string consumerCount = message->getStringProperty( "consumerCount" );
+ std::cout << "Number of Consumers = " << consumerCount << std::endl;
+ this->consumerOnline = Integer::parseInt( consumerCount ) > 0 ? true : false;
+ }
+
+ } else {
+ std::cout << "Received a Non-Advisory Message!" << std::endl;
+ }
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.h?rev=784311&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.h (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.h Fri Jun 12 23:22:04 2009
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACTIVEMQCPP_EXAMPLES_ADVISORIES_ADVISORYPRODUCER_H_
+#define _ACTIVEMQCPP_EXAMPLES_ADVISORIES_ADVISORYPRODUCER_H_
+
+#include <string>
+#include <memory>
+
+#include <cms/Session.h>
+#include <cms/MessageProducer.h>
+#include <cms/MessageConsumer.h>
+#include <cms/MessageListener.h>
+
+#include <decaf/lang/Runnable.h>
+#include <decaf/util/concurrent/CountDownLatch.h>
+
+namespace activemqcpp {
+namespace examples {
+namespace advisories {
+
+ class AdvisoryProducer : public decaf::lang::Runnable,
+ public cms::MessageListener {
+ private:
+
+ volatile bool consumerOnline;
+ volatile bool shutdown;
+ decaf::util::concurrent::CountDownLatch shutdownLatch;
+
+ cms::Session* session;
+ std::auto_ptr<cms::MessageConsumer> consumer;
+ std::auto_ptr<cms::MessageProducer> producer;
+
+ public:
+
+ AdvisoryProducer( cms::Session* session );
+ virtual ~AdvisoryProducer();
+
+ /**
+ * Shut down the processing that occurs in the Run method.
+ */
+ void stop();
+
+ /**
+ * Run the producer code.
+ */
+ virtual void run();
+
+ /**
+ * Async Message callback.
+ */
+ virtual void onMessage( const cms::Message* message );
+
+ };
+
+}}}
+
+#endif /* _ACTIVEMQCPP_EXAMPLES_ADVISORIES_ADVISORYPRODUCER_H_ */
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducer.h
------------------------------------------------------------------------------
svn:eol-style = native
Added: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducerMain.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducerMain.cpp?rev=784311&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducerMain.cpp (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducerMain.cpp Fri Jun 12 23:22:04 2009
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "AdvisoryProducer.h"
+
+#include <decaf/lang/Thread.h>
+#include <decaf/lang/Runnable.h>
+#include <activemq/library/ActiveMQCPP.h>
+#include <cms/ConnectionFactory.h>
+#include <cms/Connection.h>
+#include <cms/Session.h>
+#include <stdlib.h>
+#include <iostream>
+#include <memory>
+
+using namespace activemqcpp::examples::advisories;
+using namespace decaf;
+using namespace decaf::lang;
+using namespace cms;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+int main( int argc AMQCPP_UNUSED, char* argv[] AMQCPP_UNUSED ) {
+
+ // We must always init the library first before using any methods in it.
+ activemq::library::ActiveMQCPP::initializeLibrary();
+
+ std::cout << "=====================================================\n";
+ std::cout << "Starting the example:" << std::endl;
+ std::cout << "-----------------------------------------------------\n";
+
+ // Set the URI to point to the IPAddress of your broker.
+ // add any optional params to the url to enable things like
+ // tightMarshalling or tcp logging etc. See the CMS web site for
+ // a full list of configuration options.
+ //
+ // http://activemq.apache.org/cms/
+ //
+ std::string brokerURI = "failover:(tcp://127.0.0.1:61616)";
+
+ // Create the Connection
+ auto_ptr<cms::ConnectionFactory> connectionFactory(
+ cms::ConnectionFactory::createCMSConnectionFactory( brokerURI ) );
+
+ auto_ptr<cms::Connection> connection;
+
+ // Create a Connection
+ try{
+ connection.reset( connectionFactory->createConnection() );
+ } catch( CMSException& e ) {
+ e.printStackTrace();
+ return 1;
+ }
+
+ // Create the Session
+ std::auto_ptr<cms::Session> session( connection->createSession() );
+
+ // Create the producer and run it.
+ AdvisoryProducer advisoryProducer( session.get() );
+ Thread runner( &advisoryProducer );
+ runner.start();
+
+ // Start the Connection now.
+ connection->start();
+
+ // Wait until we are told to quit.
+ std::cout << "Press 'q' to quit" << std::endl;
+ while( std::cin.get() != 'q') {}
+
+ // Shutdown now
+ advisoryProducer.stop();
+ connection->stop();
+
+ std::cout << "-----------------------------------------------------\n";
+ std::cout << "Finished with the example." << std::endl;
+ std::cout << "=====================================================\n";
+
+ // We must also always remember to shut down the Library when done.
+ activemq::library::ActiveMQCPP::shutdownLibrary();
+
+ return 0;
+}
Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/examples/advisories/AdvisoryProducerMain.cpp
------------------------------------------------------------------------------
svn:eol-style = native