Skip to content

Conversation

@therepanic
Copy link
Contributor

@therepanic therepanic commented Apr 20, 2025

I've been thinking about this for a very long time to be honest, and have come to one conclusion, please correct me if I'm drastically wrong.

However, the point is that I believe that when we test sending from TemporaryQueue that is created when each connection is created, it can't be synchronized. The way I understand it is this:

JmsMessageSender creates a TemporaryQueue on its JMS-Connection A

JmsTemplate tries to send a response to the same queue over a new connection B

TemporaryQueue exists only within Connection A and is not available/deleted in B

And then it turns out all tests where we test TemporaryQueue, they should be synchronized. I have made all ChannelFactory in the tests to be SingleConnectionFactory, however I guess this is necessary for tests where we use TemporaryQueue, but it would be easier to do it for all tests.

If I am misunderstanding something, please correct it

Fix: #1539

…ender-applicationContext.xml

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
@snicoll
Copy link
Member

snicoll commented Apr 21, 2025

Thanks for the PR!

The way I understand it is this

I don't think this is accurate. Temporary queues are created for exactly that purpose. Sender creates a temporary queue in its session, sends a message with a replyTo header with the actual reference to the destination. Then whoever processes the message uses that to reply. As long as the session in the sender is alive, so is the temporary queue. If the queue has been deleted, then the bit that waits for the reply may have died or timed out.

I haven't been able to reproduce the problem reliably so I am not sure what to do for this yet.

@therepanic
Copy link
Contributor Author

Thanks for digging into this! You’re absolutely right about how TemporaryQueue works. What I found in our tests is that JmsMessageSender and JmsTemplate were each opening their own JMS Connection, so the queue created on Connection A could be closed (and deleted) before Connection B tried to reply. By switching both sides to use a single shared ConnectionFactory (via SingleConnectionFactory), they both reuse the same Connection/Session, so the temp queue stays alive until the reply is sent and the flakiness goes away, I think.

@snicoll
Copy link
Member

snicoll commented Apr 22, 2025

What I found in our tests is that JmsMessageSender and JmsTemplate were each opening their own JMS Connection, so the queue created on Connection A could be closed (and deleted) before Connection B tried to reply

Yes but that's a problem in the receiver end of things.

By switching both sides to use a single shared ConnectionFactory (via SingleConnectionFactory), they both reuse the same Connection/Session, so the temp queue stays alive until the reply is sent and the flakiness goes away, I think.

You are probably correct but that's hiding the underlying problem. I'd rather make the test more robust rather than hiding the fact the receiver is closing the conection when it shouldn't have.

Thanks for the PR and the convo, in any case!

@snicoll snicoll closed this Apr 22, 2025
@snicoll snicoll added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 22, 2025
@snicoll snicoll reopened this Nov 14, 2025
@snicoll
Copy link
Member

snicoll commented Nov 14, 2025

As much as I dislike it, I think there's not much else we can do given the timing of the transactions.

@snicoll snicoll added type: task A general task and removed status: declined A suggestion or change that we don't feel we should currently apply labels Nov 14, 2025
@snicoll snicoll self-assigned this Nov 14, 2025
@snicoll snicoll added this to the 4.0.17 milestone Nov 14, 2025
snicoll pushed a commit that referenced this pull request Nov 14, 2025
This commit updates the JMS integration tests to use a
SingleConnectionFactory rather than a regular ActiveMQConnectionFactory.

Given that the tests exercises both the sender and the receiver in the
same test, we can guarantee reliably the boundary of the transaction.

See gh-1549

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
snicoll added a commit that referenced this pull request Nov 14, 2025
@snicoll snicoll closed this in 00f9820 Nov 14, 2025
snicoll added a commit that referenced this pull request Nov 14, 2025
The configuration had moved to Java config and the XML file wasn't
remove. This is done as part of this commit.

See gh-1549
@snicoll
Copy link
Member

snicoll commented Nov 18, 2025

Actually this change makes it worse from what I see on CI. Given it hasn't resolved the problem I am going to revert it.

@snicoll snicoll removed this from the 4.0.17 milestone Nov 18, 2025
@snicoll snicoll added the status: declined A suggestion or change that we don't feel we should currently apply label Nov 18, 2025
snicoll added a commit that referenced this pull request Nov 18, 2025
The change didn't fix the underlying issue. Looking at CI it even seems
to have made it worse.

See gh-1549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply type: task A general task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JmsMessageSenderIntegrationTests is flaky

3 participants