java.lang.IllegalStateException: Another endpoint is already registered with id 'myuniquecustomid'

Spring JIRA | Josip Medic | 11 months ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael . Or join the community to write better ones.
  1. 0

    If we have following situation: interface: {code:title=ConsumerService.java |borderStyle=solid} public interface ConsumerService<TPayLoad> { void consume(TPayLoad message); } {code} and also following interface implementation: {code:title=TestingQueueConsumerServiceImpl.java |borderStyle=solid} @Component public class TestingQueueConsumerServiceImpl implements ConsumerService<DemoMessage> { private Log log = LogFactory.getLog(getClass()); @Transactional @RabbitListener(queues = "${rabbitmq.queue.demo}", id = "myuniquecustomid") public void consume(@Payload TestMessage message) { Assert.notNull(message); log.info(message.toString()); } } {code} on application start we gets following exception {noformat} 2016-03-24 09:26:48.971 INFO 58632 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat 2016-03-24 09:26:48.982 ERROR 58632 --- [ main] o.s.boot.SpringApplication : Application startup failed java.lang.IllegalStateException: Another endpoint is already registered with id 'myuniquecustomid' at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:146) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:122) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.registerAllEndpoints(RabbitListenerEndpointRegistrar.java:134) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.afterPropertiesSet(RabbitListenerEndpointRegistrar.java:128) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.afterSingletonsInstantiated(RabbitListenerAnnotationBeanPostProcessor.java:209) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] {noformat} This is happening as @RabbitListener annotation creates two listener instances, one for interface method and one for implementing method. After implementation of `ConsumerService<DemoMessage>` is removed then everything is working as expected.

    Spring JIRA | 11 months ago | Josip Medic
    java.lang.IllegalStateException: Another endpoint is already registered with id 'myuniquecustomid'
  2. 0

    If we have following situation: interface: {code:title=ConsumerService.java |borderStyle=solid} public interface ConsumerService<TPayLoad> { void consume(TPayLoad message); } {code} and also following interface implementation: {code:title=TestingQueueConsumerServiceImpl.java |borderStyle=solid} @Component public class TestingQueueConsumerServiceImpl implements ConsumerService<DemoMessage> { private Log log = LogFactory.getLog(getClass()); @Transactional @RabbitListener(queues = "${rabbitmq.queue.demo}", id = "myuniquecustomid") public void consume(@Payload TestMessage message) { Assert.notNull(message); log.info(message.toString()); } } {code} on application start we gets following exception {noformat} 2016-03-24 09:26:48.971 INFO 58632 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat 2016-03-24 09:26:48.982 ERROR 58632 --- [ main] o.s.boot.SpringApplication : Application startup failed java.lang.IllegalStateException: Another endpoint is already registered with id 'myuniquecustomid' at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:146) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:122) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.registerAllEndpoints(RabbitListenerEndpointRegistrar.java:134) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.afterPropertiesSet(RabbitListenerEndpointRegistrar.java:128) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.afterSingletonsInstantiated(RabbitListenerAnnotationBeanPostProcessor.java:209) ~[spring-rabbit-1.5.4.RELEASE.jar:na] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE] {noformat} This is happening as @RabbitListener annotation creates two listener instances, one for interface method and one for implementing method. After implementation of `ConsumerService<DemoMessage>` is removed then everything is working as expected.

    Spring JIRA | 11 months ago | Josip Medic
    java.lang.IllegalStateException: Another endpoint is already registered with id 'myuniquecustomid'
  3. 0
    samebug tip
    If you're using boot 1.4.x you need to modify the @springBootTest annotation to @SpringBootTest(classes = DataFlowServerConfiguration.class). 1.3.8 doesn't have this problem as well.
    via GitHub by trisberg
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Simple WebMvcTest fails with Spring Boot 1.4M3 due to missing SpringBootConfiguration

    GitHub | 9 months ago | jgoldhammer
    java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalStateException

    Another endpoint is already registered with id 'myuniquecustomid'

    at org.springframework.util.Assert.state()
  2. Spring Core
    Assert.state
    1. org.springframework.util.Assert.state(Assert.java:392)[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    1 frame
  3. Spring RabbitMQ Support
    RabbitListenerAnnotationBeanPostProcessor.afterSingletonsInstantiated
    1. org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:146)[spring-rabbit-1.5.4.RELEASE.jar:na]
    2. org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.registerListenerContainer(RabbitListenerEndpointRegistry.java:122)[spring-rabbit-1.5.4.RELEASE.jar:na]
    3. org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.registerAllEndpoints(RabbitListenerEndpointRegistrar.java:134)[spring-rabbit-1.5.4.RELEASE.jar:na]
    4. org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar.afterPropertiesSet(RabbitListenerEndpointRegistrar.java:128)[spring-rabbit-1.5.4.RELEASE.jar:na]
    5. org.springframework.amqp.rabbit.annotation.RabbitListenerAnnotationBeanPostProcessor.afterSingletonsInstantiated(RabbitListenerAnnotationBeanPostProcessor.java:209)[spring-rabbit-1.5.4.RELEASE.jar:na]
    5 frames
  4. Spring Beans
    DefaultListableBeanFactory.preInstantiateSingletons
    1. org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:792)[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    1 frame
  5. Spring Context
    AbstractApplicationContext.refresh
    1. org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    2. org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
    2 frames
  6. Spring Boot
    SpringApplication.run
    1. org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    2. org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    3. org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    4. org.springframework.boot.SpringApplication.run(SpringApplication.java:307)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    5. org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    6. org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
    6 frames