From c628313c628376be5368e2be297097f5f0e73902 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Mon, 27 Feb 2006 11:35:18 +0000 Subject: [PATCH] Ensure only one thread dispatches to a session at once git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@381322 13f79535-47bb-0310-9956-ffa450edef68 --- openwire-dotnet/src/OpenWire.Client/Session.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/openwire-dotnet/src/OpenWire.Client/Session.cs b/openwire-dotnet/src/OpenWire.Client/Session.cs index 8dfb235069..01aad0474c 100755 --- a/openwire-dotnet/src/OpenWire.Client/Session.cs +++ b/openwire-dotnet/src/OpenWire.Client/Session.cs @@ -112,7 +112,7 @@ namespace OpenWire.Client throw e; } } - + public IQueue GetQueue(string name) { return new ActiveMQQueue(name); @@ -176,7 +176,8 @@ namespace OpenWire.Client // Properties - public Connection Connection { + public Connection Connection + { get { return connection; } @@ -207,11 +208,18 @@ namespace OpenWire.Client 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(); + } } }