Frage

Im using Camel 2.10.3.

Let's assume I have a route that looks something like the following:

from("direct:split")
  .routeId("split-ti-analytics-events")
  .split().method(JsonArraySplitter.class,"split")
  .parallelProcessing()
  .log("Received: ${body}")
  .to("stub:direct:somewhere");

And a test class that does that following with NotifyBuilder to assert my splitter is doing what it ought to.

@Test(description = "Asserts that when we receive a json event that we properly split the " +
            "events if the payload was a json array.")
public void testReceiveTiAnalyticsArrayOfJsonEvents() {
    NotifyBuilder notifier = new NotifyBuilder(context)
      .wereSentTo("stub:direct:somewhere")
      .whenExactlyDone(7)
      .create();
      producerTemplate.sendBody("direct:split", sampleEventsInArrayJsonString);

      assertTrue(notifier.matches(5, TimeUnit.SECONDS));
}

And assume sampleEventsInArrayJsonString is a json array that looks like:

[{},{},{},{},{},{},{}]

Where there are 7 object elements in that json array.

The test will fail pretty much immediately. However, the output of the test clearly shows 7 log messages of "Received: {}".

Now, here's the fun part... in the NotifyBuilder if I set .whenExactlyDone(8), then the test passes. Where on earth would that 8th message be coming from? I'd love to just say this test is valid and call it a day since I know it's getting at least the messages split off from that json array (ignoring the fact I'm not verifying the contents in NotifyBuilder), but I'm concerned about actually having an 8th exchange sent through route that doesn't belong. What is the reason NotifyBuilder sees 8 exchanges that are done through that route instead of 7?

War es hilfreich?

Lösung

Yes this is a little bug in Camel. I have logged a ticket, and a working fix in the tests https://issues.apache.org/jira/browse/CAMEL-6255

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top