[
https://issues.apache.org/jira/browse/AMQNET-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13103592#comment-13103592
]
Andrew Parkin commented on AMQNET-342:
--------------------------------------
I'd be happy to do this, but at present I can't build the project, my Nant just
crashes :-( If I managed to get it working I'll try and attach a test case.
It's difficult to reproduce this problem and we don't see it very often
(although it is pretty severe when it does occur as no more messages arrive
from the broker). I think it might be necessary to add artificial delays to
some of the methods in order to produce the error.
> "Collection was modified" exception when adding message consumer
> ----------------------------------------------------------------
>
> Key: AMQNET-342
> URL: https://issues.apache.org/jira/browse/AMQNET-342
> Project: ActiveMQ .Net
> Issue Type: Bug
> Components: NMS
> Affects Versions: 1.5.1
> Environment: Windows XP
> Reporter: Andrew Parkin
> Assignee: Jim Gomes
>
> I am occasionally seeing the exception below when executing the following
> code:
> IMessageConsumer consumer = session.CreateConsumer(dest);
> consumer.Listener += BufferMessage;
> System.InvalidOperationException: Collection was modified; enumeration
> operation may not execute.
> at System.Collections.Hashtable.HashtableEnumerator.MoveNext()
> at Apache.NMS.ActiveMQ.Session.Start()
> at Apache.NMS.ActiveMQ.MessageConsumer.add_Listener(MessageListener value)
> Putting locks around the code in my application doesn't prevent the problem.
> I've had a look at the ActiveMQ source & I suspect the problem is as follows:
> MessageConsumer invokes the following code in the "add" section of "public
> event MessageListener Listener"
> if(wasStarted == true)
> {
> this.session.Start();
> }
> ...and Session.Start() iterates over consumers.values as follows:
> foreach(MessageConsumer consumer in this.consumers.Values)
> {
> consumer.Start();
> }
> I noticed that everywhere else in Session where this iteration occurs is
> locked with "lock(this.consumers.SyncRoot)", except for in the Start()
> method. Does a lock also need to be put around this section as well?
> Unfortunately I'm having problems building the source at the moment so I'm
> unable to confirm whether this would fix the problem or not.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira