== Why is this an issue?

``++DefaultMessageListenerContainer++`` is implemented as a JMS poller. While the Spring container is shutting itself down, as each in-progress JMS ``++Consumer.receive()++`` call completes, any non-``++null++`` return value will be a JMS message that the DMLC will _discard_ due to the shutdown in progress. That will result in the received message never being processed. 


To prevent message loss during restart operations, set ``++acceptMessagesWhileStopping++`` to ``++true++`` so that such messages will be processed before shut down.


=== Noncompliant code example

[source,xml]
----
<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">  <!-- Noncompliant -->
   <property name="connectionFactory" ref="connFactory" />
   <property name="destination" ref="dest" />
   <property name="messageListener" ref="serviceAdapter" />
   <property name="autoStartup" value="true" />
   <property name="concurrentConsumers" value="10" />
   <property name="maxConcurrentConsumers" value="10" />
   <property name="clientId" value="myClientID" />
</bean>
----


=== Compliant solution

[source,xml]
----
<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
   <property name="connectionFactory" ref="connFactory" />
   <property name="destination" ref="dest" />
   <property name="messageListener" ref="serviceAdapter" />
   <property name="autoStartup" value="true" />
   <property name="concurrentConsumers" value="10" />
   <property name="maxConcurrentConsumers" value="10" />
   <property name="clientId" value="myClientID" />
   <property name="acceptMessagesWhileStopping" value="true" />
</bean>
----


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Enable "acceptMessagesWhileStopping".


=== Highlighting

``++class++`` value of ``++<bean>++``


'''
== Comments And Links
(visible only on this page)

=== on 5 Jan 2016, 01:44:06 Gordon Daugherty wrote:
When it comes time to implement this one keep in mind that this rule should ONLY apply when the "sessionTransacted" property is left unspecified OR is set to false. In cases where transacted sessions are being used it very well may be desirable to skip processing of the last message that was read during the shutdown process; that message will get redelivered by the JMS broker.

=== on 21 Jun 2018, 18:08:45 Michael Gumowski wrote:
Thanks for the comment [~gjd6640], I'll take that into account in the implementation.

endif::env-github,rspecator-view[]
