activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r474321 - in /incubator/activemq/site: activemq-c-clients.html cross-language-clients.html
Date Mon, 13 Nov 2006 14:05:17 GMT
Author: chirino
Date: Mon Nov 13 06:05:16 2006
New Revision: 474321

URL: http://svn.apache.org/viewvc?view=rev&rev=474321
Log:
Latest export from confluence

Modified:
    incubator/activemq/site/activemq-c-clients.html
    incubator/activemq/site/cross-language-clients.html

Modified: incubator/activemq/site/activemq-c-clients.html
URL: http://svn.apache.org/viewvc/incubator/activemq/site/activemq-c-clients.html?view=diff&rev=474321&r1=474320&r2=474321
==============================================================================
--- incubator/activemq/site/activemq-c-clients.html (original)
+++ incubator/activemq/site/activemq-c-clients.html Mon Nov 13 06:05:16 2006
@@ -253,18 +253,27 @@
             <div class="pagetitle">ActiveMQ C++ Clients</div>
 -->
             <DIV class="wiki-content"><P>There are currently two primary options
for C+&#43; clients to ActiveMQ - one more JMS-like and the other less JMS-like.</P>
+<TABLE class="confluenceTable"><TBODY>
+<TR>
+<TH class="confluenceTh"> C+&#43; Client <BR clear="all"> </TH>
+<TH class="confluenceTh"> Description </TH>
+</TR>
+<TR>
+<TD class="confluenceTd"> ActiveMQ CPP <BR clear="all"> </TD>
+<TD class="confluenceTd"> Uses the CMS API, which is an easy-to-use JMS 1.1-like API.&nbsp;
Architecture supports pluggable transport protocols, very much like the ActiveMQ broker, itself.&nbsp;
Currently uses the <A href="stomp.html" title="Stomp">Stomp</A> protocol, but
work has already begun on adding <A href="openwire.html" title="OpenWire">OpenWire</A>
support (should have this soon). </TD>
+</TR>
+<TR>
+<TD class="confluenceTd"> <A href="openwire-cpp-client.html" title="OpenWire CPP
Client">OpenWire CPP Client</A> </TD>
+<TD class="confluenceTd"> Describes a client written, used and contributed by Amazon.com
due to a need for a C+&#43; client in their internal infrastructure. This library is available
in the amazon/ directory of the source tree (example code is provided there) </TD>
+</TR>
+</TBODY></TABLE>
+<P>This page is dedicated to the ActiveMQ CPP client, as the API is probably more natural
to those already familiar with JMS.</P>
 
-<P><A href="openwire-cpp-client.html" title="OpenWire CPP Client">OpenWire CPP
Client</A> describes a client written, used and contributed by Amazon.com due to a need
for a C+&#43; client in their internal  infrastructure.  This library is available in
the amazon/ directory of the source tree (example code is provided there).</P>
+<H3><A name="ActiveMQC%2B%2BClients-ActiveMQCPP1.0nowavailable%5C%21ClickhereActiveMQCPPReleases"></A><B>ActiveMQ
CPP 1.0 now available&#33;</B> Click <SPAN class="nobr"><A href="http://goopen.org/confluence/pages/createpage.action?spaceKey=ACTIVEMQ&title=ActiveMQ%20CPP%20Releases&linkCreation=true&fromPageId=8971"
title="Create Page: ActiveMQ CPP Releases" class="createlink">here<SUP><IMG class="rendericon"
src="http://goopen.org/confluence/images/icons/plus.gif" height="7" width="7" align="absmiddle"
alt="" border="0"></SUP></A></SPAN></H3>
 
-<P>This page describes a C+&#43; client with a more JMS-like API than the above:</P>
+<P>In addition to providing a JMS 1.1-like API, ActiveMQ CPP also provides a robust
set of classes that support things such as threading, I/O, sockets, etc. You may find many
of these classes useful, such as the &quot;synchronized&quot; macro that let&apos;s
you use a Java-like synchronization on any object that implements the activemq::concurrent::Synchronizable
interface.</P>
 
-<P>ActiveMQ CPP is a C+&#43; API to JMS/MOM implemented currently using <A href="stomp.html"
title="Stomp">Stomp</A> but we hope to have an implementation using <A href="openwire.html"
title="OpenWire">OpenWire</A> soon.</P>
-
-<P>ActiveMQ CPP is a complete rewrite of the original <A href="cms.html" title="CMS">CMS</A>
library and is a full-on replacement with AMQ 4.1-SNAPSHOT or later.</P>
-
-<P>In addition to providing a JMS 1.1-like API, it also provides a robust set of classes
that support things such as threading, I/O, sockets, etc. You may find many of these classes
useful, such as the &quot;synchronized&quot; macro that let&apos;s you use a Java-like
synchronization on any object that implements the activemq::concurrent::Synchronizable interface.</P>
-
-<P>The source code for the ActiveMQ CPP is <SPAN class="nobr"><A href="https://svn.apache.org/repos/asf/incubator/activemq/activemq-cpp/trunk/activemq-cpp/"
title="Visit page outside Confluence" rel="nofollow">here<SUP><IMG class="rendericon"
src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle"
alt="" border="0"></SUP></A></SPAN> Due to changes needed in the Broker
the ActiveMQ-cpp client works with the 4.0.2 and above Broker only.</P>
+<P>The latest source code for the ActiveMQ CPP is <SPAN class="nobr"><A href="https://svn.apache.org/repos/asf/incubator/activemq/activemq-cpp/trunk/activemq-cpp/"
title="Visit page outside Confluence" rel="nofollow">here<SUP><IMG class="rendericon"
src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0" width="0" align="absmiddle"
alt="" border="0"></SUP></A></SPAN> Due to changes needed in the Broker
the ActiveMQ-cpp client works with the 4.0.2 and above Broker only.</P>
 
 <P>Also, check out the <A href="activemq-cpp-roadmap.html" title="ActiveMQ CPP roadmap">ActiveMQ
CPP roadmap</A> for the list of features that are planned for future releases.</P>
 
@@ -282,6 +291,7 @@
 #include &lt;cms/ExceptionListener.h&gt;
 #include &lt;cms/MessageListener.h&gt;
 #include &lt;stdlib.h&gt;
+#include &lt;iostream&gt;
 
 using namespace activemq::core;
 using namespace activemq::util;
@@ -297,15 +307,17 @@
 	Destination* destination;
 	MessageProducer* producer;
 	<SPAN class="code-object">int</SPAN> numMessages;
+    bool useTopic;
 
 <SPAN class="code-keyword">public</SPAN>:
 	
