activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r381322 - /incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs
Date Mon, 27 Feb 2006 11:35:27 GMT
Author: jstrachan
Date: Mon Feb 27 03:35:18 2006
New Revision: 381322

URL: http://svn.apache.org/viewcvs?rev=381322&view=rev
Log:
Ensure only one thread dispatches to a session at once

Modified:
    incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs

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=381322&r1=381321&r2=381322&view=diff
==============================================================================
--- incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs (original)
+++ incubator/activemq/trunk/openwire-dotnet/src/OpenWire.Client/Session.cs Mon Feb 27 03:35:18
2006
@@ -112,7 +112,7 @@
                 throw e;
             }
         }
-
+        
         public IQueue GetQueue(string name)
         {
             return new ActiveMQQueue(name);
@@ -176,7 +176,8 @@
         
         
         // Properties
-        public Connection Connection {
+        public Connection Connection
+        {
             get {
                 return connection;
             }
@@ -207,11 +208,18 @@
             connection.SyncRequest(command);
         }
         
-        public void DispatchAsyncMessages(object state) {
+        public void DispatchAsyncMessages(object state)
+        {
             // lets iterate through each consumer created by this session
             // ensuring that they have all pending messages dispatched
-            foreach (MessageConsumer consumer in consumers.Values) {
-                consumer.DispatchAsyncMessages();
+            lock (this)
+            {
+                // lets ensure that only 1 thread dispatches messages in a consumer at once
+                
+                foreach (MessageConsumer consumer in consumers.Values)
+                {
+                    consumer.DispatchAsyncMessages();
+                }
             }
         }
         



Mime
View raw message