Camel
  1. Camel
  2. CAMEL-4928

Async API support by the Timer component

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9.0
    • Fix Version/s: 2.12.0
    • Component/s: camel-core
    • Labels:
    • Patch Info:
      Patch Available
    • Estimated Complexity:
      Unknown

      Description

      It would be great to have timer component support asynchronous API.
      Such a feature can be useful when timer component generates events which must be processed by multiple threads.
      Current implementation of the timer component makes a blocking call so the usage of thread pools hardly possible to process multiple timer event simultaneously.

      Sample
      from("timer:start")
          .threads(1, 5)
          .to("bean:very-long-operation");
      
      1. CAMEL-4928.patch
        5 kB
        Sergey Zhemzhitsky

        Activity

        Hide
        Sergey Zhemzhitsky added a comment -

        New async parameter has been added in the included patch.

        Sample
        from("timer:start?async=true")
            .threads(1, 5)
            .to("bean:very-long-operation")
        

        So by default the behavior is exactly the same as in the previous version of timer and if one want to use asynchronous API async=true parameter should be added in the endpoint uri.

        The patch also includes doSuspend and doResume methods in the TimerConsumer to be able to stop the route faster and to prevent the timer running during stopping the route when using async. api.

        Show
        Sergey Zhemzhitsky added a comment - New async parameter has been added in the included patch. Sample from( "timer:start?async= true " ) .threads(1, 5) .to( "bean:very- long -operation" ) So by default the behavior is exactly the same as in the previous version of timer and if one want to use asynchronous API async=true parameter should be added in the endpoint uri. The patch also includes doSuspend and doResume methods in the TimerConsumer to be able to stop the route faster and to prevent the timer running during stopping the route when using async. api.
        Hide
        Claus Ibsen added a comment -

        I think the consumers should use the Async API by default. People can disable async in their routes by setting synchronous=false, on the endpoint uri's if they want that disabled.

        Or we could introduce asyncConsumer=true|false as a general option, for people to control this.

        The JMS consumer already have the asyncConsumer option.

        Show
        Claus Ibsen added a comment - I think the consumers should use the Async API by default. People can disable async in their routes by setting synchronous=false, on the endpoint uri's if they want that disabled. Or we could introduce asyncConsumer=true|false as a general option, for people to control this. The JMS consumer already have the asyncConsumer option.
        Hide
        Sergey Zhemzhitsky added a comment -

        I noticed that synchronous=false is used primarily by producers and asyncConsumer parameter exists only in jms consumer, so I suppose that synchronous parameter can be used to determine whether both producers or consumers should be synchronous. (Maybe jms consumer should consider using of synchronous parameter instead of asyncConsumer to prevent introduction of new parameters for the same thing in other components)

        So, the patch was replaced to involve usage of synchronous parameter.

        Show
        Sergey Zhemzhitsky added a comment - I noticed that synchronous=false is used primarily by producers and asyncConsumer parameter exists only in jms consumer, so I suppose that synchronous parameter can be used to determine whether both producers or consumers should be synchronous. (Maybe jms consumer should consider using of synchronous parameter instead of asyncConsumer to prevent introduction of new parameters for the same thing in other components) So, the patch was replaced to involve usage of synchronous parameter.
        Hide
        Claus Ibsen added a comment -

        Thanks for the patch.

        Show
        Claus Ibsen added a comment - Thanks for the patch.

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Sergey Zhemzhitsky
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development