I am trying to use async scope from within vm inbound endpoint whose exchange pattern is request -response. The idea is call two other flows asynchronously from the vmmainflow.From what I understand from the mule documentation, when a vm is used with request-response exchange pattern, the exceution is carried on same thread that invokes the vm. I now have a requirement to call two other flows from within this vm flow and they are one-way and can be invoked asynchronously. However, when I do the following from my mule-config, I get the error as shown below.This happens only with concurrent requests to the service. I am not sure about the approach of calling async from a vm. If this approach is wrong, please suggest how I go about this. I am thinking to use another flow with inbound as vm(one-way) which has actual calls to two flows and then call that new vm from my vmmainflow.
<flow name="vmmainflow">
<vm:inbound-endpoint address="vm://vmmainflow"
exchange-pattern="request-response" />
........
<async>
<flow-ref name="flow1" />
<flow-ref name="flow2" />
</async>
.....
</flow>
Following is the error I get:
Exception in thread "null.processor.async.2" org.mule.api.MuleRuntimeException: An exception occurred while invoking message processor "DefaultMessageProcessorChain '(inner iterating chain) of 'async' child chain'
[
org.mule.api.processor.LoggerMessageProcessor@ccf1a3,
org.mule.api.processor.LoggerMessageProcessor@1fd937a,
org.mule.config.spring.factories.FlowRefFactoryBean$1@16a10c1
]" for asynchronously.
org.mule.processor.AsyncInterceptingMessageProcessor handleWorkException] - Work caused exception on 'workCompleted'. Work being executed was: org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker@483ebe
at org.mule.processor.AsyncInterceptingMessageProcessor.handleWorkException(AsyncInterceptingMessageProcessor.java:197)
at org.mule.processor.AsyncInterceptingMessageProcessor.workCompleted(AsyncInterceptingMessageProcessor.java:173)
at org.mule.work.WorkerContext.run(WorkerContext.java:368)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.util.ConcurrentModificationException
at org.apache.commons.collections.map.AbstractHashedMap$HashIterator.nextEntry(AbstractHashedMap.java:1113)
at org.apache.commons.collections.map.AbstractHashedMap$KeySetIterator.next(AbstractHashedMap.java:938)
at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1010)
at org.mule.DefaultMuleMessage.copyMessageProperties(DefaultMuleMessage.java:228)
at org.mule.DefaultMuleMessage.<init>(DefaultMuleMessage.java:203)
at org.mule.DefaultMuleMessage.<init>(DefaultMuleMessage.java:279)
at org.mule.DefaultMuleMessage.newThreadCopy(DefaultMuleMessage.java:1375)
at org.mule.DefaultMuleEvent.newThreadCopy(DefaultMuleEvent.java:713)
at org.mule.RequestContext.newEvent(RequestContext.java:135)
at org.mule.RequestContext.setEvent(RequestContext.java:72)
at org.mule.construct.SimpleFlowConstruct.process(SimpleFlowConstruct.java:125)
at org.mule.config.spring.factories.FlowRefFactoryBean$1.process(FlowRefFactoryBean.java:40)
at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:72)
at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:89)
at org.mule.processor.AbstractInterceptingMessageProcessor.processNext(AbstractInterceptingMessageProcessor.java:81)
at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:55)
at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:122)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:212)
at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:41)
at org.mule.work.WorkerContext.run(WorkerContext.java:309)