[ https://issues.apache.org/activemq/browse/AMQ-930?page=all ]
james strachan resolved AMQ-930.
--------------------------------
Fix Version/s: 4.1
Resolution: Fixed
Patch applied to ensure consumers.Values is thread safe to fix the issue
> Session 'consumers' hashtable susceptible to invalid operation exception
> ------------------------------------------------------------------------
>
> Key: AMQ-930
> URL: https://issues.apache.org/activemq/browse/AMQ-930
> Project: ActiveMQ
> Issue Type: Bug
> Components: NMS (C# client)
> Affects Versions: incubation
> Environment: Windows XP, NMS API running against a AMQ 4.0.2 provider
> Reporter: Bryan Schmidt
> Fix For: 4.1
>
>
> In a multithreaded environment that reuses the Session object, the following
> exception is thrown:
> Invalid operation exception with the text: "Collection was modified;
> enumeration operation may not execute."
> The exception is thrown when iterating through Session's consumers.Values
> collection. It appears that the lock is being ignored. Spinning up a new
> thread fixes the problem:
> --- Session.cs, DispatchAsyncMessages method ---
> public void DispatchAsyncMessages(object state)
> {
> // lets iterate through each consumer created by this session
> // ensuring that they have all pending messages dispatched
> lock (this)
> {
> // lets ensure that only 1 thread dispatches messages in a
> consumer at once
> foreach (MessageConsumer consumer in consumers.Values)
> {
> ThreadPool.QueueUserWorkItem(new
> WaitCallback(consumer.DispatchAsyncMessages));
> }
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira