The following simple example can reproduce the problem.
Code:
<rabbit:connection-factory id="connectionFactory" host="myhost" port="5672" channel-cache-size="10" />
<rabbit:admin connection-factory="connectionFactory" />
<rabbit:queue id="jobExecQ" name="Q_JobExec" queue-arguments="haQ" />
<rabbit:queue-arguments id="haQ">
<entry key="x-ha-policy" value="all" />
</rabbit:queue-arguments>
<rabbit:listener-container connection-factory="connectionFactory" concurrency="5" acknowledge="none" >
<rabbit:listener ref="jobExecutor" queues="jobExecQ" />
</rabbit:listener-container>
<bean id="jobExecutor" class="test.amqp.JobExecutor" />
And here is the MessageListener code:
Code:
public class JobExecutor implements MessageListener {
private static Log log = LogFactory.getLog(JobExecutor.class);
public void onMessage(Message rmqMessage) {
String messageText = new String(rmqMessage.getBody());
log.info("Received message: " + messageText );
}
public static void main(String[] args) throws Exception {
ApplicationContext context = new ClassPathXmlApplicationContext("rabbitConfiguration.xml");
}
}
To reproduce:
1. start the app by the main method in the above class
2. send a message to Q_JobExec queue using the default exchange (I used rabbitmq management console for this)
3. check the log to see the received message
4. unplug the network cable for a few seconds
5. send second message as you did in step 2
6. send third/forth/... messages
The message in step 5 is lost.
Thanks for your help.