You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by js...@apache.org on 2006/01/10 14:57:51 UTC

svn commit: r367605 - in /incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client: ./ Commands/ Core/

Author: jstrachan
Date: Tue Jan 10 05:56:34 2006
New Revision: 367605

URL: http://svn.apache.org/viewcvs?rev=367605&view=rev
Log:
added first cut of a near complete OpenWire.Net API with a shell of an implementation

Added:
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQDestination.cs
      - copied, changed from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQDestination.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQQueue.cs
      - copied, changed from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQQueue.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempQueue.cs
      - copied, changed from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempQueue.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempTopic.cs
      - copied, changed from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempTopic.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTopic.cs
      - copied, changed from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTopic.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConnectionClosedException.cs   (with props)
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConsumerClosedException.cs   (with props)
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs   (with props)
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageConsumer.cs   (with props)
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageProducer.cs   (with props)
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs   (with props)
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs   (with props)
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs   (with props)
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/OpenWireException.cs   (with props)
Removed:
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQDestination.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQQueue.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempQueue.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempTopic.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTopic.cs
Modified:
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTextMessage.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Connection.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ISession.cs
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs

Copied: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQDestination.cs (from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQDestination.cs)
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQDestination.cs?p2=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQDestination.cs&p1=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQDestination.cs&r1=367585&r2=367605&rev=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQDestination.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQDestination.cs Tue Jan 10 05:56:34 2006
@@ -2,7 +2,7 @@
 using OpenWire.Client.Commands;
 using OpenWire.Client.Core;
 
