activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: Add in C++ and CSharp examples for Openwire
Date Thu, 10 Oct 2013 15:10:46 GMT
Updated Branches:
  refs/heads/trunk b4dafca86 -> a912d6d5c


Add in C++ and CSharp examples for Openwire

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/a912d6d5
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/a912d6d5
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/a912d6d5

Branch: refs/heads/trunk
Commit: a912d6d5cedc60074ff85af06dfac6a4a070889b
Parents: b4dafca
Author: Timothy Bish <tabish121@gmai.com>
Authored: Thu Oct 10 11:10:36 2013 -0400
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Thu Oct 10 11:10:36 2013 -0400

----------------------------------------------------------------------
 .../release/examples/openwire/cpp/Listener.cpp  | 126 +++++++++++++++++++
 .../release/examples/openwire/cpp/Publisher.cpp | 120 ++++++++++++++++++
 .../src/release/examples/openwire/cpp/readme.md |  42 +++++++
 .../ActiveMQExamples/ActiveMQExamples.sln       |  26 ++++
 .../ActiveMQExamples/ActiveMQExamples.userprefs |  29 +++++
 .../ActiveMQExamples/Listener/AssemblyInfo.cs   |  44 +++++++
 .../ActiveMQExamples/Listener/Listener.cs       | 106 ++++++++++++++++
 .../ActiveMQExamples/Listener/Listener.csproj   |  52 ++++++++
 .../ActiveMQExamples/Listener/NMSTracer.cs      |  78 ++++++++++++
 .../ActiveMQExamples/Publisher/AssemblyInfo.cs  |  44 +++++++
 .../ActiveMQExamples/Publisher/NMSTracer.cs     |  78 ++++++++++++
 .../ActiveMQExamples/Publisher/Publisher.cs     |  87 +++++++++++++
 .../ActiveMQExamples/Publisher/Publisher.csproj |  52 ++++++++
 .../release/examples/openwire/csharp/readme.md  |  33 +++++
 14 files changed, 917 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/cpp/Listener.cpp
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/cpp/Listener.cpp b/assembly/src/release/examples/openwire/cpp/Listener.cpp
new file mode 100644
index 0000000..d5d0c78
--- /dev/null
+++ b/assembly/src/release/examples/openwire/cpp/Listener.cpp
@@ -0,0 +1,126 @@
+/*
+ * 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 <activemq/core/ActiveMQConnectionFactory.h>
+#include <activemq/core/ActiveMQConnection.h>
+#include <activemq/library/ActiveMQCPP.h>
+#include <decaf/lang/Integer.h>
+#include <decaf/lang/System.h>
+#include <activemq/util/Config.h>
+#include <cms/Connection.h>
+#include <cms/Session.h>
+#include <cms/Destination.h>
+#include <cms/MessageProducer.h>
+#include <cms/TextMessage.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream>
+
+using namespace activemq;
+using namespace activemq::core;
+using namespace decaf::lang;
+using namespace cms;
+using namespace std;
+
+////////////////////////////////////////////////////////////////////////////////
+std::string getEnv(const std::string& key, const std::string& defaultValue) {
+
+    try{
+        return System::getenv(key);
+    } catch(...) {
+    }
+
+    return defaultValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string getArg(char* argv[], int argc, int index, const std::string& defaultValue)
{
+
+    if( index < argc ) {
+        return argv[index];
+    }
+
+    return defaultValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int main(int argc AMQCPP_UNUSED, char* argv[] AMQCPP_UNUSED) {
+
+    activemq::library::ActiveMQCPP::initializeLibrary();
+
+    std::cout << "=====================================================\n";
+    std::cout << "Starting the Listener example:" << std::endl;
+    std::cout << "-----------------------------------------------------\n";
+
+    std::string user = getEnv("ACTIVEMQ_USER", "admin");
+    std::string password = getEnv("ACTIVEMQ_PASSWORD", "password");
+    std::string host = getEnv("ACTIVEMQ_HOST", "localhost");
+    int port = Integer::parseInt(getEnv("ACTIVEMQ_PORT", "61616"));
+    std::string destination = getArg(argv, argc, 1, "event");
+
+    {
+        ActiveMQConnectionFactory factory;
+        factory.setBrokerURI(std::string("tcp://") + host + ":" + Integer::toString(port));
+
+        std::auto_ptr<Connection> connection(factory.createConnection(user, password));
+
+        std::auto_ptr<Session> session(connection->createSession());
+        std::auto_ptr<Destination> dest(session->createTopic(destination));
+        std::auto_ptr<MessageConsumer> consumer(session->createConsumer(dest.get()));
+
+        connection->start();
+
+        long long start = System::currentTimeMillis();
+        long long count = 0;
+
+        std::cout << "Waiting for messages..." << std::endl;
+        while(true) {
+
+            std::auto_ptr<Message> message(consumer->receive());
+
+            const TextMessage* txtMsg = dynamic_cast<const TextMessage*>(message.get());
+
+            if( txtMsg != NULL ) {
+                std::string body = txtMsg->getText();
+                if( body == "SHUTDOWN" ) {
+                    long long diff = System::currentTimeMillis() - start;
+                    cout << "Received " << count << " in " << (double)diff/1000.0
<< " seconds" << std::endl;
+                    break;
+                } else {
+                    if( count == 0 ) {
+                        start = System::currentTimeMillis();
+                    }
+                    count++;
+                    if( count % 1000 == 0 ) {
+                        std::cout << "Received " << count << " messages."
<< std::endl;
+                    }
+                }
+
+            } else {
+                std::cout << "Unexpected message type." << std::endl;
+            }
+        }
+
+        connection->close();
+    }
+
+    std::cout << "-----------------------------------------------------\n";
+    std::cout << "Finished with the example." << std::endl;
+    std::cout << "=====================================================\n";
+
+    activemq::library::ActiveMQCPP::shutdownLibrary();
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/cpp/Publisher.cpp
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/cpp/Publisher.cpp b/assembly/src/release/examples/openwire/cpp/Publisher.cpp
new file mode 100644
index 0000000..9001726
--- /dev/null
+++ b/assembly/src/release/examples/openwire/cpp/Publisher.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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 <activemq/util/Config.h>
+
+#include <decaf/lang/System.h>
+#include <decaf/lang/Runnable.h>
+#include <decaf/lang/Integer.h>
+#include <activemq/core/ActiveMQConnectionFactory.h>
+#include <activemq/library/ActiveMQCPP.h>
+#include <cms/Connection.h>
+#include <cms/Session.h>
+#include <cms/Destination.h>
+#include <cms/MessageProducer.h>
+#include <cms/TextMessage.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream>
+#include <memory>
+
+using namespace cms;
+using namespace activemq;
+using namespace activemq::core;
+using namespace decaf;
+using namespace decaf::lang;
+
+////////////////////////////////////////////////////////////////////////////////
+std::string getEnv(const std::string& key, const std::string& defaultValue) {
+
+    try{
+        return System::getenv(key);
+    } catch(...) {
+    }
+
+    return defaultValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+std::string getArg(char* argv[], int argc, int index, const std::string& defaultValue)
{
+
+    if( index < argc ) {
+        return argv[index];
+    }
+
+    return defaultValue;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int main(int argc, char* argv[]) {
+
+    activemq::library::ActiveMQCPP::initializeLibrary();
+
+    std::cout << "=====================================================\n";
+    std::cout << "Starting the Publisher example:" << std::endl;
+    std::cout << "-----------------------------------------------------\n";
+
+    std::string user = getEnv("ACTIVEMQ_USER", "admin");
+    std::string password = getEnv("ACTIVEMQ_PASSWORD", "password");
+    std::string host = getEnv("ACTIVEMQ_HOST", "localhost");
+    int port = Integer::parseInt(getEnv("ACTIVEMQ_PORT", "61616"));
+    std::string destination = getArg(argv, argc, 1, "event");
+
+    int messages = 10000;
+    int size = 256;
+
+    std::string DATA = "abcdefghijklmnopqrstuvwxyz";
+    std::string body = "";
+    for( int i=0; i < size; i ++) {
+        body += DATA.at(i%DATA.length());
+    }
+
+    {
+        ActiveMQConnectionFactory factory;
+        factory.setBrokerURI(std::string("tcp://") + host + ":" + Integer::toString(port));
+
+        std::auto_ptr<TextMessage> message;
+        std::auto_ptr<Connection> connection(factory.createConnection(user, password));
+
+        connection->start();
+
+        std::auto_ptr<Session> session(connection->createSession());
+        std::auto_ptr<Destination> dest(session->createTopic(destination));
+        std::auto_ptr<MessageProducer> producer(session->createProducer(dest.get()));
+
+        producer->setDeliveryMode(DeliveryMode::NON_PERSISTENT);
+
+        for( int i=1; i <= messages; i ++) {
+            message.reset(session->createTextMessage(body));
+            producer->send(message.get());
+            if( (i % 1000) == 0) {
+                std::cout << "Sent " << i << " messages" << std::endl;;
+            }
+        }
+
+        message.reset(session->createTextMessage("SHUTDOWN"));
+        producer->send(message.get());
+
+        connection->close();
+    }
+
+    std::cout << "-----------------------------------------------------\n";
+    std::cout << "Finished with the example." << std::endl;
+    std::cout << "=====================================================\n";
+
+    activemq::library::ActiveMQCPP::shutdownLibrary();
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/cpp/readme.md
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/cpp/readme.md b/assembly/src/release/examples/openwire/cpp/readme.md
new file mode 100644
index 0000000..3ea59ce
--- /dev/null
+++ b/assembly/src/release/examples/openwire/cpp/readme.md
@@ -0,0 +1,42 @@
+Prereqs
+=======
+
+These examples use the [ActiveMQ-CPP](http://activemq.apache.org/cms) C++ library,
+
+
+1. [Download the latest release from the ActiveMQ-CPP website)
+2. [Build and Install](http://activemq.apache.org/cms/building.html)
+
+Building
+========
+
+This will vary depending on where you installed your libraries and the compiler 
+you are using but on my Ubuntu system, I compiled the examples as follows:
+
+    gcc Listener.cpp -o listener -I/usr/local/include/activemq-cpp-3.8.1 -I/usr/include/apr-1.0
-lactivemq-cpp -lstdc++ 
+    gcc Publisher.cpp -o publisher -I/usr/local/include/activemq-cpp-3.8.1 -I/usr/include/apr-1.0
-lactivemq-cpp -lstdc++ 
+
+Running the Examples
+====================
+
+Note: You may need to update set an environment variable so that the 
+activemq-cpp shared libraries can be loaded.  For example on my Ubuntu 
+system I had to add the following to my profile:
+
+    export LD_LIBRARY_PATH=/usr/local/lib
+
+In one terminal window run:
+
+    ./listener
+
+In another terminal window run:
+
+    ./publisher
+
+You can control to which stomp server the examples try to connect to by
+setting the following environment variables: 
+
+* `ACTIVEMQ_HOST`
+* `ACTIVEMQ_PORT`
+* `ACTIVEMQ_USER`
+* `ACTIVEMQ_PASSWORD`

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/ActiveMQExamples.sln
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/ActiveMQExamples.sln
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/ActiveMQExamples.sln
new file mode 100644
index 0000000..ade0d24
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/ActiveMQExamples.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Publisher", "Publisher\Publisher.csproj",
"{0FEEC122-F3FD-4148-A461-0A724AE0C691}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listener", "Listener\Listener.csproj",
"{08413D64-4C72-4F92-9B4A-9BAECCDB6DC3}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x86 = Debug|x86
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{08413D64-4C72-4F92-9B4A-9BAECCDB6DC3}.Debug|x86.ActiveCfg = Debug|x86
+		{08413D64-4C72-4F92-9B4A-9BAECCDB6DC3}.Debug|x86.Build.0 = Debug|x86
+		{08413D64-4C72-4F92-9B4A-9BAECCDB6DC3}.Release|x86.ActiveCfg = Release|x86
+		{08413D64-4C72-4F92-9B4A-9BAECCDB6DC3}.Release|x86.Build.0 = Release|x86
+		{0FEEC122-F3FD-4148-A461-0A724AE0C691}.Debug|x86.ActiveCfg = Debug|x86
+		{0FEEC122-F3FD-4148-A461-0A724AE0C691}.Debug|x86.Build.0 = Debug|x86
+		{0FEEC122-F3FD-4148-A461-0A724AE0C691}.Release|x86.ActiveCfg = Release|x86
+		{0FEEC122-F3FD-4148-A461-0A724AE0C691}.Release|x86.Build.0 = Release|x86
+	EndGlobalSection
+	GlobalSection(MonoDevelopProperties) = preSolution
+		StartupItem = Listener\Listener.csproj
+	EndGlobalSection
+EndGlobal

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/ActiveMQExamples.userprefs
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/ActiveMQExamples.userprefs
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/ActiveMQExamples.userprefs
new file mode 100644
index 0000000..6a204c8
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/ActiveMQExamples.userprefs
@@ -0,0 +1,29 @@
+<Properties>
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
+  <MonoDevelop.Ide.Workbench ActiveDocument="Publisher/Publisher.cs">
+    <Files>
+      <File FileName="Listener/Listener.cs" Line="35" Column="17" />
+      <File FileName="Publisher/Publisher.cs" Line="21" Column="26" />
+    </Files>
+    <Pads>
+      <Pad Id="ProjectPad">
+        <State expanded="True">
+          <Node name="Listener" expanded="True">
+            <Node name="References" expanded="True" />
+          </Node>
+          <Node name="Publisher" expanded="True">
+            <Node name="References" expanded="True" />
+            <Node name="Publisher.cs" selected="True" />
+          </Node>
+        </State>
+      </Pad>
+      <Pad Id="ClassPad">
+        <State selected="True" />
+      </Pad>
+    </Pads>
+  </MonoDevelop.Ide.Workbench>
+  <MonoDevelop.Ide.DebuggingService.Breakpoints>
+    <BreakpointStore />
+  </MonoDevelop.Ide.DebuggingService.Breakpoints>
+  <MonoDevelop.Ide.DebuggingService.PinnedWatches />
+</Properties>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/AssemblyInfo.cs
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/AssemblyInfo.cs
new file mode 100644
index 0000000..a1f96a9
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/AssemblyInfo.cs
@@ -0,0 +1,44 @@
+/**
+ * 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("Listener")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly, 
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/Listener.cs
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/Listener.cs
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/Listener.cs
new file mode 100644
index 0000000..dd6c124
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/Listener.cs
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+using System;
+
+using Apache.NMS;
+using Apache.NMS.ActiveMQ;
+
+namespace ActiveMQ.Example
+{
+	class Listemer
+	{
+		public static void Main(string[] args)
+		{
+			Console.WriteLine("Starting up Listener.");			
+						
+	        String user = env("ACTIVEMQ_USER", "admin");
+	        String password = env("ACTIVEMQ_PASSWORD", "password");
+	        String host = env("ACTIVEMQ_HOST", "localhost");
+	        int port = Int32.Parse(env("ACTIVEMQ_PORT", "61616"));
+	        String destination = arg(args, 0, "event");
+	
+			String brokerUri = "activemq:tcp://" + host + ":" + port + "?transport.useLogging=true";
+	        NMSConnectionFactory factory = new NMSConnectionFactory(brokerUri);
+	
+	        IConnection connection = factory.CreateConnection(user, password);
+	        connection.Start();
+	        ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+	        IDestination dest = session.GetTopic(destination);
+	
+	        IMessageConsumer consumer = session.CreateConsumer(dest);
+	        DateTime start = DateTime.Now;
+	        long count = 0;
+	        
+			Console.WriteLine("Waiting for messages...");
+			while (true) 
+			{
+	            IMessage msg = consumer.Receive();
+	            if (msg is ITextMessage) 
+				{
+					ITextMessage txtMsg = msg as ITextMessage;
+	                String body = txtMsg.Text;
+	                if ("SHUTDOWN".Equals(body))
+					{
+	                    TimeSpan diff = DateTime.Now - start;
+	                    Console.WriteLine(String.Format("Received {0} in {1} seconds", count,
(1.0*diff.TotalMilliseconds/1000.0)));
+	                    break;
+	                } 
+					else 
+					{
+	                    if (count == 0) 
+						{
+	                        start = DateTime.Now;
+	                    }
+	                    count ++;
+	                    if (count % 1000 == 0) 
+						{
+	                        Console.WriteLine(String.Format("Received {0} messages.", count));
+	                    }
+	                }
+	
+	            }
+				else 
+				{
+	                Console.WriteLine("Unexpected message type: " + msg.GetType().Name);
+	            }
+	        }
+	        
+			Console.WriteLine("Shutting down Listener.");			
+			connection.Close();
+	    }
+	
+	    private static String env(String key, String defaultValue)
+		{
+	        String rc = System.Environment.GetEnvironmentVariable(key);
+	        if (rc == null)
+			{
+	            return defaultValue;
+			}
+	        return rc;
+	    }
+	
+	    private static String arg(String []args, int index, String defaultValue) 
+		{
+	        if (index < args.Length)
+			{
+	            return args[index];
+			}
+            return defaultValue;
+	    }
+	}
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/Listener.csproj
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/Listener.csproj
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/Listener.csproj
new file mode 100644
index 0000000..2fe971c
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/Listener.csproj
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>9.0.21022</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{08413D64-4C72-4F92-9B4A-9BAECCDB6DC3}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>Listener</RootNamespace>
+    <AssemblyName>Listener</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x86</PlatformTarget>
+    <Externalconsole>true</Externalconsole>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>none</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x86</PlatformTarget>
+    <Externalconsole>true</Externalconsole>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="Apache.NMS">
+      <HintPath>..\..\..\..\..\..\..\..\..\..\activemq\NMS.ActiveMQ\lib\Apache.NMS\mono-2.0\Apache.NMS.dll</HintPath>
+    </Reference>
+    <Reference Include="Ionic.Zlib">
+      <HintPath>..\..\..\..\..\..\..\..\..\..\activemq\NMS.ActiveMQ\lib\DotNetZip\mono-2.0\Ionic.Zlib.dll</HintPath>
+    </Reference>
+    <Reference Include="Apache.NMS.ActiveMQ">
+      <HintPath>..\..\..\..\..\..\..\..\..\..\activemq\NMS.ActiveMQ\build\mono-2.0\debug\Apache.NMS.ActiveMQ.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Listener.cs" />
+    <Compile Include="AssemblyInfo.cs" />
+    <Compile Include="NMSTracer.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/NMSTracer.cs
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/NMSTracer.cs
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/NMSTracer.cs
new file mode 100755
index 0000000..b37af66
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Listener/NMSTracer.cs
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace ActiveMQ.Example
+{
+    public class NmsTracer : Apache.NMS.ITrace
+    {
+        #region ITrace Members
+        public void Debug(string message)
+        {
+            Console.WriteLine("DEBUG: " + message);
+        }
+
+        public void Error(string message)
+        {
+            Console.WriteLine("ERROR: " + message);
+        }
+
+        public void Fatal(string message)
+        {
+            Console.WriteLine("FATAL: " + message);
+        }
+
+        public void Info(string message)
+        {
+            Console.WriteLine("INFO:  " + message);
+        }
+
+        public void Warn(string message)
+        {
+            Console.WriteLine("WARN:  " + message);
+        }
+
+        public bool IsDebugEnabled
+        {
+            get { return true; }
+        }
+
+        public bool IsErrorEnabled
+        {
+            get { return true; }
+        }
+
+        public bool IsFatalEnabled
+        {
+            get { return true; }
+        }
+
+        public bool IsInfoEnabled
+        {
+            get { return true; }
+        }
+
+        public bool IsWarnEnabled
+        {
+            get { return true; }
+        }
+
+        #endregion
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/AssemblyInfo.cs
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/AssemblyInfo.cs
new file mode 100644
index 0000000..2628d12
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/AssemblyInfo.cs
@@ -0,0 +1,44 @@
+/**
+ * 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.
+ */
+
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("Publisher")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly, 
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/NMSTracer.cs
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/NMSTracer.cs
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/NMSTracer.cs
new file mode 100755
index 0000000..b37af66
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/NMSTracer.cs
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace ActiveMQ.Example
+{
+    public class NmsTracer : Apache.NMS.ITrace
+    {
+        #region ITrace Members
+        public void Debug(string message)
+        {
+            Console.WriteLine("DEBUG: " + message);
+        }
+
+        public void Error(string message)
+        {
+            Console.WriteLine("ERROR: " + message);
+        }
+
+        public void Fatal(string message)
+        {
+            Console.WriteLine("FATAL: " + message);
+        }
+
+        public void Info(string message)
+        {
+            Console.WriteLine("INFO:  " + message);
+        }
+
+        public void Warn(string message)
+        {
+            Console.WriteLine("WARN:  " + message);
+        }
+
+        public bool IsDebugEnabled
+        {
+            get { return true; }
+        }
+
+        public bool IsErrorEnabled
+        {
+            get { return true; }
+        }
+
+        public bool IsFatalEnabled
+        {
+            get { return true; }
+        }
+
+        public bool IsInfoEnabled
+        {
+            get { return true; }
+        }
+
+        public bool IsWarnEnabled
+        {
+            get { return true; }
+        }
+
+        #endregion
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/Publisher.cs
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/Publisher.cs
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/Publisher.cs
new file mode 100644
index 0000000..2a3a88d
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/Publisher.cs
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+using System;
+
+using Apache.NMS;
+using Apache.NMS.ActiveMQ;
+
+namespace ActiveMQ.Example
+{
+	class Publisher
+	{
+		public static void Main (string[] args)
+		{
+	        String user = env("ACTIVEMQ_USER", "admin");
+	        String password = env("ACTIVEMQ_PASSWORD", "password");
+	        String host = env("ACTIVEMQ_HOST", "localhost");
+	        int port = Int32.Parse(env("ACTIVEMQ_PORT", "61616"));
+			String destination = arg(args, 0, "event");
+	
+	        int messages = 10000;
+	        int size = 256;
+	
+	        String DATA = "abcdefghijklmnopqrstuvwxyz";
+	        String body = "";
+	        for(int i=0; i < size; i ++) 
+			{
+	            body += DATA[i%DATA.Length];
+	        }
+	
+			String brokerUri = "activemq:tcp://" + host + ":" + port;
+	        NMSConnectionFactory factory = new NMSConnectionFactory(brokerUri);
+	
+	        IConnection connection = factory.CreateConnection(user, password);
+	        connection.Start();
+	        ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+	        IDestination dest = session.GetTopic(destination);
+	        IMessageProducer producer = session.CreateProducer(dest);
+	        producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
+	
+	        for (int i=1; i <= messages; i ++) 
+			{
+	            producer.Send(session.CreateTextMessage(body));
+	            if ((i % 1000) == 0) 
+				{
+	                Console.WriteLine(String.Format("Sent {0} messages", i));
+	            }
+	        }
+	
+	        producer.Send(session.CreateTextMessage("SHUTDOWN"));
+	        connection.Close();
+		}
+
+	    private static String env(String key, String defaultValue)
+		{
+	        String rc = System.Environment.GetEnvironmentVariable(key);
+	        if (rc == null)
+			{
+	            return defaultValue;
+			}
+	        return rc;
+	    }
+	
+	    private static String arg(String []args, int index, String defaultValue) 
+		{
+	        if (index < args.Length)
+			{
+	            return args[index];
+			}
+            return defaultValue;
+	    }
+	}
+}

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/Publisher.csproj
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/Publisher.csproj
b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/Publisher.csproj
new file mode 100644
index 0000000..1d4dfd7
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/ActiveMQExamples/Publisher/Publisher.csproj
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>9.0.21022</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{0FEEC122-F3FD-4148-A461-0A724AE0C691}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>Publisher</RootNamespace>
+    <AssemblyName>Publisher</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x86</PlatformTarget>
+    <Externalconsole>true</Externalconsole>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>none</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x86</PlatformTarget>
+    <Externalconsole>true</Externalconsole>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="Apache.NMS.ActiveMQ">
+      <HintPath>..\..\..\..\..\..\..\..\..\..\activemq\NMS.ActiveMQ\build\mono-2.0\debug\Apache.NMS.ActiveMQ.dll</HintPath>
+    </Reference>
+    <Reference Include="Apache.NMS">
+      <HintPath>..\..\..\..\..\..\..\..\..\..\activemq\NMS.ActiveMQ\lib\Apache.NMS\mono-2.0\Apache.NMS.dll</HintPath>
+    </Reference>
+    <Reference Include="Ionic.Zlib">
+      <HintPath>..\..\..\..\..\..\..\..\..\..\activemq\NMS.ActiveMQ\lib\DotNetZip\mono-2.0\Ionic.Zlib.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Publisher.cs" />
+    <Compile Include="AssemblyInfo.cs" />
+    <Compile Include="NMSTracer.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq/blob/a912d6d5/assembly/src/release/examples/openwire/csharp/readme.md
----------------------------------------------------------------------
diff --git a/assembly/src/release/examples/openwire/csharp/readme.md b/assembly/src/release/examples/openwire/csharp/readme.md
new file mode 100644
index 0000000..73b9ab0
--- /dev/null
+++ b/assembly/src/release/examples/openwire/csharp/readme.md
@@ -0,0 +1,33 @@
+Prereqs
+=======
+
+- Install [Apache.NMS.ActiveMQ](http://activemq.apache.org/nms/download.html) 
+
+Building
+========
+
+This will vary depending on where you installed your libraries.  Open the 
+ActiveMQExamples solution in Visual Studio and update the references for the
+Listener and Publisher project to point to where you Apache.NMS.dll,  
+Apache.NMS.ActiveMQ.dll and Ionic.Zlib.dll are located.  
+
+Build both projects in the solution.
+
+Running the Examples
+====================
+
+In one terminal window run:
+
+    ./Listener.exe
+
+In another terminal window run:
+
+    ./Publisher.exe
+
+You can control to which ActiveMQ server the examples try to connect to by
+setting the following environment variables: 
+
+* `ACTIVEMQ_HOST`
+* `ACTIVEMQ_PORT`
+* `ACTIVEMQ_USER`
+* `ACTIVEMQ_PASSWORD`


Mime
View raw message