Relative Content

Tag Archive for spring-dataspring-transactionsspring-jms

Polling from integration test for data inserted by JMS consumer

An existing (ugly) integration test send and wait a JMS message locally (ActiveMq). The wait here does (an ugly) polling (timeout 60s) to get a Todo row inserted by the consumer of the JMS.
The test is flacky meaning the polling exceeds the 60s for sometimes. I activated the transactions commit to see at which time spring initiates a commit, and I see that for all failed test the commit was initiated just too early before the timeout of 60s (because the work that the consumer needs to do is about 1.5s).
So the 60 second is already more enough to get a chance to have the result that is inserted and commited by the consumer.
What could be the possible reasons that sometimes the polling is getting the data just before the time out of 60s and sometimes it does not get it even more than 60s whereas the elapsed time of the consumer to consume the message is about 1.5s?