Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-1834

Add Message History support to annotated endpoints

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 2.0.3
    • Fix Version/s: 4.0 M4
    • Component/s: Core
    • Labels:

      Description

      MessageHistory skips the Handlers annotated with MessageEndpoint.

      When using the xml declaration we have an option to name the Handler:

      <router id="myRouter" ref="myRouterBean" .../>

      If we switch this example to using Annotations you will loose the ability of naming the Handler,
      and then the MessageHistory will skip the Handler, as it's name will be auto-generated and it will
      start with 'org.springframework.integration'.

      The Spring Integration annotations such as @Transformer, @ServiceActivator, and all other annotation
      that end up creating a Handler, should have an id attribute to behave like the id attribute from
      their XML counterparts.

        Activity

        Hide
        abilan Artem Bilan added a comment -

        Hi, all!

        I've investigated the problem and found that it is lying inside the MessagingAnnotationPostProcessor, when this post-processor registers 'singleton' for AbstractEndpoint from delegated MethodAnnotationPostProcessor. But the last one doesn't register Handler bean for annotated method. In the other words: Annotation processing doesn't work like xml parsing.
        Also there is no any reason to introduce some "id" attribute for SI-annotations: when I change the AbstractMethodAnnotationPostProcessor to register Handler as a singleton, this bean takes the beanName by pattern:

         
        String baseName = originalBeanName + "." + method.getName() + "." + ClassUtils.getShortNameAsProperty(annotationType);
        String name = baseName;
        int count = 1;
        while (this.beanFactory.containsBean(name)) {
        	name = baseName + "#" + (++count);
        }
        return name;
         

        In the end this Handler is tracked by <message-history/> as well as xml-component with 'id'.

        So, if it is OK and enough to "Add Message History support to annotated endpoints" let me implement it on the next Sprint.

        Show
        abilan Artem Bilan added a comment - Hi, all! I've investigated the problem and found that it is lying inside the MessagingAnnotationPostProcessor , when this post-processor registers 'singleton' for AbstractEndpoint from delegated MethodAnnotationPostProcessor . But the last one doesn't register Handler bean for annotated method. In the other words: Annotation processing doesn't work like xml parsing. Also there is no any reason to introduce some "id" attribute for SI-annotations: when I change the AbstractMethodAnnotationPostProcessor to register Handler as a singleton, this bean takes the beanName by pattern:   String baseName = originalBeanName + "." + method.getName() + "." + ClassUtils.getShortNameAsProperty(annotationType); String name = baseName; int count = 1 ; while ( this .beanFactory.containsBean(name)) { name = baseName + "#" + (++count); } return name;   In the end this Handler is tracked by <message-history/> as well as xml-component with 'id'. So, if it is OK and enough to "Add Message History support to annotated endpoints" let me implement it on the next Sprint.
        Show
        abilan Artem Bilan added a comment - PR: https://github.com/spring-projects/spring-integration/pull/1063
        Hide
        grussell Gary Russell added a comment -

        Merged

        Show
        grussell Gary Russell added a comment - Merged

          People

          • Assignee:
            abilan Artem Bilan
            Reporter:
            mih_vlad MIhalcea Vlad
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: