activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r380183 [3/3] - in /incubator/activemq/trunk/openwire-dotnet: src/OpenWire.Client/ src/OpenWire.Client/Commands/ src/OpenWire.Client/Core/ src/OpenWire.Client/IO/ tests/OpenWire.Client/
Date Thu, 23 Feb 2006 18:16:23 GMT
Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IO/WireFormatInfoMarshaller.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IO/WireFormatInfoMarshaller.cs?rev=380183&r1=380182&r2=380183&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IO/WireFormatInfoMarshaller.cs
(original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IO/WireFormatInfoMarshaller.cs
Thu Feb 23 10:16:15 2006
@@ -57,8 +57,8 @@
 
         WireFormatInfo info = (WireFormatInfo)o;
         info.Magic = ReadBytes(dataIn, 8);
-        info.Version = dataIn.ReadInt32();
-        info.Options = dataIn.ReadInt32();
+        info.Version = DataStreamMarshaller.ReadInt(dataIn);
+        info.Options = DataStreamMarshaller.ReadInt(dataIn);
 
     }
 
@@ -82,8 +82,8 @@
 
         WireFormatInfo info = (WireFormatInfo)o;
         dataOut.Write(info.Magic, 0, 8);
-        dataOut.Write((int) info.Version);
-        dataOut.Write((int) info.Options);
+        DataStreamMarshaller.WriteInt(info.Version, dataOut);
+        DataStreamMarshaller.WriteInt(info.Options, dataOut);
 
     }
   }

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IO/XATransactionIdMarshaller.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IO/XATransactionIdMarshaller.cs?rev=380183&r1=380182&r2=380183&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IO/XATransactionIdMarshaller.cs
(original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IO/XATransactionIdMarshaller.cs
Thu Feb 23 10:16:15 2006
@@ -56,7 +56,7 @@
         base.Unmarshal(wireFormat, o, dataIn, bs);
 
         XATransactionId info = (XATransactionId)o;
-        info.FormatId = dataIn.ReadInt32();
+        info.FormatId = DataStreamMarshaller.ReadInt(dataIn);
         info.GlobalTransactionId = ReadBytes(dataIn, bs.ReadBoolean());
         info.BranchQualifier = ReadBytes(dataIn, bs.ReadBoolean());
 
@@ -85,13 +85,13 @@
         base.Marshal2(wireFormat, o, dataOut, bs);
 
         XATransactionId info = (XATransactionId)o;
-        dataOut.Write((int) info.FormatId);
+        DataStreamMarshaller.WriteInt(info.FormatId, dataOut);
         if(bs.ReadBoolean()) {
-           dataOut.Write((int)info.GlobalTransactionId.Length);
+           DataStreamMarshaller.WriteInt(info.GlobalTransactionId.Length, dataOut);
            dataOut.Write(info.GlobalTransactionId);
         }
         if(bs.ReadBoolean()) {
-           dataOut.Write((int)info.BranchQualifier.Length);
+           DataStreamMarshaller.WriteInt(info.BranchQualifier.Length, dataOut);
            dataOut.Write(info.BranchQualifier);
         }
 

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs?rev=380183&r1=380182&r2=380183&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs Thu Feb
23 10:16:15 2006
@@ -1,42 +1,63 @@
 using System;
+using System.Threading;
 using OpenWire.Client.Commands;
 
-namespace OpenWire.Client {
+namespace OpenWire.Client
+{
+    /// <summary>
+    /// An object capable of receiving messages from some destination
+    /// </summary>
+    public class MessageConsumer : IMessageConsumer
+    {
+        
+        private Session session;
+        private ConsumerInfo info;
+        private bool closed;
+        
+        public event MessageHandler Listener;
+        
+        public MessageConsumer(Session session, ConsumerInfo info)
+        {
+            this.session = session;
+            this.info = info;
+        }
+        
         /// <summary>
-        /// An object capable of receiving messages from some destination
+        /// Method Dispatch
         /// </summary>
-        public class MessageConsumer : IMessageConsumer {
-
-                private Session session;
-                private ConsumerInfo info;
-                private bool closed;
-
-                public MessageConsumer(Session session, ConsumerInfo info) {
-                        this.session = session;
-                        this.info = info; 
-                }
-
-                public IMessage Receive() {
-                        CheckClosed();
-                        // TODO
-                        return null; 
-                }
-
-                public IMessage ReceiveNoWait() {
-                        CheckClosed();
-                        // TODO
-                        return null; 
-                } 
-                
-                public void Dispose() {
-                        session.DisposeOf(info.ConsumerId);
-                        closed = true;
-                }
-                
-                protected void CheckClosed() {
-                        if (closed) {
-                                throw new ConnectionClosedException();
-                        }
-                }
-        } 
+        /// <param name="message">An ActiveMQMessage</param>
+        public void Dispatch(ActiveMQMessage message)
+        {
+            Console.WriteLine("Dispatching message to consumer: " + message);
+        }
+        
+        public IMessage Receive()
+        {
+            CheckClosed();
+            Thread.Sleep(60000);
+            // TODO
+            return null;
+        }
+        
+        public IMessage ReceiveNoWait()
+        {
+            CheckClosed();
+            // TODO
+            return null;
+        }
+        
+        public void Dispose()
+        {
+            session.DisposeOf(info.ConsumerId);
+            closed = true;
+        }
+        
+        protected void CheckClosed()
+        {
+            if (closed)
+            {
+                throw new ConnectionClosedException();
+            }
+        }
+    }
 }

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs?rev=380183&r1=380182&r2=380183&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs Thu Feb
23 10:16:15 2006
@@ -1,30 +1,52 @@
 using System;
 using OpenWire.Client.Commands;
 
-namespace OpenWire.Client {
-        /// <summary>
-        /// An object capable of sending messages to some destination
-        /// </summary>
-        public class MessageProducer : IMessageProducer {
-
-                private Session session;
-                private ProducerInfo info;
-
-                public MessageProducer(Session session, ProducerInfo info) {
-                        this.session = session;
-                        this.info = info; 
-                }
-
-                public void Send(IMessage message) {
-                        Send(info.Destination, message); 
-                }
-
-                public void Send(IDestination destination, IMessage message) {
-                        session.DoSend(destination, message); 
-                } 
-                
-                public void Dispose() {
-                        session.DisposeOf(info.ProducerId);
-                }
-        } 
+namespace OpenWire.Client
+{
+    /// <summary>
+    /// An object capable of sending messages to some destination
+    /// </summary>
+    public class MessageProducer : IMessageProducer
+    {
+        
+        private Session session;
+        private ProducerInfo info;
+        private long messageCounter;
+        
+        
+        public MessageProducer(Session session, ProducerInfo info)
+        {
+            this.session = session;
+            this.info = info;
+        }
+        
+        public void Send(IMessage message)
+        {
+            Send(info.Destination, message);
+        }
+        
+        public void Send(IDestination destination, IMessage message)
+        {
+            MessageId id = new MessageId();
+            id.ProducerId = info.ProducerId;
+            lock (this)
+            {
+                id.ProducerSequenceId = ++messageCounter;
+            }
+            ActiveMQMessage activeMessage = (ActiveMQMessage) message;
+            activeMessage.MessageId = id;
+            activeMessage.ProducerId = info.ProducerId;
+            activeMessage.Destination = (ActiveMQDestination) destination;
+            
+            Console.WriteLine("About to send message with MessageId: " + activeMessage.MessageId);
+            Console.WriteLine("About to send message with ProducerId: " + activeMessage.ProducerId);
+            Console.WriteLine("About to send message with Destination: " + activeMessage.Destination);
+            session.DoSend(destination, message);
+        }
+        
+        public void Dispose()
+        {
+            session.DisposeOf(info.ProducerId);
+        }
+    }
 }

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs?rev=380183&r1=380182&r2=380183&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs Thu Feb 23 10:16:15
2006
@@ -2,102 +2,170 @@
 using OpenWire.Client.Commands;
 using OpenWire.Client.Core;
 
-namespace OpenWire.Client {
+namespace OpenWire.Client
+{
+    /// <summary>
+    /// Default provider of ISession
+    /// </summary>
+    public class Session : ISession
+    {
+        private Connection connection;
+        private AcknowledgementMode acknowledgementMode;
+        private SessionInfo info;
+        private long consumerCounter;
+        private long producerCounter;
+        private int prefetchSize = 1000;
+        
+        public Session(Connection connection, SessionInfo info)
+        {
+            this.connection = connection;
+            this.info = info;
+        }
+        
+        public void Dispose()
+        {
+            DisposeOf(info.SessionId);
+        }
+        
+        public IMessageProducer CreateProducer()
+        {
+            return CreateProducer(null);
+        }
+        
+        public IMessageProducer CreateProducer(IDestination destination)
+        {
+            ProducerInfo command = CreateProducerInfo(destination);
+            connection.SyncRequest(command);
+            return new MessageProducer(this, command);
+        }
+        
+        public void Acknowledge(Message message)
+        {
+            if (acknowledgementMode == AcknowledgementMode.ClientAcknowledge)
+            {
+                MessageAck ack = new MessageAck();
+                // TODO complete packet
+                connection.SyncRequest(ack);
+            }
+        }
+        
+        public IMessageConsumer CreateConsumer(IDestination destination)
+        {
+            return CreateConsumer(destination, null);
+        }
+        
+        public IMessageConsumer CreateConsumer(IDestination destination, string selector)
+        {
+            ConsumerInfo command = CreateConsumerInfo(destination, selector);
+            connection.SyncRequest(command);
+            MessageConsumer consumer = new MessageConsumer(this, command);
+            connection.AddConsumer(command.ConsumerId, consumer);
+            return consumer;
+        }
+        
+        public IQueue GetQueue(string name)
+        {
+            return new ActiveMQQueue(name);
+        }
+        
+        public ITopic GetTopic(string name)
+        {
+            return new ActiveMQTopic(name);
+        }
+        
+        public IMessage CreateMessage()
+        {
+            ActiveMQMessage answer = new ActiveMQMessage();
+            Configure(answer);
+            return answer;
+        }
+        
+        
+        public ITextMessage CreateTextMessage()
+        {
+            ActiveMQTextMessage answer = new ActiveMQTextMessage();
+            Configure(answer);
+            return answer;
+        }
+        
+        public ITextMessage CreateTextMessage(string text)
+        {
+            ActiveMQTextMessage answer = new ActiveMQTextMessage(text);
+            Configure(answer);
+            return answer;
+        }
+        
+        // Implementation methods
+        public void DoSend(IDestination destination, IMessage message)
+        {
+            ActiveMQMessage command = ActiveMQMessage.Transform(message);
+            // TODO complete packet
+            connection.SyncRequest(command);
+        }
+        
+        public void DisposeOf(DataStructure objectId)
+        {
+            Console.WriteLine("Disposing of session: " + objectId + " with datatype: " +
objectId.GetDataStructureType());
+            /*
+             RemoveInfo command = new RemoveInfo();
+             command.ObjectId = objectId;
+             connection.SyncRequest(command);
+             */
+        }
+        
+        public void DisposeOf(ConsumerId objectId)
+        {
+            Console.WriteLine("Disposing of consumer: " + objectId);
+            connection.RemoveConsumer(objectId);
+            /*
+             RemoveInfo command = new RemoveInfo();
+             command.ObjectId = objectId;
+             connection.SyncRequest(command);
+             */
+        }
+        
+        protected ConsumerInfo CreateConsumerInfo(IDestination destination, string selector)
+        {
+            ConsumerInfo answer = new ConsumerInfo();
+            ConsumerId id = new ConsumerId();
+            id.ConnectionId = info.SessionId.ConnectionId;
+            id.SessionId = info.SessionId.Value;
+            lock (this)
+            {
+                id.Value = ++consumerCounter;
+            }
+            answer.ConsumerId = id;
+            answer.Destination = (ActiveMQDestination) destination;
+            answer.Selector = selector;
+            answer.PrefetchSize = prefetchSize;
+            
+            // TODO configure other features on the consumer
+            return answer;
+        }
+        
+        protected ProducerInfo CreateProducerInfo(IDestination destination)
+        {
+            ProducerInfo answer = new ProducerInfo();
+            ProducerId id = new ProducerId();
+            id.ConnectionId = info.SessionId.ConnectionId;
+            id.SessionId = info.SessionId.Value;
+            lock (this)
+            {
+                id.Value = ++producerCounter;
+            }
+            answer.ProducerId = id;
+            answer.Destination = (ActiveMQDestination) destination;
+            return answer;
+        }
+        
         /// <summary>
-        /// Default provider of ISession
+        /// Configures the message command
         /// </summary>
-        public class Session : ISession {
-                private Connection connection;
-                private AcknowledgementMode acknowledgementMode;
-                private SessionInfo info;
-                private long consumerCounter;
-
-                public Session(Connection connection, SessionInfo info) {
-                        this.connection = connection;
-                        this.info = info; 
-                }
-
-                public void Dispose() {
-                        DisposeOf(info.SessionId); 
-                }
-
-                public IMessageProducer CreateProducer() {
-                        return CreateProducer(null); 
-                }
-
-                public IMessageProducer CreateProducer(IDestination destination) {
-                        ProducerInfo command = CreateProducerInfo(destination);
-                        connection.SyncRequest(command);
-                        return new MessageProducer(this, command); 
-                }
-
-                public void Acknowledge(Message message) {
-                        if (acknowledgementMode == AcknowledgementMode.ClientAcknowledge)
{
-                                MessageAck ack = new MessageAck();
-                                // TODO complete packet
-                                connection.SyncRequest(ack); 
-                        } 
-                }
-
-                public IMessageConsumer CreateConsumer(IDestination destination) {
-                        return CreateConsumer(destination, null); 
-                }
-
-                public IMessageConsumer CreateConsumer(IDestination destination, string selector)
{
-                        ConsumerInfo command = CreateConsumerInfo(destination, selector);
-                        connection.SyncRequest(command);
-                        return new MessageConsumer(this, command); 
-                }
-
-                public IQueue GetQueue(string name) {
-                        return new ActiveMQQueue(name); 
-                }
-
-                public ITopic GetTopic(string name) {
-                        return new ActiveMQTopic(name); 
-                }
-
-                public IMessage CreateMessage() {
-                        return new ActiveMQMessage(); 
-                }
-
-                public ITextMessage CreateTextMessage() {
-                        return new ActiveMQTextMessage(); 
-                }
-
-                public ITextMessage CreateTextMessage(string text) {
-                        return new ActiveMQTextMessage(text); 
-                }
-
-                // Implementation methods
-                public void DoSend(IDestination destination, IMessage message) {
-                        ActiveMQMessage command = ActiveMQMessage.Transform(message);
-                        // TODO complete packet
-                        connection.SyncRequest(command); 
-                }
-
-                public void DisposeOf(DataStructure objectId) {
-                        RemoveInfo command = new RemoveInfo();
-                        command.ObjectId = objectId;
-                        connection.SyncRequest(command); 
-                }
-
-                protected ConsumerInfo CreateConsumerInfo(IDestination destination, string
selector) {
-                        ConsumerInfo answer = new ConsumerInfo();
-                        ConsumerId consumerId = new ConsumerId();
-                        consumerId.SessionId = info.SessionId.Value;
-                        lock (this) {
-                                consumerId.Value = ++consumerCounter; 
-                        }
-                        // TODO complete packet
-                        answer.ConsumerId = consumerId;
-                        return answer; 
-                }
-
-                protected ProducerInfo CreateProducerInfo(IDestination destination) {
-                        ProducerInfo info = new ProducerInfo();
-                        // TODO complete packet
-                        return info; 
-                } 
-        } 
+        /// <param name="activeMQMessage">An ActiveMQMessage</param>
+        /// <returns>An IMessage</retutns>
+        protected void Configure(ActiveMQMessage message)
+        {
+        }
+        
+    }
 }

Modified: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs?rev=380183&r1=380182&r2=380183&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/ClientTest.cs Thu Feb 23
10:16:15 2006
@@ -4,39 +4,84 @@
 using NUnit.Framework;
 
 using OpenWire.Client;
+using OpenWire.Client.Core;
 
-namespace OpenWire.Client {
-
-        [ TestFixture ]
-        public class ClientTest : TestSupport {
-
-                [ Test ]
-                public void SendAndSyncReceive() {
-                        IConnectionFactory factory = new ConnectionFactory("localhost", 61616);
-                        
-                        Assert.IsTrue(factory != null, "created valid factory: " + factory);
+namespace OpenWire.Client
+{
+    
+    [ TestFixture ]
+    public class ClientTest : TestSupport
+    {
+        
+        [ Test ]
+        public void CreateOpenWireFormat()
+        {
+            OpenWireFormat format = new OpenWireFormat();
+            Assert.IsTrue(format != null);
+        }
+        
+        [ Test ]
+        public void CreateConnectionFactory()
+        {
+            IConnectionFactory factory = new ConnectionFactory("localhost", 61616);
+            Assert.IsTrue(factory != null, "created valid factory: " + factory);
+        }
+        
+        [ Test ]
+        public void SendAndSyncReceive()
+        {
+            IConnectionFactory factory = new ConnectionFactory("localhost", 61616);
+            
+            Assert.IsTrue(factory != null, "no factory created");
+            
+            Console.WriteLine("Worked!");
+            
+            using (IConnection connection = factory.CreateConnection())
+            {
+                try
+                {
+                    Assert.IsTrue(connection != null, "no connection created");
+                    Console.WriteLine("Created a connection!");
+                    
+                    ISession session = connection.CreateSession();
+                    Console.WriteLine("Created a session: " + session);
+                    
+                    IDestination destination = session.GetQueue("FOO.BAR");
+                    Assert.IsTrue(destination != null, "No queue available!");
+                    Console.WriteLine("Using destination: " + destination);
+                    
+                    IMessageConsumer consumer = session.CreateConsumer(destination);
+                    Console.WriteLine("Created consumer!: " + consumer);
+                    
+                    IMessageProducer producer = session.CreateProducer(destination);
+                    Console.WriteLine("Created producer!: " + producer);
+                    
+                    string expected = "Hello World!";
+                    ITextMessage request = session.CreateTextMessage(expected);
+                    Console.WriteLine("### About to send message: " + request);
+                    
+                    producer.Send(request);
+                    Console.WriteLine("### Sent message!");
+                    
+                    ITextMessage message = (ITextMessage) consumer.Receive();
+                    if (message == null)
+                    {
+                        Console.WriteLine("### No message!!");
+                    }
+                    else
+                    {
+                        Console.WriteLine("### Received message: " + message + " of type:
" + message.GetType());
+                        String actual = message.Text;
                         
-                        Console.WriteLine("Worked!");
-                        
-                        using (IConnection connection = factory.CreateConnection()) {
-                                ISession session = connection.CreateSession();
-                                Console.WriteLine("Created a session: " + session);
-                                
-                                IDestination destination = session.GetQueue("FOO.BAR");
-                                Assert.IsTrue(destination != null, "No queue available!");
-                                Console.WriteLine("Using destination: " + destination);
-
-                                IMessageConsumer consumer = session.CreateConsumer(destination);
-                                
-                                IMessageProducer producer = session.CreateProducer(destination);
-                                string expected = "Hello World!";
-                                ITextMessage request = session.CreateTextMessage(expected);
-                                producer.Send(request);
-                                
-                                ITextMessage message = (ITextMessage) consumer.Receive();
-                                
-                                Assert.AreEqual(expected, message.Text); 
-                        } 
-                } 
-        } 
+                        Console.WriteLine("### Message text is: " + actual);
+                    }
+                }
+                catch (Exception e)
+                {
+                    Console.WriteLine("Caught: " + e);
+                }
+            }
+        }
+    }
 }
+

Added: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/EndianTest.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/EndianTest.cs?rev=380183&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/EndianTest.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/EndianTest.cs Thu Feb 23
10:16:15 2006
@@ -0,0 +1,60 @@
+using NUnit.Framework;
+using OpenWire.Client.Core;
+using System;
+
+namespace openwire_dotnet
+{
+    [TestFixture]
+    public class EndianTest
+    {
+        
+        [Test]
+        public void TestLongEndian()
+        {
+            long value = 0x0102030405060708l;
+            
+            long newValue = DataStreamMarshaller.SwitchEndian(value);
+            
+            Console.WriteLine("New value: " + newValue);
+            
+            Assert.AreEqual(0x0807060504030201L, newValue);
+            
+            long actual = DataStreamMarshaller.SwitchEndian(newValue);
+            
+            Assert.AreEqual(value, actual);
+        }
+        
+        [Test]
+        public void TestIntEndian()
+        {
+            int value = 0x12345678;
+            
+            int newValue = DataStreamMarshaller.SwitchEndian(value);
+            
+            Console.WriteLine("New value: " + newValue);
+            
+            Assert.AreEqual(0x78563412, newValue);
+            
+            int actual = DataStreamMarshaller.SwitchEndian(newValue);
+            
+            Assert.AreEqual(value, actual);
+        }
+        [Test]
+        public void TestShortEndian()
+        {
+            short value = 0x1234;
+            
+            short newValue = DataStreamMarshaller.SwitchEndian(value);
+            
+            Console.WriteLine("New value: " + newValue);
+            
+            Assert.AreEqual(0x3412, newValue);
+            
+            short actual = DataStreamMarshaller.SwitchEndian(newValue);
+            
+            Assert.AreEqual(value, actual);
+        }
+    }
+}
+
+

Added: incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/TestMain.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/TestMain.cs?rev=380183&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/TestMain.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/tests/OpenWire.Client/TestMain.cs Thu Feb 23
10:16:15 2006
@@ -0,0 +1,59 @@
+using System;
+using System.IO;
+
+using OpenWire.Client;
+using OpenWire.Client.Core;
+
+namespace openwire_dotnet
+{
+    public class TestMain
+    {
+        public static void Main(string[] args)
+        {
+            try
+            {
+                Console.WriteLine("About to connect to ActiveMQ");
+                
+                IConnectionFactory factory = new ConnectionFactory("localhost", 61616);
+                
+                Console.WriteLine("Worked!");
+                
+                using (IConnection connection = factory.CreateConnection())
+                {
+                    Console.WriteLine("Created a connection!");
+                    
+                    ISession session = connection.CreateSession();
+                    Console.WriteLine("Created a session: " + session);
+                    
+                    IDestination destination = session.GetQueue("FOO.BAR");
+                    Console.WriteLine("Using destination: " + destination);
+                    
+                    IMessageConsumer consumer = session.CreateConsumer(destination);
+                    
+                    IMessageProducer producer = session.CreateProducer(destination);
+                    string expected = "Hello World!";
+                    ITextMessage request = session.CreateTextMessage(expected);
+                    producer.Send(request);
+                    
+                    ITextMessage message = (ITextMessage) consumer.Receive();
+                    if (message == null)
+                    {
+                        Console.WriteLine("### No message!!");
+                    }
+                    else
+                    {
+                        Console.WriteLine("### Received message: " + message + " of type:
" + message.GetType());
+                        String actual = message.Text;
+                        
+                        Console.WriteLine("### Message text is: " + actual);
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine("Caught: " + e);
+                Console.WriteLine("Stack: " + e.StackTrace);
+            }
+        }
+    }
+}



Mime
View raw message