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

@Produce and @Consume injected on prototype beans needs a mechanism for automatic stopping when no longer in use

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Won't Fix
    • 2.2.0
    • Future
    • camel-spring
    • None

    Description

      This only applies for prototype scoped POJOs which uses @Produce or @Consume to inject a Camel Producer/Consumer.

      As the prototype scoped POJO is short lived and there could potentially be created many of those POJOs.
      Then @Produce / @Consume will inject new instances of Producer / Consumer as well.

      And since there is no standard way of knowing when the POJO is no longer in need, which is where we can to stop the Producer/Consumer.

      For singleton scoped this is not a problem as CamelContext will keep track on the created Producer/Consumer in its internal servicesToClose.
      Which is then stopped when CamelContext stops.

      For prototype we need a different strategy such as

      • proxy it to use pooled producers/consumers which CamelContext manage the lifecycle
      • use a shared ProducerTemplate / ConsumerTemplate instead which CamelContext manages the lifecycle
      • other
      • maybe some thread local tricks

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            davsclaus Claus Ibsen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: