Skip to content

JMSTemplate.receive() and receiveSelected() don't use "receiveTimeout" property if in a transaction [SPR-10109] #14742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Dec 19, 2012 · 1 comment
Assignees
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

Comments

@spring-projects-issues
Copy link
Collaborator

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()) {

			timeout = resourceHolder.getTimeToLiveInMillis();

		}

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

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good catch! Fixed for 3.2.1 and 3.1.4.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug in: messaging Issues in messaging modules (jms, messaging) status: backported An issue that has been backported to maintenance branches labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.2.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

2 participants