On Publishing the message to Rabbit MQ Exchange, few of the messages are getting lost. For example, posted 10 messages only five got delivered to the binded queue and the rest 5 messages are lost. Please advice.
Below is Spring XML configuration for connection
<bean id="cachingConnectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory" destroy-method="destroy">
<property name="addresses" value="example.com:8080"/>
<property name="username" value="guest" />
<property name="password" value="guest" />
<property name="virtualHost" value="guest-app" />
<property name="connectionTimeout" value="1000"/>
<property name="cacheMode" value="#{T(org.springframework.amqp.rabbit.connection.CachingConnectionFactory.CacheMode).CONNECTION}"/>
<property name="channelCacheSize" value="6000"/>
<property name="channelCheckoutTimeout" value="60000"/>
<property name="requestedHeartBeat" value="30"/>
<property name="publisherConfirms" value="true"/>
<property name="publisherReturns" value="true"/>
</bean>
Below is Rabbit Template Config
<rabbit:template id="amqpTemplate" connection-factory="cachingConnectionFactory" mandatory="true" retry-template="retryTemplate" />
<bean id="retryTemplate" class="org.springframework.retry.support.RetryTemplate">
<property name="backOffPolicy">
<bean class="org.springframework.retry.backoff.ExponentialBackOffPolicy">
<property name="initialInterval" value="500" />
<property name="multiplier" value="10.0" />
<property name="maxInterval" value="10000" />
</bean>
</property>
</bean>
<rabbit:admin connection-factory="cachingConnectionFactory" />
Below is for Publishing message
int:chain input-channel="output">
<int:header-enricher>
<int:header name="amqp_deliveryMode" value="PERSISTENT" type="org.springframework.amqp.core.MessageDeliveryMode"/>
</int:header-enricher>
<int-amqp:outbound-channel-adapter id="outboundAmqp" amqp-template="amqpTemplate" exchange-name-expression="headers['exchange']" routing-key-expression="headers['routingKey']" mapped-request-headers="*" confirm-correlation-expression="payload" confirm-ack-channel="msgResponse" confirm-nack-channel="msgResponse" return-channel="msgResponse"/>