GitHub user RovoMe opened a pull request:

    https://github.com/apache/camel/pull/2288

    AWS XRay - suppress stacktrace on already emitted segments

    Currently when invoking a route asynchronously via Camel there is a chance 
that the processing of that code doesn't occur before the current thread was 
able to complete its task and therefore allowing XRay to emit the segment. On 
processing of the asynchronous route and its beans or processors, the segment 
was already emitted and thus XRay does not allow to send that information to 
AWS. In that case an `AlreadyEmittedException` is thrown.
    
    This PR will catch these exceptions and convert them to a warn-log. A 
further test using a custom compoent which uses a backing service for certain 
states that sends data to a further route asynchronously was added to showcase 
the cases when this issue may occur.
    
    Other XRay based tests also got updated slightly in order to use 
`NotifyBuilder` in order to avoid timing issues and `Thread.sleep(...)` 
instructions.
    
    Note that this PR is for 2.21.x and probably needs to be cherry-picked into 
master as well

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/RovoMe/camel fix/XRayCustomComponentTest

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/camel/pull/2288.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2288
    
----
commit ea42bb9b0b90fbdb477692dc16cf94cd9ff93083
Author: Roman Vottner <rovo@...>
Date:   2018-04-11T15:19:06Z

    Added test for custom component which uses a backing service which 
furthermore sends data to a further Camel route asynchronously. As the 
processing route was a single consumer thread it couldn't process new tasks 
issued to it till the further task was finished leading to XRay emitting the 
segment preemptively as it wasn't aware that some stuff from the asynchronous 
route, which wasn't processed yet, belong to it. Later on, when the 
asynchronous code was executed an AlreadyEmittedException was thrown which is 
now caught by the XRayTracer object and converted to a warn-log.
    Added also notify builders to each test case in order to get issues with 
test-timing right. This also has the benefit to get rid of Thread.sleeps(...) 
inside of the tests itself

----


---

Reply via email to