-namespace OpenWire.Client.Core {
+namespace OpenWire.Client.Commands {
         
         /// <summary>
         /// Summary description for ActiveMQDestination.
@@ -177,7 +177,7 @@
                  * @return @throws JMSException
                  * @throws javax.jms.JMSException
                  */
-                public static ActiveMQDestination transformDestination(IDestination destination) {
+                public static ActiveMQDestination Transform(IDestination destination) {
                         ActiveMQDestination result = null;
                         if (destination != null) {
                                 if (destination is ActiveMQDestination) {

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs?rev=367605&r1=367604&r2=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQMessage.cs Tue Jan 10 05:56:34 2006
@@ -13,26 +13,32 @@
 using OpenWire.Client;
 using OpenWire.Client.Core;
 
-namespace OpenWire.Client.Commands
-{
-    public class ActiveMQMessage : Message
-    {
-    			public const byte ID_ActiveMQMessage = 23;
-    			
+namespace OpenWire.Client.Commands {
+        public class ActiveMQMessage : Message, IMessage {
+                public const byte ID_ActiveMQMessage = 23;
+
+                public static ActiveMQMessage Transform(IMessage message) {
+                        return (ActiveMQMessage) message;
+                }
+
+                // TODO generate Equals method
+                // TODO generate GetHashCode method
+                // TODO generate ToString method
+
+                public override byte GetCommandType() {
+                        return ID_ActiveMQMessage; 
+                }
+
+
+                // Properties
+                public IDestination FromDestination {
+                        get {
+                                return Destination;
+                        }
+                        set {
+                                this.Destination = ActiveMQDestination.Transform(value);
+                        }
+                }
 
-
-
-        // TODO generate Equals method
-        // TODO generate GetHashCode method
-        // TODO generate ToString method
-
-
-        public override byte GetCommandType() {
-            return ID_ActiveMQMessage;
-        }
-
-
-        // Properties
-
-    }
+        } 
 }

Copied: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQQueue.cs (from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQQueue.cs)
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQQueue.cs?p2=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQQueue.cs&p1=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQQueue.cs&r1=367585&r2=367605&rev=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQQueue.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQQueue.cs Tue Jan 10 05:56:34 2006
@@ -3,7 +3,7 @@
 using OpenWire.Client.Commands;
 using OpenWire.Client.Core;
 
-namespace OpenWire.Client.Core {
+namespace OpenWire.Client.Commands {
         /// <summary>
         /// Summary description for ActiveMQQueue.
         /// </summary>

Copied: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempQueue.cs (from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempQueue.cs)
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempQueue.cs?p2=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempQueue.cs&p1=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempQueue.cs&r1=367585&r2=367605&rev=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempQueue.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempQueue.cs Tue Jan 10 05:56:34 2006
@@ -3,7 +3,7 @@
 using OpenWire.Client.Commands;
 using OpenWire.Client.Core;
 
-namespace OpenWire.Client.Core {
+namespace OpenWire.Client.Commands {
         /// <summary>
         /// Summary description for ActiveMQTempQueue.
         /// </summary>

Copied: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempTopic.cs (from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempTopic.cs)
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempTopic.cs?p2=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempTopic.cs&p1=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempTopic.cs&r1=367585&r2=367605&rev=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTempTopic.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTempTopic.cs Tue Jan 10 05:56:34 2006
@@ -3,7 +3,7 @@
 using OpenWire.Client.Commands;
 using OpenWire.Client.Core;
 
-namespace OpenWire.Client.Core {
+namespace OpenWire.Client.Commands {
         /// <summary>
         /// Summary description for ActiveMQTempTopic.
         /// </summary>

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTextMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTextMessage.cs?rev=367605&r1=367604&r2=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTextMessage.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTextMessage.cs Tue Jan 10 05:56:34 2006
@@ -13,26 +13,34 @@
 using OpenWire.Client;
 using OpenWire.Client.Core;
 
-namespace OpenWire.Client.Commands
-{
-    public class ActiveMQTextMessage : ActiveMQMessage
-    {
-    			public const byte ID_ActiveMQTextMessage = 28;
-    			
+namespace OpenWire.Client.Commands {
+        public class ActiveMQTextMessage : ActiveMQMessage, ITextMessage {
+                public const byte ID_ActiveMQTextMessage = 28;
 
 
+                private String text;
 
-        // TODO generate Equals method
-        // TODO generate GetHashCode method
-        // TODO generate ToString method
 
+                // TODO generate Equals method
+                // TODO generate GetHashCode method
+                // TODO generate ToString method
 
-        public override byte GetCommandType() {
-            return ID_ActiveMQTextMessage;
-        }
 
+                public override byte GetCommandType() {
+                        return ID_ActiveMQTextMessage; 
+                }
 
-        // Properties
 
-    }
+                // Properties
+
+                public string Text {
+                        get {
+                                if (text == null) {
+                                        // TODO parse from the content
+                                }
+                                return text; 
+                        }
+                        set { this.text = value; } 
+                } 
+        } 
 }

Copied: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTopic.cs (from r367585, incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTopic.cs)
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTopic.cs?p2=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTopic.cs&p1=incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTopic.cs&r1=367585&r2=367605&rev=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Core/ActiveMQTopic.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Commands/ActiveMQTopic.cs Tue Jan 10 05:56:34 2006
@@ -3,7 +3,7 @@
 using OpenWire.Client.Commands;
 using OpenWire.Client.Core;
 
-namespace OpenWire.Client.Core {
+namespace OpenWire.Client.Commands {
         /// <summary>
         /// Summary description for ActiveMQTopic.
         /// </summary>

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Connection.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Connection.cs?rev=367605&r1=367604&r2=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Connection.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Connection.cs Tue Jan 10 05:56:34 2006
@@ -9,10 +9,18 @@
         /// </summary>
         public class Connection : IConnection {
 
+                private ConnectionInfo info;
                 private Transport transport;
                 IList sessions = new ArrayList();
                 private bool transacted;
+                private bool closed;
                 private AcknowledgementMode acknowledgementMode;
+                private long sessionCounter;
+
+                public Connection(Transport transport, ConnectionInfo info) {
+                        this.transport = transport;
+                        this.info = info; 
+                }
 
                 /// <summary>
                 /// Creates a new session to work on this connection
@@ -25,15 +33,19 @@
                 /// Creates a new session to work on this connection
                 /// </summary>
                 public ISession CreateSession(bool transacted, AcknowledgementMode acknowledgementMode) {
-                        Session session = new Session(this, acknowledgementMode);
+                        CheckClosed();
+                        SessionInfo info = CreateSessionInfo(transacted, acknowledgementMode);
+                        Session session = new Session(this, info);
                         sessions.Add(session);
                         return session; 
                 }
 
                 public void Dispose() {
                         foreach (Session session in sessions) {
-                                session.Dispose();
+                                session.Dispose(); 
                         }
+                        sessions.Clear();
+                        closed = true; 
                 }
 
                 // Properties
@@ -51,6 +63,40 @@
                 public AcknowledgementMode AcknowledgementMode {
                         get { return acknowledgementMode; }
                         set { this.acknowledgementMode = value; } 
+                }
+
+                // Implementation methods
+
+                /// <summary>
+                /// Performs a synchronous request-response with the broker
+                /// </summary>
+                public Response SyncRequest(Command command) {
+                        CheckClosed();
+                        Response response = Transport.Request(command);
+                        if (response is ExceptionResponse) {
+                                ExceptionResponse exceptionResponse = (ExceptionResponse) response;
+                                // TODO include stack trace
+                                throw new OpenWireException("Request failed: " + exceptionResponse); 
+                        }
+                        return response; 
+                }
+
+
+                protected SessionInfo CreateSessionInfo(bool transacted, AcknowledgementMode acknowledgementMode) {
+                        SessionInfo answer = new SessionInfo();
+                        SessionId sessionId = new SessionId();
+                        sessionId.ConnectionId = info.ConnectionId.Value;
+                        lock (this) {
+                                sessionId.Value = ++sessionCounter; 
+                        }
+                        answer.SessionId = sessionId;
+                        return answer; 
+                }
+
+                protected void CheckClosed() {
+                        if (closed) {
+                                throw new ConnectionClosedException(); 
+                        } 
                 } 
         } 
 }

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConnectionClosedException.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConnectionClosedException.cs?rev=367605&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConnectionClosedException.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConnectionClosedException.cs Tue Jan 10 05:56:34 2006
@@ -0,0 +1,14 @@
+using System;
+using System.Collections;
+using OpenWire.Client.Commands;
+using OpenWire.Client.Core;
+
+namespace OpenWire.Client {
+        /// <summary>
+        /// Exception thrown when a connection is used that it already closed
+        /// </summary>
+        public class ConnectionClosedException : OpenWireException {
+                public ConnectionClosedException() : base("The connection is already closed!") {
+                }
+        } 
+}

Propchange: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConnectionClosedException.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConsumerClosedException.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConsumerClosedException.cs?rev=367605&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConsumerClosedException.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConsumerClosedException.cs Tue Jan 10 05:56:34 2006
@@ -0,0 +1,14 @@
+using System;
+using System.Collections;
+using OpenWire.Client.Commands;
+using OpenWire.Client.Core;
+
+namespace OpenWire.Client {
+        /// <summary>
+        /// Exception thrown when a consumer is used that it already closed
+        /// </summary>
+        public class ConsumerClosedException : OpenWireException {
+                public ConsumerClosedException() : base("The consumer is already closed!") {
+                }
+        } 
+}

Propchange: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ConsumerClosedException.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs?rev=367605&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs Tue Jan 10 05:56:34 2006
@@ -0,0 +1,14 @@
+using System;
+using OpenWire.Client.Commands;
+
+namespace OpenWire.Client {
+        /// <summary>
+        /// Represents a message either to be sent to a message broker or received from a message broker
+        /// </summary>
+        public interface IMessage {
+
+                IDestination FromDestination {
+                        get;
+                } 
+        } 
+}

Propchange: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessage.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageConsumer.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageConsumer.cs?rev=367605&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageConsumer.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageConsumer.cs Tue Jan 10 05:56:34 2006
@@ -0,0 +1,21 @@
+using System;
+using OpenWire.Client.Commands;
+
+namespace OpenWire.Client {
+        /// <summary>
+        /// A consumer of messages
+        /// </summary>
+        public interface IMessageConsumer : IDisposable {
+
+                /// <summary>
+                /// Waits until a message is available and returns it
+                /// </summary>
+                IMessage Receive();
+                
+                /// <summary>
+                /// If a message is available immediately it is returned otherwise this method returns null
+                /// </summary>
+                IMessage ReceiveNoWait();
+                
+        } 
+}

Propchange: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageConsumer.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageProducer.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageProducer.cs?rev=367605&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageProducer.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageProducer.cs Tue Jan 10 05:56:34 2006
@@ -0,0 +1,20 @@
+using System;
+using OpenWire.Client.Commands;
+
+namespace OpenWire.Client {
+        /// <summary>
+        /// An object capable of sending messages to some destination
+        /// </summary>
+        public interface IMessageProducer : IDisposable {
+
+                /// <summary>
+                /// Sends the message to the default destination for this producer
+                /// </summary>
+                void Send(IMessage message);
+
+                /// <summary>
+                /// Sends the message to the given destination
+                /// </summary>
+                void Send(IDestination destination, IMessage message); 
+        } 
+}

Propchange: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/IMessageProducer.cs
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ISession.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ISession.cs?rev=367605&r1=367604&r2=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ISession.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ISession.cs Tue Jan 10 05:56:34 2006
@@ -6,6 +6,39 @@
         /// Represents a single unit of work on an IConnection.
         /// So the ISession can be used to perform transactional receive and sends
         /// </summary>
-        public interface ISession {
+        public interface ISession : IDisposable {
+
+
+                /// <summary>
+                /// Creates a producer of messages
+                /// </summary>
+                IMessageProducer CreateProducer();
+
+                /// <summary>
+                /// Creates a producer of messages on a given destination
+                /// </summary>
+                IMessageProducer CreateProducer(IDestination destination); 
+
+                /// <summary>
+                /// Creates a cpmsi,er of messages on a given destination
+                /// </summary>
+                IMessageConsumer CreateConsumer(IDestination destination); 
+
+                /// <summary>
+                /// Creates a cpmsi,er of messages on a given destination with a selector
+                /// </summary>
+                IMessageConsumer CreateConsumer(IDestination destination, string selector); 
+                
+                /// <summary>
+                /// Returns the queue for the given name
+                /// </summary>
+                IQueue GetQueue(string name); 
+                
+                /// <summary>
+                /// Returns the topic for the given name
+                /// </summary>
+                ITopic GetTopic(string name); 
+                
+                
         } 
 }

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs?rev=367605&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs Tue Jan 10 05:56:34 2006
@@ -0,0 +1,15 @@
+using System;
+using OpenWire.Client.Commands;
+
+namespace OpenWire.Client {
+        /// <summary>
+        /// Represents a text based message
+        /// </summary>
+        public interface ITextMessage : IMessage {
+
+                string Text {
+                        get;
+                        set; 
+                } 
+        } 
+}

Propchange: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/ITextMessage.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: 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=367605&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs Tue Jan 10 05:56:34 2006
@@ -0,0 +1,42 @@
+using System;
+using OpenWire.Client.Commands;
+
+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 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();
+                        }
+                }
+        } 
+}

Propchange: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageConsumer.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: 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=367605&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs Tue Jan 10 05:56:34 2006
@@ -0,0 +1,30 @@
+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);
+                }
+        } 
+}

Propchange: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/MessageProducer.cs
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/OpenWireException.cs
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/OpenWireException.cs?rev=367605&view=auto
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/OpenWireException.cs (added)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/OpenWireException.cs Tue Jan 10 05:56:34 2006
@@ -0,0 +1,14 @@
+using System;
+using System.Collections;
+using OpenWire.Client.Commands;
+using OpenWire.Client.Core;
+
+namespace OpenWire.Client {
+        /// <summary>
+        /// Represents an OpenWire exception
+        /// </summary>
+        public class OpenWireException : Exception {
+                public OpenWireException(string message) : base(message) {
+                }
+        } 
+}

Propchange: incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/OpenWireException.cs
------------------------------------------------------------------------------
    svn:executable = *

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=367605&r1=367604&r2=367605&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs Tue Jan 10 05:56:34 2006
@@ -6,23 +6,86 @@
         /// <summary>
         /// Default provider of ISession
         /// </summary>
-        public class Session : ISession, IDisposable {
+        public class Session : ISession {
                 private Connection connection;
                 private AcknowledgementMode acknowledgementMode;
+                private SessionInfo info;
+                private long consumerCounter;
 
-                public Session(Connection connection, AcknowledgementMode acknowledgementMode) {
+                public Session(Connection connection, SessionInfo info) {
                         this.connection = connection;
-                        this.acknowledgementMode = acknowledgementMode; 
+                        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();
-                                connection.Transport.Request(ack);
+                                // 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); 
+                }
+
+                // 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; 
+                } 
         } 
 }