activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Schmidt (JIRA)" <>
Subject [jira] Created: (AMQ-930) Session 'consumers' hashtable susceptible to invalid operation exception
Date Tue, 19 Sep 2006 19:42:27 GMT
Session 'consumers' hashtable susceptible to invalid operation exception

                 Key: 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

In a multithreaded environment that reuses the Session object, the following exception is

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:
For more information on JIRA, see:


View raw message