activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r512228 - in /activemq/activemq-dotnet/trunk/src/main/csharp: MSMQ/DefaultMessageConverter.cs MSMQ/Destination.cs MSMQ/MessageProducer.cs MSMQ/ObjectMessage.cs MSMQ/Queue.cs MSMQ/Session.cs Stomp/ConnectionFactory.cs
Date Tue, 27 Feb 2007 12:25:38 GMT
Author: jstrachan
Date: Tue Feb 27 04:25:37 2007
New Revision: 512228

URL: http://svn.apache.org/viewvc?view=rev&rev=512228
Log:
Fixed up the MSMQ code with the latest NMS APIs for AMQNET-30

Modified:
    activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/DefaultMessageConverter.cs
    activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Destination.cs
    activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageProducer.cs
    activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/ObjectMessage.cs
    activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Queue.cs
    activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Session.cs
    activemq/activemq-dotnet/trunk/src/main/csharp/Stomp/ConnectionFactory.cs

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/DefaultMessageConverter.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/DefaultMessageConverter.cs?view=diff&rev=512228&r1=512227&r2=512228
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/DefaultMessageConverter.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/DefaultMessageConverter.cs Tue Feb
27 04:25:37 2007
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 using System;
-using System.Collections.Generic;
 using System.Text;
 using System.Messaging;
 using NMS;
@@ -32,10 +31,10 @@
             {
                 responseQueue = new MessageQueue(((Destination)message.NMSReplyTo).Path);
             }
-            if (message.NMSExpiration != null)
-            {
+            //if (message.NMSExpiration != null)
+            //{
                 msg.TimeToBeReceived = message.NMSExpiration;
-            }
+            //}
             if (message.NMSCorrelationID != null)
             {
                 msg.CorrelationId = message.NMSCorrelationID;
@@ -46,7 +45,7 @@
 
             return msg;
         }
-        public IMessage convertFromMSMQMessage(Message message) 
+        public IMessage convertFromMSMQMessage(Message message)
         {
             return null;
         }

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Destination.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Destination.cs?view=diff&rev=512228&r1=512227&r2=512228
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Destination.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Destination.cs Tue Feb 27 04:25:37
2007
@@ -50,44 +50,34 @@
             set { this.path = value; }
         }
         
-        /**
-         * Returns true if a temporary Destination
-         *
-         * @return true/false
-         */
-        
-        public bool IsTemporary()
-        {
-            return DestinationType == DestinationType.TemporaryQueue
-                || DestinationType == DestinationType.TemporaryTopic;
-        }
-        
-        /**
-         * Returns true if a Topic Destination
-         *
-         * @return true/false
-         */
-        
-        public bool IsTopic()
-        {
-            return DestinationType == DestinationType.Topic
-                   || DestinationType == DestinationType.TemporaryTopic;
-        }
-        
-        /**
-         * Returns true if a Queue Destination
-         *
-         * @return true/false
-         */
-        public bool IsQueue()
-        {
-            return !IsTopic();
-        }
-        
+		
+		public bool IsTopic
+		{
+			get {
+				return DestinationType == DestinationType.Topic
+					|| DestinationType == DestinationType.TemporaryTopic;
+			}
+		}
+		
+		public bool IsQueue
+		{
+			get {
+				return !IsTopic;
+			}
+		}
+		
+		
+		public bool IsTemporary
+		{
+			get {
+				return DestinationType == DestinationType.TemporaryQueue
+					|| DestinationType == DestinationType.TemporaryTopic;
+			}
+		}
         
         /**
          * @return string representation of this instance
-         */        
+         */
         public override String ToString()
         {
             return this.path;
@@ -104,7 +94,7 @@
             {
                 answer = path.GetHashCode();
             }
-            if (IsTopic())
+            if (IsTopic)
             {
                 answer ^= 0xfabfab;
             }

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageProducer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageProducer.cs?view=diff&rev=512228&r1=512227&r2=512228
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageProducer.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/MessageProducer.cs Tue Feb 27 04:25:37
2007
@@ -25,13 +25,14 @@
     /// </summary>
     public class MessageProducer : IMessageProducer
     {
+		
         private readonly Session session;
         private Destination destination;
 
-        private long messageCounter;
+        //private long messageCounter;
         private bool persistent;
         private TimeSpan timeToLive;
-        private int priority;
+        private byte priority;
         private bool disableMessageID;
         private bool disableMessageTimestamp;
         
@@ -67,25 +68,35 @@
                     {
                         throw new NMSSecurityException("Do not have write access to: " +
dest);
                     }
-                }                
-            } 
-            catch( Exception e ) 
+                }
+            }
+            catch( Exception e )
             {
                 if( rc!=null )
                 {
                     rc.Dispose();
                 }
                 throw new NMSException(e.Message+": "+dest, e);
-            }            
+            }
             return rc;
         }
 
         public void Send(IMessage message)
         {
-            Send(destination, message);
+            Send(Destination, message);
         }
 
-        public void Send(IDestination dest, IMessage imessage)
+		public void Send(IMessage message, bool persistent, byte priority, TimeSpan timeToLive)
+		{
+			Send(Destination, message, persistent, priority, timeToLive);
+		}
+
+        public void Send(IDestination destination, IMessage message)
+        {
+			Send(destination, message, Persistent, Priority, TimeToLive);
+        }
+		
+        public void Send(IDestination destination, IMessage imessage, bool persistent, byte
priority, TimeSpan timeToLive)
         {
             BaseMessage message = (BaseMessage) imessage;
             MessageQueue mq=null;
@@ -96,28 +107,28 @@
                 // Locate the MSMQ Queue we will be sending to
                 if (messageQueue != null)
                 {
-                    if( dest.Equals(destination) )
+                    if( destination.Equals(this.destination) )
                     {
                         mq = messageQueue;
-                    } 
+                    }
                     else
                     {
-                        throw new NMSException("This producer can only be used to send to:
"+destination);
+                        throw new NMSException("This producer can only be used to send to:
" + destination);
                     }
                 }
                 else
                 {
-                    mq = openMessageQueue((Destination)dest);
+                    mq = openMessageQueue((Destination) destination);
                 }
-
+				
                 // Convert the Mesasge into a MSMQ message
                 message.NMSPersistent = persistent;
-                message.NMSExpiration = TimeToLive;
-                message.NMSPriority = (byte)priority;
+                message.NMSExpiration = timeToLive;
+                message.NMSPriority = priority;
                 
                 // message.NMSTimestamp = new DateTime().Date.;
                 Message msg = messageConverter.convertToMSMQMessage(message);
-                // TODO: message.NMSMessageId = 
+                // TODO: message.NMSMessageId =
                 // Now Send the message
                 if( mq.Transactional )
                 {
@@ -161,20 +172,53 @@
                 }
             }
         }
-
-        public void Send(IDestination destination, IMessage message, bool persistent, byte
priority, TimeSpan timeToLive)
-        {
-            throw new NotImplementedException();
-        }
-
+		
+		
+		
         public void Dispose()
         {
             if( messageQueue!=null )
             {
                 messageQueue.Dispose();
-                messageQueue = null;                    
+                messageQueue = null;
             }
         }
+		
+		
+		public IMessage CreateMessage()
+		{
+			return session.CreateMessage();
+		}
+		
+		public ITextMessage CreateTextMessage()
+		{
+			return session.CreateTextMessage();
+		}
+		
+		public ITextMessage CreateTextMessage(String text)
+		{
+			return session.CreateTextMessage(text);
+		}
+		
+		public IMapMessage CreateMapMessage()
+		{
+			return session.CreateMapMessage();
+		}
+		
+		public IObjectMessage CreateObjectMessage(Object body)
+		{
+			return session.CreateObjectMessage(body);
+		}
+		
+		public IBytesMessage CreateBytesMessage()
+		{
+			return session.CreateBytesMessage();
+		}
+		
+		public IBytesMessage CreateBytesMessage(byte[] body)
+		{
+			return session.CreateBytesMessage(body);
+		}
 
         public bool Persistent
         {
@@ -194,7 +238,13 @@
             set { throw new NotImplementedException(); }
         }
 
-        public int Priority
+		public IDestination Destination
+		{
+            get { return destination; }
+            set { destination = (Destination) value; }
+		}
+		
+        public byte Priority
         {
             get { return priority; }
             set { priority = value; }
@@ -219,4 +269,4 @@
         }
 
     }
-}
\ No newline at end of file
+}

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/ObjectMessage.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/ObjectMessage.cs?view=diff&rev=512228&r1=512227&r2=512228
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/ObjectMessage.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/ObjectMessage.cs Tue Feb 27 04:25:37
2007
@@ -1,27 +1,84 @@
 /*
-* 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.
-*/
+ * 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 NMS;
 using System;
 using System.Collections;
+using System.IO;
+
+#if !(PocketPC||NETCF||NETCF_2_0)
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
+#endif
 
 namespace MSMQ
 {
-    public class ObjectMessage : BaseMessage
+    public class ObjectMessage : BaseMessage, IObjectMessage
     {
-
-    }
+		#if !(PocketPC||NETCF||NETCF_2_0)
+		private object body;
+		private IFormatter formatter;
+		#endif
+		
+		public object Body
+		{
+			get {
+				#if !(PocketPC||NETCF||NETCF_2_0)
+				if (body == null)
+				{
+					body = Formatter.Deserialize(new MemoryStream(Content));
+				}
+				return body;
+				#else
+                throw new NotImplementedException();
+				#endif
+			}
+			
+			set {
+				#if !(PocketPC||NETCF||NETCF_2_0)
+				body = value;
+				#else
+                throw new NotImplementedException();
+				#endif
+			}
+		}
+		
+		
+		#if !(PocketPC||NETCF||NETCF_2_0)
+		public IFormatter Formatter
+		{
+			get {
+				if (formatter == null)
+				{
+					formatter = new BinaryFormatter();
+				}
+				return formatter;
+			}
+			
+			set {
+				formatter = value;
+			}
+		}
+		#endif
+	}
 }
+
+
+		
+
+		
+

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Queue.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Queue.cs?view=diff&rev=512228&r1=512227&r2=512228
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Queue.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Queue.cs Tue Feb 27 04:25:37 2007
@@ -24,10 +24,12 @@
 	/// Summary description for Queue.
 	/// </summary>
 	public class Queue : Destination, IQueue
-    {        
+    {
+		
         public Queue() : base()
         {
         }
+		
         public Queue(String name) : base(name)
         {
         }
@@ -49,6 +51,8 @@
         {
             return new Queue(name);
         }
+
+        
     }
 }
 

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Session.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Session.cs?view=diff&rev=512228&r1=512227&r2=512228
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Session.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/MSMQ/Session.cs Tue Feb 27 04:25:37 2007
@@ -134,7 +134,14 @@
             answer.Content = body;
             return answer;
         }
-        
+		
+		public IObjectMessage CreateObjectMessage(Object body)
+		{
+			ObjectMessage answer = new ObjectMessage();
+			answer.Body = body;
+			return answer;
+		}
+		
         public void Commit()
         {
             if (! Transacted )
@@ -150,10 +157,10 @@
             {
                 throw new InvalidOperationException("You cannot perform a Commit() on a non-transacted
session. Acknowlegement mode is: " + acknowledgementMode);
             }
-            messageQueueTransaction.Abort();            
+            messageQueueTransaction.Abort();
         }
         
-        // Properties        
+        // Properties
         public Connection Connection
         {
             get { return connection; }
@@ -173,7 +180,7 @@
         {
             get
             {
-                if( messageQueueTransaction.Status != MessageQueueTransactionStatus.Pending
) 
+                if( messageQueueTransaction.Status != MessageQueueTransactionStatus.Pending
)
                     messageQueueTransaction.Begin();
                 return messageQueueTransaction;
             }

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/Stomp/ConnectionFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/Stomp/ConnectionFactory.cs?view=diff&rev=512228&r1=512227&r2=512228
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/Stomp/ConnectionFactory.cs (original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/Stomp/ConnectionFactory.cs Tue Feb 27 04:25:37
2007
@@ -21,7 +21,7 @@
 namespace Stomp
 {
     /// <summary>
-    /// Represents a connection with a message broker using the 
+    /// Represents a connection with a message broker using the
 	/// <a href="http://stomp.codehaus.org/">STOMP</a> protocol.
     /// </summary>
     public class ConnectionFactory : ActiveMQ.ConnectionFactory
@@ -29,6 +29,14 @@
         public ConnectionFactory()
         {
 			BrokerUri = new Uri("stomp://localhost:61613");
+        }
+		
+		public ConnectionFactory(Uri brokerUri) : base(brokerUri)
+        {
+        }
+        
+        public ConnectionFactory(string brokerUri) : base(brokerUri)
+        {
         }
     }
 }



Mime
View raw message