0

I'm running into a very odd problem that happens only under very specific circumstances. I have the following route

<routes id="id1" xmlns="http://camel.apache.org/schema/spring">
<route id="id2">
    <from uri="{{input}}"/>
    <log message="Started route"/>

    <transacted/>

    <doTry>
        <multicast>
            <pipeline>
                <log message="Started 1" />
                <log message="Finished 1" />
            </pipeline>

            <pipeline>
                <log message="Started 2" />
                <log message="Finished 2" />
            </pipeline>
        </multicast>

        <log message="Finished multi"/>

        <doCatch>
            <exception>java.lang.Exception</exception>
            <log message="Exception happened"/>
        </doCatch>
    </doTry>
</route>
</routes>

This prints the following

Started route
Started 1
Finished 1
Started 2
Finished 2

It then hangs until you terminate the process. Finished multi is never logged. After 10 seconds I get a message from Atomikos (the transaction manager) that looks like

Transaction tm168555531112800002 has timed out and will rollback.

When I terminate the process, camel tells me there's 1 inflight exchange for route id2. Graceful shutdown fails after 10 seconds and it has to kill the main thread.

The following threads are blocked and will be interrupted so the threads are released
Blocked Thread --- Id: 1 Name: main RouteId: id2 NodeId: multicast1

Now here's the fun part. Changing the route in any of these ways fixes the problem and everything works as expected:

  • Removing one of the log messages from the second pipeline. Doesn't matter what you put in the first one, the second pipeline must contain only a single line.
  • Removing one pipeline block completely
  • Making the multicast concurrent with parallelProcessing = true
  • Removing <transacted/>
  • Moving the multicast outside <doTry>

I'm using Camel 3.15.0 with Spring Boot 2.6.4

Egor
  • 1,622
  • 12
  • 26
  • Did you already try to put the pipelines in 2 separate sub-routes (so that you have a simple multicast to "direct:subroute1" and "direct:subroute2" ? I'm curious to see if it makes some differences – TacheDeChoco Jun 01 '23 at 15:22
  • @TacheDeChoco I just tried and it made no difference - both subroutes logged their two respective messages but the multicast still hangs. I tried with and without pipeline wrapping the elements. – Egor Jun 01 '23 at 15:35

1 Answers1

0

This may be due to one or more threads being blocked, so the transaction cannot proceed to commit and times out.

Try a thread dump to see the details, that should show more details to work with. Maybe there is a race condition on a shared connection pool or something.

Guy Pardon
  • 484
  • 2
  • 8