Error thrown from framework call to ListenerContainerLifecycleManager when SpringAMQPConfiguration has exclusive=false

The error says:

“Error invoking setter method, please report this at http://issues.axonframework.org

That gets thrown from the setExclusive(boolean) method of DefaultRabbitMqStrategy, which is called from the createContainer(config) method of ListenerContainerFactory.

Looking in the function createContainer(config), I notice that this section:

if (config.getConcurrentConsumers() != null)
{

newContainer.setConcurrentConsumers(config.getConcurrentConsumers());

}

…comes before this section:

if (config.getExclusive() != null)
{
rabbitMqStrategy.setExclusive(newContainer, config.getExclusive());

}

So, in effect the setExclusive() method is called AFTER the setConcurrentConsumers() method in Spring’s SimpleMessageListenerContainer. Looking at the code for that on Github, it seems like that order will always lead to an error when trying to set exclusive=false, because the Spring code expects one to call setExclusive(false) BEFORE calling setConcurrentConsumers(> 1).

Hi,

thanks for reporting this one. Should be an easy fix.
As a workaround, you can probably not provide a value for exclusive, unless you want it to be true. Exclusive defaults to false.

Cheers,

Allard

Hi,

while trying to reproduce this, I’m noticing that the existing code does work as expected. Since exclusive defaults to false, setting it to false doesn’t change anything. Spring will only throw an exception if it has been set to true explicitly sometime earlier.

Can you share the stack trace that you receive?

Cheers,

Allard

It seemed to be defaulting to ‘true’ for me. When i didn’t set it, i could see exclusive consumers get formed on the Queue from the RabbitMQ management console.

Caused by: org.axonframework.common.AxonConfigurationException: Error invoking setter method, please report this at http://issues.axonframework.org
at org.axonframework.eventhandling.amqp.spring.DefaultRabbitMqStrategy.setExclusive(DefaultRabbitMqStrategy.java:34) ~[axon-amqp-2.4.4.jar:2.4.4]
at org.axonframework.eventhandling.amqp.spring.ListenerContainerFactory.createContainer(ListenerContainerFactory.java:111) ~[axon-amqp-2.4.4.jar:2.4.4]
at org.axonframework.eventhandling.amqp.spring.ListenerContainerLifecycleManager.registerCluster(ListenerContainerLifecycleManager.java:86) ~[axon-amqp-2.4.4.jar:2.4.4]
at org.axonframework.eventhandling.amqp.spring.SpringAMQPTerminal.onClusterCreated(SpringAMQPTerminal.java:154) ~[axon-amqp-2.4.4.jar:2.4.4]
at org.axonframework.eventhandling.ClusteringEventBus.clusterFor(ClusteringEventBus.java:120) ~[axon-core-2.4.4.jar:2.4.6-SNAPSHOT]
at org.axonframework.eventhandling.ClusteringEventBus.subscribe(ClusteringEventBus.java:99) ~[axon-core-2.4.4.jar:2.4.6-SNAPSHOT]
at org.axonframework.eventhandling.annotation.AnnotationEventListenerBeanPostProcessor.subscribe(AnnotationEventListenerBeanPostProcessor.java:81) ~[axon-core-2.4.4.jar:2.4.6-SNAPSHOT]
at org.axonframework.eventhandling.annotation.AnnotationEventListenerBeanPostProcessor.subscribe(AnnotationEventListenerBeanPostProcessor8) ~[axon-core-2.4.4.jar:2.4.6-SNAPSHOT]
at org.axonframework.common.annotation.AbstractAnnotationHandlerBeanPostProcessor.start(AbstractAnnotationHandlerBeanPostProcessor.java:165) ~[axon-core-2.4.4.jar:2.4.6-SNAPSHOT]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:173) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
… 14 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_91]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91]
at org.axonframework.eventhandling.amqp.spring.DefaultRabbitMqStrategy.setExclusive(DefaultRabbitMqStrategy.java:32) ~[axon-amqp-2.4.4.jar:2.4.4]
… 23 common frames omitted
Caused by: java.lang.IllegalArgumentException: When the consumer is exclusive, the concurrency must be 1
at org.springframework.util.Assert.isTrue(Assert.java:68) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.setExclusive(SimpleMessageListenerContainer.java:316) ~[spring-rabbit-1.5.4.RELEASE.jar:na]
… 28 common frames omitted

Hi James,

the stacktrace shows that spring throws an IllegalArgumentException, because the concurrency is > 1. According to the source code, it will only throw this exception when the exclusive setting is being set to true. Are you sure it’s not being set to true somewhere? In Both Spring and Axon, it defaults to false.

Cheers,

Allard