activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1062066 - in /activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp: ./ ApolloExamples/ ApolloExamples/Listener/ ApolloExamples/Publisher/
Date Fri, 21 Jan 2011 23:08:21 GMT
Author: tabish
Date: Fri Jan 21 23:08:21 2011
New Revision: 1062066

URL: http://svn.apache.org/viewvc?rev=1062066&view=rev
Log:
Add example showing how to use the Apache.NMS.Stomp client to connect from .NET applications.

Added:
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.sln
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.userprefs
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/AssemblyInfo.cs
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.cs
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.csproj
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/NMSTracer.cs
  (with props)
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/AssemblyInfo.cs
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/NMSTracer.cs
  (with props)
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.cs
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.csproj
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/readme.md

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.sln
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.sln?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.sln
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.sln
Fri Jan 21 23:08:21 2011
@@ -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

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.userprefs
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.userprefs?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.userprefs
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/ApolloExamples.userprefs
Fri Jan 21 23:08:21 2011
@@ -0,0 +1,30 @@
+<Properties>
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" ctype="Workspace" />
+  <MonoDevelop.Ide.Workbench ActiveDocument="Publisher/Publisher.cs" ctype="Workbench">
+    <Files>
+      <File FileName="Listener/Listener.cs" Line="51" Column="48" />
+      <File FileName="Publisher/Publisher.cs" Line="35" Column="30" />
+    </Files>
+    <Pads>
+      <Pad Id="ProjectPad">
+        <State expanded="True">
+          <Node name="Listener" expanded="True">
+            <Option id="ShowVersionControlOverlays" value="True" />
+            <Option id="ShowAllFiles" value="False" />
+          </Node>
+          <Node name="Publisher" expanded="True" selected="True">
+            <Option id="ShowVersionControlOverlays" value="True" />
+            <Option id="ShowAllFiles" value="False" />
+          </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 ctype="PinnedWatchStore" />
+</Properties>
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/AssemblyInfo.cs?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/AssemblyInfo.cs
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/AssemblyInfo.cs
Fri Jan 21 23:08:21 2011
@@ -0,0 +1,27 @@
+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("")]
+

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.cs?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.cs
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.cs
Fri Jan 21 23:08:21 2011
@@ -0,0 +1,105 @@
+/*
+ * 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.Stomp;
+
+namespace Apollo.Example
+{
+	class Listemer
+	{
+		public static void Main(string[] args)
+		{
+			Console.WriteLine("Starting up Listener.");			
+						
+	        String user = env("STOMP_USER", "admin");
+	        String password = env("STOMP_PASSWORD", "password");
+	        String host = env("STOMP_HOST", "localhost");
+	        int port = Int32.Parse(env("STOMP_PORT", "61613"));
+	        String destination = arg(args, 0, "event");
+	
+			String brokerUri = "stomp: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;
+	        
+			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;
+	    }
+	}
+}

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.csproj?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.csproj
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/Listener.csproj
Fri Jan 21 23:08:21 2011
@@ -0,0 +1 @@
+<?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</War
 ningLevel>
    <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, Version=1.5.0.2196,
Culture=neutral, PublicKeyToken=82756feee3957618">
      <SpecificVersion>False</SpecificVersion>
     <HintPath>..\..\..\dev\activemq\NMS.Stomp\build\mono-2.0\debug\Apache.NMS.dll</HintPath>
   </Reference>
    <Reference Include="Apache.NMS.Stomp, Version=1.6.0.2211, Culture=neutral,
PublicKeyToken=82756feee3957618">
      <SpecificVersion>False</SpecificVersion>
     <HintPath>..\..\..\dev\activemq\
 NMS.Stomp\build\mono-2.0\debug\Apache.NMS.Stomp.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

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/NMSTracer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/NMSTracer.cs?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/NMSTracer.cs
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/NMSTracer.cs
Fri Jan 21 23:08:21 2011
@@ -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 Apollo.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
+    }
+}
+

Propchange: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Listener/NMSTracer.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/AssemblyInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/AssemblyInfo.cs?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/AssemblyInfo.cs
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/AssemblyInfo.cs
Fri Jan 21 23:08:21 2011
@@ -0,0 +1,27 @@
+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("")]
+

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/NMSTracer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/NMSTracer.cs?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/NMSTracer.cs
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/NMSTracer.cs
Fri Jan 21 23:08:21 2011
@@ -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 Apollo.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
+    }
+}
+

Propchange: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/NMSTracer.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.cs?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.cs
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.cs
Fri Jan 21 23:08:21 2011
@@ -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.Stomp;
+
+namespace Apollo.Example
+{
+	class Publisher
+	{
+		public static void Main (string[] args)
+		{
+	        String user = env("STOMP_USER", "admin");
+	        String password = env("STOMP_PASSWORD", "password");
+	        String host = env("STOMP_HOST", "localhost");
+	        int port = Int32.Parse(env("STOMP_PORT", "61613"));
+			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 = "stomp: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;
+	    }
+	}
+}

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.csproj?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.csproj
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/ApolloExamples/Publisher/Publisher.csproj
Fri Jan 21 23:08:21 2011
@@ -0,0 +1 @@
+<?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</W
 arningLevel>
    <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, Version=1.5.0.2196,
Culture=neutral, PublicKeyToken=82756feee3957618">
      <SpecificVersion>False</SpecificVersion>
     <HintPath>..\..\..\dev\activemq\NMS.Stomp\build\mono-2.0\debug\Apache.NMS.dll</HintPath>
   </Reference>
    <Reference Include="Apache.NMS.Stomp, Version=1.6.0.2211, Culture=neutral,
PublicKeyToken=82756feee3957618">
      <SpecificVersion>False</SpecificVersion>
     <HintPath>..\..\..\dev\activem
 q\NMS.Stomp\build\mono-2.0\debug\Apache.NMS.Stomp.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

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/readme.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/readme.md?rev=1062066&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/readme.md
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/csharp/readme.md
Fri Jan 21 23:08:21 2011
@@ -0,0 +1,31 @@
+Prereqs
+=======
+
+- Install [Apache.NMS.Stomp](http://activemq.apache.org/nms/download.html) 
+
+Building
+========
+
+This will vary depending on where you installed your libraries.  Open the 
+ApolloExamples solution in Visual Studio and upadte the references for the
+Listener and Publisher project to point to where you Apache.NMS.dll and 
+Apache.NMS.Stomp.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 stomp server the examples try to connect to by
+setting the following environment variables: 
+
+* `STOMP_HOST`
+* `STOMP_PORT`
+* `STOMP_USER`
+* `STOMP_PASSWORD`



Mime
View raw message