activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r777304 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp: TestMain.cs TestMainAsync.cs
Date Thu, 21 May 2009 22:58:02 GMT
Author: jgomes
Date: Thu May 21 22:58:00 2009
New Revision: 777304

URL: http://svn.apache.org/viewvc?rev=777304&view=rev
Log:
Converted leading tabs to spaces for better web formatting display.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMain.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMainAsync.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMain.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMain.cs?rev=777304&r1=777303&r2=777304&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMain.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMain.cs Thu May
21 22:58:00 2009
@@ -15,6 +15,9 @@
  * limitations under the License.
  */
 
+// NOTE: Keep leading spaces.  Do not convert to tabs.  This file
+// is auto-linked on the NMS website as example code.
+
 // START SNIPPET: demo
 using System;
 using Apache.NMS;
@@ -22,67 +25,67 @@
 
 namespace Apache.NMS.ActiveMQ.Test
 {
-	public class TestMain
-	{
-		public static void Main(string[] args)
-		{
-			try
-			{
-				Uri connecturi = new Uri("activemq:tcp://activemqhost:61616");
-				
-				Console.WriteLine("About to connect to " + connecturi);
-
-				// NOTE: ensure the nmsprovider-activemq.config file exists in the executable folder.
-				IConnectionFactory factory = new NMSConnectionFactory(connecturi);
-
-				using(IConnection connection = factory.CreateConnection())
-				using(ISession session = connection.CreateSession())
-				{
-					/*
-					 * Examples for getting a destination:
-					 *   IDestination destination = session.GetQueue("FOO.BAR");  // Hard coded to queue
destination
-					 *   IDestination destination = session.GetTopic("FOO.BAR");  // Hard coded to topic
destination
-					 *   IDestination destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
 // Allows destination type to be embedded in name
-					 *   IDestination destination = SessionUtil.GetDestination(session, "topic://FOO.BAR");
 // Allows destination type to be embedded in name
-					 *   IDestination destination = SessionUtil.GetDestination(session, "FOO.BAR");    
     // Defaults to queue if type not specified.
-					 */
-					IDestination destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
-					Console.WriteLine("Using destination: " + destination);
-
-					// Create a consumer and producer
-					using(IMessageConsumer consumer = session.CreateConsumer(destination))
-					using(IMessageProducer producer = session.CreateProducer(destination))
-					{
-						producer.Persistent = true;
-
-						// Send a message
-						ITextMessage request = session.CreateTextMessage("Hello World!");
-						request.NMSCorrelationID = "abc";
-						request.Properties["NMSXGroupID"] = "cheese";
-						request.Properties["myHeader"] = "Cheddar";
-
-						producer.Send(request);
-
-						// Consume a message
-						ITextMessage message = consumer.Receive() as ITextMessage;
-						if(message == null)
-						{
-							Console.WriteLine("No message received!");
-						}
-						else
-						{
-							Console.WriteLine("Received message with ID:   " + message.NMSMessageId);
-							Console.WriteLine("Received message with text: " + message.Text);
-						}
-					}
-				}
-			}
-			catch(Exception e)
-			{
-				Console.WriteLine("Caught: " + e);
-				Console.WriteLine("Stack: " + e.StackTrace);
-			}
-		}
-	}
+    public class TestMain
+    {
+        public static void Main(string[] args)
+        {
+            try
+            {
+                Uri connecturi = new Uri("activemq:tcp://activemqhost:61616");
+                
+                Console.WriteLine("About to connect to " + connecturi);
+
+                // NOTE: ensure the nmsprovider-activemq.config file exists in the executable
folder.
+                IConnectionFactory factory = new NMSConnectionFactory(connecturi);
+
+                using(IConnection connection = factory.CreateConnection())
+                using(ISession session = connection.CreateSession())
+                {
+                    /*
+                     * Examples for getting a destination:
+                     *   IDestination destination = session.GetQueue("FOO.BAR");  // Hard
coded to queue destination
+                     *   IDestination destination = session.GetTopic("FOO.BAR");  // Hard
coded to topic destination
+                     *   IDestination destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
 // Allows destination type to be embedded in name
+                     *   IDestination destination = SessionUtil.GetDestination(session, "topic://FOO.BAR");
 // Allows destination type to be embedded in name
+                     *   IDestination destination = SessionUtil.GetDestination(session, "FOO.BAR");
         // Defaults to queue if type not specified.
+                     */
+                    IDestination destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
+                    Console.WriteLine("Using destination: " + destination);
+
+                    // Create a consumer and producer
+                    using(IMessageConsumer consumer = session.CreateConsumer(destination))
+                    using(IMessageProducer producer = session.CreateProducer(destination))
+                    {
+                        producer.Persistent = true;
+
+                        // Send a message
+                        ITextMessage request = session.CreateTextMessage("Hello World!");
+                        request.NMSCorrelationID = "abc";
+                        request.Properties["NMSXGroupID"] = "cheese";
+                        request.Properties["myHeader"] = "Cheddar";
+
+                        producer.Send(request);
+
+                        // Consume a message
+                        ITextMessage message = consumer.Receive() as ITextMessage;
+                        if(message == null)
+                        {
+                            Console.WriteLine("No message received!");
+                        }
+                        else
+                        {
+                            Console.WriteLine("Received message with ID:   " + message.NMSMessageId);
+                            Console.WriteLine("Received message with text: " + message.Text);
+                        }
+                    }
+                }
+            }
+            catch(Exception e)
+            {
+                Console.WriteLine("Caught: " + e);
+                Console.WriteLine("Stack: " + e.StackTrace);
+            }
+        }
+    }
 }
 // END SNIPPET: demo

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMainAsync.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMainAsync.cs?rev=777304&r1=777303&r2=777304&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMainAsync.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/TestMainAsync.cs Thu
May 21 22:58:00 2009
@@ -15,6 +15,9 @@
  * limitations under the License.
  */
 
+// NOTE: Keep leading spaces.  Do not convert to tabs.  This file
+// is auto-linked on the NMS website as example code.
+
 // START SNIPPET: demo
 using System;
 using System.Threading;
@@ -23,80 +26,80 @@
 
 namespace Apache.NMS.ActiveMQ.Test
 {
-	public class TestMain
-	{
-		protected static AutoResetEvent semaphore = new AutoResetEvent(false);
-		protected static ITextMessage message = null;
-		protected static TimeSpan receiveTimeout = TimeSpan.FromSeconds(10);
-		
-		public static void Main(string[] args)
-		{
-			try
-			{
-				Uri connecturi = new Uri("activemq:tcp://activemqhost:61616");
-				
-				Console.WriteLine("About to connect to " + connecturi);
-
-				// NOTE: ensure the nmsprovider-activemq.config file exists in the executable folder.
-				IConnectionFactory factory = new NMSConnectionFactory(connecturi);
-
-				using(IConnection connection = factory.CreateConnection())
-				using(ISession session = connection.CreateSession())
-				{
-					/*
-					 * Examples for getting a destination:
-					 *   IDestination destination = session.GetQueue("FOO.BAR");  // Hard coded to queue
destination
-					 *   IDestination destination = session.GetTopic("FOO.BAR");  // Hard coded to topic
destination
-					 *   IDestination destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
 // Allows destination type to be embedded in name
-					 *   IDestination destination = SessionUtil.GetDestination(session, "topic://FOO.BAR");
 // Allows destination type to be embedded in name
-					 *   IDestination destination = SessionUtil.GetDestination(session, "FOO.BAR");    
     // Defaults to queue if type not specified.
-					 */
-					IDestination destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
-					Console.WriteLine("Using destination: " + destination);
-
-					// Create a consumer and producer
-					using(IMessageConsumer consumer = session.CreateConsumer(destination))
-					using(IMessageProducer producer = session.CreateProducer(destination))
-					{
-						connection.Start();		// Must start the connection for async messaging.
-						producer.Persistent = true;
-						producer.RequestTimeout = receiveTimeout;
-						consumer.Listener += new MessageListener(OnMessage);
-
-						// Send a message
-						ITextMessage request = session.CreateTextMessage("Hello World!");
-						request.NMSCorrelationID = "abc";
-						request.Properties["NMSXGroupID"] = "cheese";
-						request.Properties["myHeader"] = "Cheddar";
-
-						producer.Send(request);
-
-						// Wait for the message
-						semaphore.WaitOne((int) receiveTimeout.TotalMilliseconds, true);
-						if(message == null)
-						{
-							Console.WriteLine("No message received!");
-						}
-						else
-						{
-							Console.WriteLine("Received message with ID:   " + message.NMSMessageId);
-							Console.WriteLine("Received message with text: " + message.Text);
-						}
-					}
-				}
-			}
-			catch(Exception e)
-			{
-				Console.WriteLine("Caught: " + e);
-				Console.WriteLine("Stack: " + e.StackTrace);
-			}
-		}
-
-		protected static void OnMessage(IMessage receivedMsg)
-		{
-			message = receivedMsg as ITextMessage;
-			semaphore.Set();
-		}
-	}
+    public class TestMain
+    {
+        protected static AutoResetEvent semaphore = new AutoResetEvent(false);
+        protected static ITextMessage message = null;
+        protected static TimeSpan receiveTimeout = TimeSpan.FromSeconds(10);
+        
+        public static void Main(string[] args)
+        {
+            try
+            {
+                Uri connecturi = new Uri("activemq:tcp://activemqhost:61616");
+                
+                Console.WriteLine("About to connect to " + connecturi);
+
+                // NOTE: ensure the nmsprovider-activemq.config file exists in the executable
folder.
+                IConnectionFactory factory = new NMSConnectionFactory(connecturi);
+
+                using(IConnection connection = factory.CreateConnection())
+                using(ISession session = connection.CreateSession())
+                {
+                    /*
+                     * Examples for getting a destination:
+                     *   IDestination destination = session.GetQueue("FOO.BAR");  // Hard
coded to queue destination
+                     *   IDestination destination = session.GetTopic("FOO.BAR");  // Hard
coded to topic destination
+                     *   IDestination destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
 // Allows destination type to be embedded in name
+                     *   IDestination destination = SessionUtil.GetDestination(session, "topic://FOO.BAR");
 // Allows destination type to be embedded in name
+                     *   IDestination destination = SessionUtil.GetDestination(session, "FOO.BAR");
         // Defaults to queue if type not specified.
+                     */
+                    IDestination destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
+                    Console.WriteLine("Using destination: " + destination);
+
+                    // Create a consumer and producer
+                    using(IMessageConsumer consumer = session.CreateConsumer(destination))
+                    using(IMessageProducer producer = session.CreateProducer(destination))
+                    {
+                        connection.Start();     // Must start the connection for async messaging.
+                        producer.Persistent = true;
+                        producer.RequestTimeout = receiveTimeout;
+                        consumer.Listener += new MessageListener(OnMessage);
+
+                        // Send a message
+                        ITextMessage request = session.CreateTextMessage("Hello World!");
+                        request.NMSCorrelationID = "abc";
+                        request.Properties["NMSXGroupID"] = "cheese";
+                        request.Properties["myHeader"] = "Cheddar";
+
+                        producer.Send(request);
+
+                        // Wait for the message
+                        semaphore.WaitOne((int) receiveTimeout.TotalMilliseconds, true);
+                        if(message == null)
+                        {
+                            Console.WriteLine("No message received!");
+                        }
+                        else
+                        {
+                            Console.WriteLine("Received message with ID:   " + message.NMSMessageId);
+                            Console.WriteLine("Received message with text: " + message.Text);
+                        }
+                    }
+                }
+            }
+            catch(Exception e)
+            {
+                Console.WriteLine("Caught: " + e);
+                Console.WriteLine("Stack: " + e.StackTrace);
+            }
+        }
+
+        protected static void OnMessage(IMessage receivedMsg)
+        {
+            message = receivedMsg as ITextMessage;
+            semaphore.Set();
+        }
+    }
 }
 // END SNIPPET: demo



Mime
View raw message