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
This commit is contained in:
James Strachan 2006-02-27 11:35:18 +00:00
parent 39b329fc7d
commit c628313c62
1 changed files with 13 additions and 5 deletions

View File

@ -112,7 +112,7 @@ namespace OpenWire.Client
throw e; throw e;
} }
} }
public IQueue GetQueue(string name) public IQueue GetQueue(string name)
{ {
return new ActiveMQQueue(name); return new ActiveMQQueue(name);
@ -176,7 +176,8 @@ namespace OpenWire.Client
// Properties // Properties
public Connection Connection { public Connection Connection
{
get { get {
return connection; return connection;
} }
@ -207,11 +208,18 @@ namespace OpenWire.Client
connection.SyncRequest(command); connection.SyncRequest(command);
} }
public void DispatchAsyncMessages(object state) { public void DispatchAsyncMessages(object state)
{
// lets iterate through each consumer created by this session // lets iterate through each consumer created by this session
// ensuring that they have all pending messages dispatched // ensuring that they have all pending messages dispatched
foreach (MessageConsumer consumer in consumers.Values) { lock (this)
consumer.DispatchAsyncMessages(); {
// lets ensure that only 1 thread dispatches messages in a consumer at once
foreach (MessageConsumer consumer in consumers.Values)
{
consumer.DispatchAsyncMessages();
}
} }
} }