java.lang.IllegalStateException: Cannot register resolved alias 'my.shared.name' (original: '${exchange.foo.name}') for name 'exchangeFoo: It is already registered for name 'exchangeFoo'.

Spring JIRA | Peter Moore | 9 months ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    I've got the following Queue and Exchange declarations: {code} <rabbit:queue id="queueFoo" name="${queue.foo.name}" durable="true" exclusive="false"/> <rabbit:direct-exchange id="exchangeFoo" name="${exchange.foo.name}" durable="true"> <rabbit:bindings> <rabbit:binding queue="queueFoo" key="${queue.foo.name}"/> </rabbit:bindings> </rabbit:direct-exchange> {code} Importantly, my exchange and queue names happen to be the same in this case. config.props: {code} queue.foo.name=my.shared.name exchange.foo.name=my.shared.name {code} On context initialization, I get this exception: {code} 20160610 11:39:20.991 [ERROR] (main) o.s.web.context.ContextLoader Context initialization failed java.lang.IllegalStateException: Cannot register resolved alias 'my.shared.name' (original: '${exchange.foo.name}') for name 'exchangeFoo: It is already registered for name 'exchangeFoo'. at org.springframework.core.SimpleAliasRegistry.resolveAliases(SimpleAliasRegistry.java:157) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] {code} The error message there is a bit confusing, but I debugged into SimpleAliasRegistry, and basically, Spring's alias logic has detected that the "name" aliases are the same for both the exchange and queue beans. This makes sense, given the normal Spring semantics for the bean 'name' attribute as an alias for 'id'. If I take property placeholders out of the picture, and just use the same name ("my.shared.name") for the queue and the exchange beans, things work fine, so the bug is probably a bean post-processing issue. I can work around this for now, by choosing different names for the exchange and the queue. However, my bigger worry (and the reason I've marked this as major) is that if someone from my Ops team were to change a queue name in the application's configuration, that could potentially clash with one of the app's Spring bean names / aliases, causing a very confusing failure. It seems like it would be better to fully separate the queue/exchange naming from Spring's default 'name' functionality, and choose an entirely different attribute, such as 'queueName'.

    Spring JIRA | 9 months ago | Peter Moore
    java.lang.IllegalStateException: Cannot register resolved alias 'my.shared.name' (original: '${exchange.foo.name}') for name 'exchangeFoo: It is already registered for name 'exchangeFoo'.
  2. 0

    I've got the following Queue and Exchange declarations: {code} <rabbit:queue id="queueFoo" name="${queue.foo.name}" durable="true" exclusive="false"/> <rabbit:direct-exchange id="exchangeFoo" name="${exchange.foo.name}" durable="true"> <rabbit:bindings> <rabbit:binding queue="queueFoo" key="${queue.foo.name}"/> </rabbit:bindings> </rabbit:direct-exchange> {code} Importantly, my exchange and queue names happen to be the same in this case. config.props: {code} queue.foo.name=my.shared.name exchange.foo.name=my.shared.name {code} On context initialization, I get this exception: {code} 20160610 11:39:20.991 [ERROR] (main) o.s.web.context.ContextLoader Context initialization failed java.lang.IllegalStateException: Cannot register resolved alias 'my.shared.name' (original: '${exchange.foo.name}') for name 'exchangeFoo: It is already registered for name 'exchangeFoo'. at org.springframework.core.SimpleAliasRegistry.resolveAliases(SimpleAliasRegistry.java:157) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE] {code} The error message there is a bit confusing, but I debugged into SimpleAliasRegistry, and basically, Spring's alias logic has detected that the "name" aliases are the same for both the exchange and queue beans. This makes sense, given the normal Spring semantics for the bean 'name' attribute as an alias for 'id'. If I take property placeholders out of the picture, and just use the same name ("my.shared.name") for the queue and the exchange beans, things work fine, so the bug is probably a bean post-processing issue. I can work around this for now, by choosing different names for the exchange and the queue. However, my bigger worry (and the reason I've marked this as major) is that if someone from my Ops team were to change a queue name in the application's configuration, that could potentially clash with one of the app's Spring bean names / aliases, causing a very confusing failure. It seems like it would be better to fully separate the queue/exchange naming from Spring's default 'name' functionality, and choose an entirely different attribute, such as 'queueName'.

    Spring JIRA | 9 months ago | Peter Moore
    java.lang.IllegalStateException: Cannot register resolved alias 'my.shared.name' (original: '${exchange.foo.name}') for name 'exchangeFoo: It is already registered for name 'exchangeFoo'.

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Cannot register resolved alias 'my.shared.name' (original: '${exchange.foo.name}') for name 'exchangeFoo: It is already registered for name 'exchangeFoo'.

      at org.springframework.core.SimpleAliasRegistry.resolveAliases()
    2. Spring Core
      SimpleAliasRegistry.resolveAliases
      1. org.springframework.core.SimpleAliasRegistry.resolveAliases(SimpleAliasRegistry.java:157)[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
      1 frame