Skip to content
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

ARTEMIS-5093 support configurable onMessage timeout w/closing consumer #5291

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jbertram
Copy link
Contributor

There wasn't a clear place to add documentation about this so I'm relying on JavaDoc.

return config.onMessageCloseTimeout;
}

@Override
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API docs specify the value set must be greater than zero, but there isn't any validation of that, should there be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm...That comment was left-over from a copy & paste. I went looking through the existing code to see how validation is done for other parameters, and I'm not actually seeing any. I'm continuing my investigation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did look into what it does with that configuration value and since it is passing into a CountdownLatch is seems like it will not trigger an exception but will return immediately so from the standpoint of being able to be set to zero or negative it works, although seems an absurd value to assign.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would seem weird to configure those if actually knowing thats what it then does, but I'd guess some might think one of those would simply mean keep waiting (e.g as is the described behaviour in the JMS spec, albeit that also originally described to effectively deadlock yourself as result hehe), especially if not reading the javadoc (should there also be actual-docs addition?).

@coocoo1112
Copy link

coocoo1112 commented Nov 13, 2024

Hey sorry, I was just wondering if there was any update on this or plans to get it into a new version? Thank you so much for starting the implementation process though!

Comment on lines 140 to 154
// don't just Thread.sleep() here because it will be interrupted on ClientConsumer.close()
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < 2000) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
}
});
latch.await();
long start = System.currentTimeMillis();
consumer.close();
long end = System.currentTimeMillis();
assertTrue( (end - start >= timeout) && (end - start <= 2000), "Closing consumer took " + (end - start) + "ms");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be inclined to use a shorter timeout for the close as Dom suggests, thus reducing the test duration, but also use a longer/indefinite 'dont complete yet' guard in the handler to be sure it is always still running after/when the timeout expires and can then 'immediately complete' on request, e.g instead arrange its waiting/exit-gating on an [atomic]boolean and other latch to wait on the rest of the test then complete quickly on request rather than the current time loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants