JMSTemplate.receive() and receiveSelected() don't use "receiveTimeout" property if in a transaction [SPR-10109] #14742
Labels
in: messaging
Issues in messaging modules (jms, messaging)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Dominique Loiseau opened SPR-10109 and commented
Hi,
I've been struggling with this (IMO) strange behavior of JMSTemplate :
protected Message doReceive(Session session, MessageConsumer consumer) throws JMSException {
try {
// Use transaction timeout (if available).
long timeout = getReceiveTimeout();
JmsResourceHolder resourceHolder =
(JmsResourceHolder) TransactionSynchronizationManager.getResource(getConnectionFactory());
if (resourceHolder != null && resourceHolder.hasTimeout()) {
We can see that "getReceiveTimeout()" is used to retrieve the "receiveTimeout" configurable property, but then this is not used if resourceHolder exists and has a timeout (which seems to be transaction timeout minus elapsed time in transaction).
I understand that the receiveTimeout should not exceed transaction timeout, but then isn't that better to have :
timeout = Math.min(timeout, resourceHolder.getTimeToLiveInMillis());
instead of :
timeout = resourceHolder.getTimeToLiveInMillis();
?
Affects: 2.5.6
Referenced from: commits 39fe8ee, d3da2ed
Backported to: 3.1.4
The text was updated successfully, but these errors were encountered: