Announcement Announcement Module
Collapse
No announcement yet.
cafe sample - annotation/XML config usage? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • cafe sample - annotation/XML config usage?

    While reviewing the cafe sample code, I wanted to see how I could save 2 lines of XML config by using annotations on the Barista class to do things like configuring the concurrency policy and parameterizing the handlers.

    The API doesn't support this, but I first thought something like the following would be ok

    Code:
    // INVALID CODE
    @MessageEndpoint
    @Concurrency(core="25", max="50")
    public class Barista {
        ...
    
        @Handler(input="coldDrinks")
        public void prepareColdDrink(Drink drink) {...}
    
        @Handler(input="hotDrinks")
        public void prepareHotDrink(Drink drink) {...}
    
        ...
    }
    ...and then I threw this style out as it makes the endpoint almost completely non-resusable...appears locked to a specific concurrency strategy and channel mapping at compile time.

    Not being that familiar with the API yet, any usage suggestions on annotations and XML config? I'm all for minimizing the XML config

    Jon

  • #2
    Jon,

    There has been a plan to add the @Concurrency annotation or at least concurrency attributes for the @MessageEndpoint annotation. For per-channel handler methods like that, the @Subscriber annotation would provide individual endpoints for the methods. If a @Concurrency annotation were available, then it could be applied alongside either of the @MessageEndpoint or @Subscriber annotations. That said, I do agree that externalized configuration of the concurrency values seems more appropriate.

    Mark

    Comment


    • #3
      Mark,

      Thanks for summarizing a usage of @Subscriber.

      I'm trying to dig through the code to better conceptualize what "Indicates that method-invoking handler adapter should delegate to this method" means as far as the behind-the-scenes activity. Maybe a proxy (which intfc?) that forwards to the annotated method when any message is sent to the specified channel?

      What intfc's/classes should I focus on to learn more?

      Jon

      Comment


      • #4
        Have a look at: org.springframework.integration.config.Susbscriber AnnotationPostProcessor

        And let me know if you have any further questions. The documentation will continue to evolve in terms of the amount of detail.

        Hope that helps.
        -Mark

        Comment

        Working...
        X