-	HelloWorldProducer( <SPAN class="code-object">int</SPAN> numMessages ){
+	HelloWorldProducer( <SPAN class="code-object">int</SPAN> numMessages, bool useTopic
= <SPAN class="code-keyword">false</SPAN> ){
 		connection = NULL;
     	session = NULL;
     	destination = NULL;
     	producer = NULL;
     	<SPAN class="code-keyword">this</SPAN>-&gt;numMessages = numMessages;
+        <SPAN class="code-keyword">this</SPAN>-&gt;useTopic = useTopic;
 	}
 	
 	virtual ~HelloWorldProducer(){
@@ -325,7 +337,11 @@
 </SPAN>            session = connection-&gt;createSession( Session::AUTO_ACKNOWLEDGE
);
 
             <SPAN class="code-comment">// Create the destination (Topic or Queue)
-</SPAN>            destination = session-&gt;createQueue( <SPAN class="code-quote">&quot;TEST.FOO&quot;</SPAN>
);
+</SPAN>            <SPAN class="code-keyword">if</SPAN>( useTopic ) {
+                destination = session-&gt;createTopic( <SPAN class="code-quote">&quot;TEST.FOO&quot;</SPAN>
);
+            } <SPAN class="code-keyword">else</SPAN> {
+                destination = session-&gt;createQueue( <SPAN class="code-quote">&quot;TEST.FOO&quot;</SPAN>
);
+            }
 
             <SPAN class="code-comment">// Create a MessageProducer from the Session
to the Topic or Queue
 </SPAN>            producer = session-&gt;createProducer( destination );
@@ -396,15 +412,17 @@
 	Destination* destination;
 	MessageConsumer* consumer;
 	<SPAN class="code-object">long</SPAN> waitMillis;
+    bool useTopic;
 		
 <SPAN class="code-keyword">public</SPAN>: 
 
-	HelloWorldConsumer( <SPAN class="code-object">long</SPAN> waitMillis ){
+	HelloWorldConsumer( <SPAN class="code-object">long</SPAN> waitMillis, bool useTopic
= <SPAN class="code-keyword">false</SPAN> ){
 		connection = NULL;
     	session = NULL;
     	destination = NULL;
     	consumer = NULL;
     	<SPAN class="code-keyword">this</SPAN>-&gt;waitMillis = waitMillis;
+        <SPAN class="code-keyword">this</SPAN>-&gt;useTopic = useTopic;
 	}
     virtual ~HelloWorldConsumer(){    	
     	cleanup();
@@ -429,7 +447,11 @@
 </SPAN>            session = connection-&gt;createSession( Session::AUTO_ACKNOWLEDGE
);
 
             <SPAN class="code-comment">// Create the destination (Topic or Queue)
-</SPAN>            destination = session-&gt;createQueue( <SPAN class="code-quote">&quot;TEST.FOO&quot;</SPAN>
);
+</SPAN>            <SPAN class="code-keyword">if</SPAN>( useTopic ) {
+                destination = session-&gt;createTopic( <SPAN class="code-quote">&quot;TEST.FOO&quot;</SPAN>
);
+            } <SPAN class="code-keyword">else</SPAN> {
+                destination = session-&gt;createQueue( <SPAN class="code-quote">&quot;TEST.FOO&quot;</SPAN>
);
+            }
 
             <SPAN class="code-comment">// Create a MessageConsumer from the Session
to the Topic or Queue
 </SPAN>            consumer = session-&gt;createConsumer( destination );
@@ -444,20 +466,26 @@
         }
     }
     
-    virtual void onMessage( <SPAN class="code-keyword">const</SPAN> Message*
message ){
+    <SPAN class="code-comment">// Called from the consumer since <SPAN class="code-keyword">this</SPAN>
class is a registered MessageListener.
+</SPAN>    virtual void onMessage( <SPAN class="code-keyword">const</SPAN>
Message* message ){
     	
+        <SPAN class="code-keyword">static</SPAN> <SPAN class="code-object">int</SPAN>
count = 0;
+        
         <SPAN class="code-keyword">try</SPAN>
         {
+            count++;
     	    <SPAN class="code-keyword">const</SPAN> TextMessage* textMessage = 
                 dynamic_cast&lt; <SPAN class="code-keyword">const</SPAN>
TextMessage* &gt;( message );
             string text = textMessage-&gt;getText();
-            printf( <SPAN class="code-quote">&quot;Received: %s\n&quot;</SPAN>,
text.c_str() );
+            printf( <SPAN class="code-quote">&quot;Message #%d Received: %s\n&quot;</SPAN>,
count, text.c_str() );
         } <SPAN class="code-keyword">catch</SPAN> (CMSException&amp; e) {
             e.printStackTrace();
         }
     }
 
-    virtual void onException( <SPAN class="code-keyword">const</SPAN> CMSException&amp;
ex ) {
+    <SPAN class="code-comment">// If something bad happens you see it here as <SPAN
class="code-keyword">this</SPAN> class is also been
+</SPAN>    <SPAN class="code-comment">// registered as an ExceptionListener with
the connection.
+</SPAN>    virtual void onException( <SPAN class="code-keyword">const</SPAN>
CMSException&amp; ex ) {
         printf(<SPAN class="code-quote">&quot;JMS Exception occured.  Shutting
down client.\n&quot;</SPAN>);
     }
     
@@ -465,6 +493,11 @@
 
     void cleanup(){
     	
+        <SPAN class="code-comment">//*************************************************
+</SPAN>        <SPAN class="code-comment">// Always close destination, consumers
and producers before
+</SPAN>        <SPAN class="code-comment">// you destroy their sessions and connection.
+</SPAN>        <SPAN class="code-comment">//*************************************************
+</SPAN>        
 		<SPAN class="code-comment">// Destroy resources.
 </SPAN>		<SPAN class="code-keyword">try</SPAN>{                       

         	<SPAN class="code-keyword">if</SPAN>( destination != NULL ) delete destination;
@@ -482,7 +515,8 @@
 			<SPAN class="code-keyword">if</SPAN>( connection != NULL ) connection-&gt;close();
 		}<SPAN class="code-keyword">catch</SPAN> (CMSException&amp; e) {}
 		
-        <SPAN class="code-keyword">try</SPAN>{
+        <SPAN class="code-comment">// Now Destroy them
+</SPAN>        <SPAN class="code-keyword">try</SPAN>{
         	<SPAN class="code-keyword">if</SPAN>( session != NULL ) delete session;
 		}<SPAN class="code-keyword">catch</SPAN> (CMSException&amp; e) {}
 		session = NULL;
@@ -495,9 +529,20 @@
 };
     
 <SPAN class="code-object">int</SPAN> main(<SPAN class="code-object">int</SPAN>
argc, <SPAN class="code-object">char</SPAN>* argv[]) {
-    
-    HelloWorldProducer producer( 1000 );
-	HelloWorldConsumer consumer( 5000 );
+
+    std::cout &lt;&lt; <SPAN class="code-quote">&quot;=====================================================\n&quot;</SPAN>;
   
+    std::cout &lt;&lt; <SPAN class="code-quote">&quot;Starting the example:&quot;</SPAN>
&lt;&lt; std::endl;
+    std::cout &lt;&lt; <SPAN class="code-quote">&quot;-----------------------------------------------------\n&quot;</SPAN>;
+
+    <SPAN class="code-comment">//============================================================
+</SPAN>    <SPAN class="code-comment">// set to <SPAN class="code-keyword">true</SPAN>
to use topics instead of queues
+</SPAN>    <SPAN class="code-comment">// Note in the code above that <SPAN
class="code-keyword">this</SPAN> causes createTopic or
+</SPAN>    <SPAN class="code-comment">// createQueue to be used in both consumer
an producer.
+</SPAN>    <SPAN class="code-comment">//============================================================
   
+</SPAN>    bool useTopics = <SPAN class="code-keyword">false</SPAN>;  
+
+    HelloWorldProducer producer( 1000, useTopics );
+	HelloWorldConsumer consumer( 8000, useTopics );
 	
 	<SPAN class="code-comment">// Start the consumer thread.
 </SPAN>	<SPAN class="code-object">Thread</SPAN> consumerThread( &amp;consumer
);
@@ -510,6 +555,13 @@
 	<SPAN class="code-comment">// Wait <SPAN class="code-keyword">for</SPAN>
the threads to complete.
 </SPAN>	producerThread.join();
 	consumerThread.join();
+
+    std::cout &lt;&lt; <SPAN class="code-quote">&quot;-----------------------------------------------------\n&quot;</SPAN>;
   
+    std::cout &lt;&lt; <SPAN class="code-quote">&quot;Finished with the
example, ignore errors from <SPAN class="code-keyword">this</SPAN>&quot;</SPAN>

+              &lt;&lt; std::endl
+              &lt;&lt; <SPAN class="code-quote">&quot;point on as the sockets
breaks when we shutdown.&quot;</SPAN>
+              &lt;&lt; std::endl;
+    std::cout &lt;&lt; <SPAN class="code-quote">&quot;=====================================================\n&quot;</SPAN>;
   
 }</PRE>
 </DIV></DIV>
 <P>For compiling that example, you need the <B>libuuid</B> that is part
of the e2fsprogs package and is available from <SPAN class="nobr"><A href="http://e2fsprogs.sourceforge.net/"
title="Visit page outside Confluence" rel="nofollow">http://e2fsprogs.sourceforge.net/<SUP><IMG
class="rendericon" src="http://goopen.org/confluence/images/icons/linkext7.gif" height="0"
width="0" align="absmiddle" alt="" border="0"></SUP></A></SPAN></P>
@@ -547,8 +599,8 @@
     </DIV>
     <DIV id="site-footer">
           Added by     <A href="http://goopen.org/confluence/users/viewuserprofile.action?username=nmittler">Nathan
Mittler</A>,
-    last edited by     <A href="http://goopen.org/confluence/users/viewuserprofile.action?username=jstrachan">James
Strachan</A> on Oct 29, 2006
-                  &nbsp;(<A href="http://goopen.org/confluence/pages/diffpages.action?pageId=8971&originalId=14485">view
change</A>)
+    last edited by     <A href="http://goopen.org/confluence/users/viewuserprofile.action?username=nmittler">Nathan
Mittler</A> on Nov 17, 2006
+                  &nbsp;(<A href="http://goopen.org/confluence/pages/diffpages.action?pageId=8971&originalId=15043">view
change</A>)
               
       (<A href="http://goopen.org/confluence/pages/editpage.action?pageId=8971">edit
page</A>)
     </DIV>

Modified: incubator/activemq/site/cross-language-clients.html
URL: http://svn.apache.org/viewvc/incubator/activemq/site/cross-language-clients.html?view=diff&rev=474321&r1=474320&r2=474321
==============================================================================
--- incubator/activemq/site/cross-language-clients.html (original)
+++ incubator/activemq/site/cross-language-clients.html Mon Nov 13 06:05:16 2006
@@ -322,16 +322,16 @@
                           <a href="http://goopen.org/confluence/pages/viewpage.action?pageId=8971"
title="ActiveMQ C++ Clients">ActiveMQ C++ Clients</a>
               <span class="smalltext">(ActiveMQ)</span>
               <br>
-                          <a href="http://goopen.org/confluence/display/ACTIVEMQ/Perl"
title="Perl">Perl</a>
+                          <a href="http://goopen.org/confluence/display/ACTIVEMQ/Python"
title="Python">Python</a>
               <span class="smalltext">(ActiveMQ)</span>
               <br>
-                          <a href="http://goopen.org/confluence/display/ACTIVEMQ/Python"
title="Python">Python</a>
+                          <a href="http://goopen.org/confluence/display/ACTIVEMQ/Pike"
title="Pike">Pike</a>
               <span class="smalltext">(ActiveMQ)</span>
               <br>
                           <a href="http://goopen.org/confluence/display/ACTIVEMQ/Ruby"
title="Ruby">Ruby</a>
               <span class="smalltext">(ActiveMQ)</span>
               <br>
-                          <a href="http://goopen.org/confluence/display/ACTIVEMQ/Pike"
title="Pike">Pike</a>
+                          <a href="http://goopen.org/confluence/display/ACTIVEMQ/Perl"
title="Perl">Perl</a>
               <span class="smalltext">(ActiveMQ)</span>
               <br>
                           <a href="http://goopen.org/confluence/display/ACTIVEMQ/PHP"
title="PHP">PHP</a>



Mime
View raw message