
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
68 lines
2.6 KiB
Plaintext
68 lines
2.6 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Use of a Spring ``++SingleConnectionFactory++`` without enabling the ``++reconnectOnException++`` setting will prevent automatic connection recovery when the connection goes bad.
|
|
|
|
|
|
That's because the ``++reconnectOnException++`` property defaults to ``++false++``. As a result, even if the code that uses this connection factory (Spring's ``++DefaultMessageListenerContainer++`` or your own code) has reconnect logic, that code won't work because the ``++SingleConnectionFactory++`` will act like a single-connection pool by preventing connection ``++close++`` calls from actually closing anything. As a result, subsequent factory ``++create++`` operations will just hand back the original broken ``++Connection++``.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,xml]
|
|
----
|
|
<bean id="singleCF" class="org.springframework.jms.connection.SingleConnectionFactory"> <!-- Noncompliant -->
|
|
<constructor-arg ref="dummyConnectionFactory" />
|
|
</bean>
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,xml]
|
|
----
|
|
<bean id="singleCF" class="org.springframework.jms.connection.SingleConnectionFactory" p:reconnectOnException="true">
|
|
<constructor-arg ref="dummyConnectionFactory" />
|
|
</bean>
|
|
----
|
|
or
|
|
|
|
[source,xml]
|
|
----
|
|
<bean id="singleCF" class="org.springframework.jms.connection.SingleConnectionFactory">
|
|
<constructor-arg ref="dummyConnectionFactory" />
|
|
<property name="reconnectOnException"><value>true</value></property>
|
|
</bean>
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
* Add a "reconnectOnException" property, set to "true"
|
|
|
|
|
|
=== Highlighting
|
|
|
|
the ``++class++`` value in ``++<bean>++``
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 5 Jan 2016, 01:52:17 Gordon Daugherty wrote:
|
|
The text of this issue needs to be tweaked. The original version included the "XMF ServiceProxy" terminology that only makes sense within my company. I've reworded it generally. Consider using this:
|
|
|
|
|
|
Left unset, the "reconnectOnException" property defaults to "false". As a result, even if the code that uses this Connection Factory (Spring's DefaultMessageListenerContainer or your own code) has reconnect logic that code won't work because the SingleConnectionFactory is acting like a single-connection pool by preventing connection "close" calls from actually closing anything. As a result subsequent factory "create" operations just hand back the original broken connection.
|
|
|
|
=== on 5 Jan 2016, 16:28:11 Ann Campbell wrote:
|
|
Thanks [~gjd6640]! I've applied your new version with minor edits.
|
|
|
|
endif::env-github,rspecator-view[]
|