Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-18816

camel-ahc component crashes when a traffic starts too early

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.18.4
    • 3.18.5
    • camel-ahc
    • None
    • Patch Available
    • Unknown

    Description

      Unfortunately it looks that when traffic to camel-ahc component starts to early it crashes with an exception:

      org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: ahc://http://localhost:59729/foo.
      Reason: java.lang.IllegalArgumentException: AsyncHttpClient must be specified on: ahc://http://localhost:59729/foo
         at org.apache.camel.support.cache.DefaultProducerCache.acquireProducer(DefaultProducerCache.java:164)
         at org.apache.camel.processor.RecipientListProcessor.doCreateProcessorExchangePairs(RecipientListProcessor.java:270)
         at org.apache.camel.processor.RecipientListProcessor.createProcessorExchangePairs(RecipientListProcessor.java:246)
         at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:295)
         at org.apache.camel.processor.RecipientList.process(RecipientList.java:175)
         at org.apache.camel.processor.Pipeline$PipelineTask.run(Pipeline.java:106)
         at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:189)
         at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:61)
         at org.apache.camel.processor.Pipeline.process(Pipeline.java:182)
         at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:399)
         at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:210)
         at org.apache.camel.component.timer.TimerConsumer$2.run(TimerConsumer.java:118)
         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
         at java.base/java.lang.Thread.run(Thread.java:829)
      Caused by: java.lang.IllegalArgumentException: AsyncHttpClient must be specified on: ahc://http://localhost:59729/foo
         at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:176)
         at org.apache.camel.component.ahc.AhcEndpoint.createProducer(AhcEndpoint.java:94)
         at org.apache.camel.support.DefaultEndpoint.createAsyncProducer(DefaultEndpoint.java:200)
         at org.apache.camel.support.cache.ServicePool$SinglePool.acquire(ServicePool.java:237)
         at org.apache.camel.support.cache.ServicePool$SinglePool.acquire(ServicePool.java:216)
         at org.apache.camel.support.cache.ServicePool.acquire(ServicePool.java:112)
         at org.apache.camel.support.cache.ProducerServicePool.acquire(ProducerServicePool.java:28)
         at org.apache.camel.support.cache.DefaultProducerCache.acquireProducer(DefaultProducerCache.java:149)
         ... 14 common frames omitted
      

      It causes that all traffic to camel-ahc endpoint is failing. It happens in my application for routes that take messages from JMS queue and sent it to HTTP (using camel-ahc component).

      Here is a test that reproduces a problem:

      public class AhcRecipientListTest extends BaseAhcTest {
      
          @Test
          public void testRecipientListCalledBeforeComponentStarted() throws Exception {
              getMockEndpoint("mock:result").expectedBodiesReceived("Hello");
      
              assertMockEndpointsSatisfied();
          }
      
          @Override
          protected RouteBuilder createRouteBuilder() throws Exception {
              return new RouteBuilder() {
                  @Override
                  public void configure() throws Exception {
                      from("timer://foo?delay=-1&?repeatCount=1")
                          .recipientList(constant(getAhcEndpointUri()))
                          .to("mock:result");
      
                      from(getTestServerEndpointUri())
                          .transform(constant("Hello"));
                  }
              };
          }
      } 

      I've prepared a patch with another 2 tests and a possible bugfix. The bugfix is based on a solution from HttpEnpoint/HttpProducer.

      The bug was discovered in version 3.18.4, but it looks that it was present for a long time.

      Attachments

        1. camel-ahc-bug.patch
          14 kB
          Krzysztof Mackowiak

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kmackowiak Krzysztof Mackowiak
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: