Announcement Announcement Module
No announcement yet.
Duplicate Message using Asynchronous Consumer Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Duplicate Message using Asynchronous Consumer


    I am having problem using the SimpleMessageListenerContainer. Everytime I send a message from the producer (A MVC Controller), the POJO Message Driven Bean receives the message 2 times (duplicate message). I am not sure if my configuration is wrong or if it is a concurrency problem is the SimpleMessageListenerContainer.

    I am using Virgo tomcat server 3.0.0.M4, spring-amqp 1.0.0.RC1, amqp-client 2.4.1, spring-rabbit 1.0.0.RC1.

    <bean id="cachingConnectionFactory"
    class="org.springframework.amqp.rabbit.connection. CachingConnectionFactory">
    <constructor-arg value="localhost" />
    <property name="username" value="guest" />
    <property name="password" value="guest" />

    <rabbit:admin id="amqpAdmin" connection-factory="cachingConnectionFactory" />

    <rabbit:queue id="newMemberQueue" />

    <rabbit:fanout-exchange id="newMemberExchange"
    <rabbit:binding queue="newMemberQueue" />

    <bean id="newMemberMessageHandler" class="">

    <bean id="newMemberMessageListenerAdapter"
    class=" apter.MessageListenerAdapter">
    <ref bean="newMemberMessageHandler" />
    <!-- <property name="messageConverter"> <null /> </property> -->

    <rabbit:listener-container connection-factory="cachingConnectionFactory">
    <rabbit:listener queues="newMemberQueue" ref="newMemberMessageListenerAdapter" />

    <bean id="newMemberRabbitTemplate" class="org.springframework.amqp.rabbit.core.Rabbit Template">
    <property name="connectionFactory" ref="cachingConnectionFactory" />
    <property name="exchange" value="" />

    public class NewMemberHandler {
    public void handleMessage(String text) {
    // do sth

    public class RegistrationController {
    @RequestMapping(value = "/registration/form", method = RequestMethod.POST)
    public String handleForm(
    HttpServletRequest request,
    HttpServletResponse response) {

    // do sth
    rabbitTemplate.convertAndSend("member id");


  • #2
    Looks OK on the face of it. Maybe you are loading rabbit-config.xml twice?


    • #3
      I just check the web.xml to make sure rabbitmq-config.xml it is not declared under contextConfigLocation and test-servlet.xml doesn't include '<import resource="rabbitmq-config.xml" />' but NewMemberHandler still receive message twice.

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" xmlns=""

      <param-value> WebApplicationContext</param-value>

      <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>

      <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>




      • #4
        Maybe you could write an integration test that loads the context as if it was the web application? We could try and isolate the problem that way (and you will find the test saves you a lot of time in the future as well).

        I did notice that you are using Virgo and keeping your webapp context in META-INF/spring. Maybe the container is loading it as well via Spring DM naming conventions?


        • #5
          Thankyou so much

          moving /META-INF/spring/applicationContext.xml to /WEB-INF does solve the problem.