Spring Integration 2.2.3.RELEASE @ServiceActivator not invoked










0















I have a legacy code with these versions (Spring version: 3.2.1.RELEASE and Spring Integration version 2.2.3.RELEASE). I would like to migrate all xml configurations of spring integration to java configuration.
Before starting the migration, I am making some test and I am struggling with @ServiceActivator which does not work.
My example is:



@Configuration
@ImportResource("classpath*:integration-config.xml")
public static class IntegrationConfig
@Bean
public MessageChannel queueChannel()
return new QueueChannel(5);


@Bean
public MessageChannel pubSubChannel()
PublishSubscribeChannel publishSubscribeChannel = new PublishSubscribeChannel();
publishSubscribeChannel.subscribe(new MessageHandler()
@Override
public void handleMessage(Message<?> message) throws MessagingException
System.out.println("First handler :" + message.getPayload());

);

publishSubscribeChannel.subscribe(new MessageHandler()
@Override
public void handleMessage(Message<?> message) throws MessagingException
System.out.println("Second handler :" + message.getPayload());

);
return publishSubscribeChannel;




And :



@MessageEndpoint
public static class MessageEndpointDefintion

@ServiceActivator(inputChannel = "queueChannel")
public void queueActivator(String payload)
System.out.println("Payload from queue : " + payload);


@ServiceActivator(inputChannel = "pubSubChannel")
public void pubSubActivator(Message<String> message)
System.out.println("Payload from pub-sub :" + message.getPayload());




When I send some messages in the channels any @ServiceActivator is invoked.



As indicated here: , adding @EnableIntegration (available since version 4 of Spring Integration) could solve the problem, but in my case I am using the version 2.2.3 which does not provide this annotation. If they provide this annotation in this version, I think we can use it but how?



Other question, can I upgrade Spring Integration version to 4 with the same version of Spring (3.2.1)?
Thanks



EDIT



I call my configuration like this:
AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class); and an example of test:



PublishSubscribeChannel publishSubscribeChannel;
publishSubscribeChannel = (PublishSubscribeChannel) context.getBean("pubSubChannel", MessageChannel.class);
publishSubscribeChannel.send(MessageBuilder.withPayload("==PUB-SUB-CHANNEL== ").build());


And integration-config.xml :



<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.springframework.org/schema/c"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">

<int:annotation-config/>

<xsd:element name="annotation-config">
<xsd:annotation>
<xsd:documentation>
Enables annotation support for Message Endpoints.
</xsd:documentation>
</xsd:annotation>
</xsd:element>











share|improve this question




























    0















    I have a legacy code with these versions (Spring version: 3.2.1.RELEASE and Spring Integration version 2.2.3.RELEASE). I would like to migrate all xml configurations of spring integration to java configuration.
    Before starting the migration, I am making some test and I am struggling with @ServiceActivator which does not work.
    My example is:



    @Configuration
    @ImportResource("classpath*:integration-config.xml")
    public static class IntegrationConfig
    @Bean
    public MessageChannel queueChannel()
    return new QueueChannel(5);


    @Bean
    public MessageChannel pubSubChannel()
    PublishSubscribeChannel publishSubscribeChannel = new PublishSubscribeChannel();
    publishSubscribeChannel.subscribe(new MessageHandler()
    @Override
    public void handleMessage(Message<?> message) throws MessagingException
    System.out.println("First handler :" + message.getPayload());

    );

    publishSubscribeChannel.subscribe(new MessageHandler()
    @Override
    public void handleMessage(Message<?> message) throws MessagingException
    System.out.println("Second handler :" + message.getPayload());

    );
    return publishSubscribeChannel;




    And :



    @MessageEndpoint
    public static class MessageEndpointDefintion

    @ServiceActivator(inputChannel = "queueChannel")
    public void queueActivator(String payload)
    System.out.println("Payload from queue : " + payload);


    @ServiceActivator(inputChannel = "pubSubChannel")
    public void pubSubActivator(Message<String> message)
    System.out.println("Payload from pub-sub :" + message.getPayload());




    When I send some messages in the channels any @ServiceActivator is invoked.



    As indicated here: , adding @EnableIntegration (available since version 4 of Spring Integration) could solve the problem, but in my case I am using the version 2.2.3 which does not provide this annotation. If they provide this annotation in this version, I think we can use it but how?



    Other question, can I upgrade Spring Integration version to 4 with the same version of Spring (3.2.1)?
    Thanks



    EDIT



    I call my configuration like this:
    AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class); and an example of test:



    PublishSubscribeChannel publishSubscribeChannel;
    publishSubscribeChannel = (PublishSubscribeChannel) context.getBean("pubSubChannel", MessageChannel.class);
    publishSubscribeChannel.send(MessageBuilder.withPayload("==PUB-SUB-CHANNEL== ").build());


    And integration-config.xml :



    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.springframework.org/schema/c"
    xmlns:int="http://www.springframework.org/schema/integration"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">

    <int:annotation-config/>

    <xsd:element name="annotation-config">
    <xsd:annotation>
    <xsd:documentation>
    Enables annotation support for Message Endpoints.
    </xsd:documentation>
    </xsd:annotation>
    </xsd:element>











    share|improve this question


























      0












      0








      0








      I have a legacy code with these versions (Spring version: 3.2.1.RELEASE and Spring Integration version 2.2.3.RELEASE). I would like to migrate all xml configurations of spring integration to java configuration.
      Before starting the migration, I am making some test and I am struggling with @ServiceActivator which does not work.
      My example is:



      @Configuration
      @ImportResource("classpath*:integration-config.xml")
      public static class IntegrationConfig
      @Bean
      public MessageChannel queueChannel()
      return new QueueChannel(5);


      @Bean
      public MessageChannel pubSubChannel()
      PublishSubscribeChannel publishSubscribeChannel = new PublishSubscribeChannel();
      publishSubscribeChannel.subscribe(new MessageHandler()
      @Override
      public void handleMessage(Message<?> message) throws MessagingException
      System.out.println("First handler :" + message.getPayload());

      );

      publishSubscribeChannel.subscribe(new MessageHandler()
      @Override
      public void handleMessage(Message<?> message) throws MessagingException
      System.out.println("Second handler :" + message.getPayload());

      );
      return publishSubscribeChannel;




      And :



      @MessageEndpoint
      public static class MessageEndpointDefintion

      @ServiceActivator(inputChannel = "queueChannel")
      public void queueActivator(String payload)
      System.out.println("Payload from queue : " + payload);


      @ServiceActivator(inputChannel = "pubSubChannel")
      public void pubSubActivator(Message<String> message)
      System.out.println("Payload from pub-sub :" + message.getPayload());




      When I send some messages in the channels any @ServiceActivator is invoked.



      As indicated here: , adding @EnableIntegration (available since version 4 of Spring Integration) could solve the problem, but in my case I am using the version 2.2.3 which does not provide this annotation. If they provide this annotation in this version, I think we can use it but how?



      Other question, can I upgrade Spring Integration version to 4 with the same version of Spring (3.2.1)?
      Thanks



      EDIT



      I call my configuration like this:
      AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class); and an example of test:



      PublishSubscribeChannel publishSubscribeChannel;
      publishSubscribeChannel = (PublishSubscribeChannel) context.getBean("pubSubChannel", MessageChannel.class);
      publishSubscribeChannel.send(MessageBuilder.withPayload("==PUB-SUB-CHANNEL== ").build());


      And integration-config.xml :



      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.springframework.org/schema/c"
      xmlns:int="http://www.springframework.org/schema/integration"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">

      <int:annotation-config/>

      <xsd:element name="annotation-config">
      <xsd:annotation>
      <xsd:documentation>
      Enables annotation support for Message Endpoints.
      </xsd:documentation>
      </xsd:annotation>
      </xsd:element>











      share|improve this question
















      I have a legacy code with these versions (Spring version: 3.2.1.RELEASE and Spring Integration version 2.2.3.RELEASE). I would like to migrate all xml configurations of spring integration to java configuration.
      Before starting the migration, I am making some test and I am struggling with @ServiceActivator which does not work.
      My example is:



      @Configuration
      @ImportResource("classpath*:integration-config.xml")
      public static class IntegrationConfig
      @Bean
      public MessageChannel queueChannel()
      return new QueueChannel(5);


      @Bean
      public MessageChannel pubSubChannel()
      PublishSubscribeChannel publishSubscribeChannel = new PublishSubscribeChannel();
      publishSubscribeChannel.subscribe(new MessageHandler()
      @Override
      public void handleMessage(Message<?> message) throws MessagingException
      System.out.println("First handler :" + message.getPayload());

      );

      publishSubscribeChannel.subscribe(new MessageHandler()
      @Override
      public void handleMessage(Message<?> message) throws MessagingException
      System.out.println("Second handler :" + message.getPayload());

      );
      return publishSubscribeChannel;




      And :



      @MessageEndpoint
      public static class MessageEndpointDefintion

      @ServiceActivator(inputChannel = "queueChannel")
      public void queueActivator(String payload)
      System.out.println("Payload from queue : " + payload);


      @ServiceActivator(inputChannel = "pubSubChannel")
      public void pubSubActivator(Message<String> message)
      System.out.println("Payload from pub-sub :" + message.getPayload());




      When I send some messages in the channels any @ServiceActivator is invoked.



      As indicated here: , adding @EnableIntegration (available since version 4 of Spring Integration) could solve the problem, but in my case I am using the version 2.2.3 which does not provide this annotation. If they provide this annotation in this version, I think we can use it but how?



      Other question, can I upgrade Spring Integration version to 4 with the same version of Spring (3.2.1)?
      Thanks



      EDIT



      I call my configuration like this:
      AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class); and an example of test:



      PublishSubscribeChannel publishSubscribeChannel;
      publishSubscribeChannel = (PublishSubscribeChannel) context.getBean("pubSubChannel", MessageChannel.class);
      publishSubscribeChannel.send(MessageBuilder.withPayload("==PUB-SUB-CHANNEL== ").build());


      And integration-config.xml :



      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.springframework.org/schema/c"
      xmlns:int="http://www.springframework.org/schema/integration"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">

      <int:annotation-config/>

      <xsd:element name="annotation-config">
      <xsd:annotation>
      <xsd:documentation>
      Enables annotation support for Message Endpoints.
      </xsd:documentation>
      </xsd:annotation>
      </xsd:element>








      java spring spring-integration integration spring-annotations






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 16:53







      akuma8

















      asked Nov 13 '18 at 16:14









      akuma8akuma8

      868820




      868820






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You are missing missing to add into your XML config this:



          <int:annotation-config/>

          <xsd:element name="annotation-config">
          <xsd:annotation>
          <xsd:documentation>
          Enables annotation support for Message Endpoints.
          </xsd:documentation>
          </xsd:annotation>


          Unfortunately that old version can't go just with plain annotations. The whole Spring Integration engine is triggered from XML.



          And no: you can't upgrade Spring Integration without upgrading Spring Framework.






          share|improve this answer























          • In my main class I use annotation config :AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class);

            – akuma8
            Nov 13 '18 at 16:37












          • Well, you don't listen: Spring Integration is still not going to work there with just plain Java & annotation configuration. You need to add at least simple XML with that tag and @ImportResource it on your @Configuration

            – Artem Bilan
            Nov 13 '18 at 16:39











          • I added one and import it as suggested but same result. I edited my post for more infos

            – akuma8
            Nov 13 '18 at 16:54











          • Works fine now, it seems like using @ServiceActivator for a queue channel causes some trouble since we have any way to define a poller inside the annotation. Thanks a lot for your help

            – akuma8
            Nov 13 '18 at 21:38











          • Right, you can't use QueueChannel for @ServiceActivator in that old version. That becomes available in face of @Poller sub-annotation since version 4.0

            – Artem Bilan
            Nov 13 '18 at 21:42










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285139%2fspring-integration-2-2-3-release-serviceactivator-not-invoked%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You are missing missing to add into your XML config this:



          <int:annotation-config/>

          <xsd:element name="annotation-config">
          <xsd:annotation>
          <xsd:documentation>
          Enables annotation support for Message Endpoints.
          </xsd:documentation>
          </xsd:annotation>


          Unfortunately that old version can't go just with plain annotations. The whole Spring Integration engine is triggered from XML.



          And no: you can't upgrade Spring Integration without upgrading Spring Framework.






          share|improve this answer























          • In my main class I use annotation config :AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class);

            – akuma8
            Nov 13 '18 at 16:37












          • Well, you don't listen: Spring Integration is still not going to work there with just plain Java & annotation configuration. You need to add at least simple XML with that tag and @ImportResource it on your @Configuration

            – Artem Bilan
            Nov 13 '18 at 16:39











          • I added one and import it as suggested but same result. I edited my post for more infos

            – akuma8
            Nov 13 '18 at 16:54











          • Works fine now, it seems like using @ServiceActivator for a queue channel causes some trouble since we have any way to define a poller inside the annotation. Thanks a lot for your help

            – akuma8
            Nov 13 '18 at 21:38











          • Right, you can't use QueueChannel for @ServiceActivator in that old version. That becomes available in face of @Poller sub-annotation since version 4.0

            – Artem Bilan
            Nov 13 '18 at 21:42















          1














          You are missing missing to add into your XML config this:



          <int:annotation-config/>

          <xsd:element name="annotation-config">
          <xsd:annotation>
          <xsd:documentation>
          Enables annotation support for Message Endpoints.
          </xsd:documentation>
          </xsd:annotation>


          Unfortunately that old version can't go just with plain annotations. The whole Spring Integration engine is triggered from XML.



          And no: you can't upgrade Spring Integration without upgrading Spring Framework.






          share|improve this answer























          • In my main class I use annotation config :AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class);

            – akuma8
            Nov 13 '18 at 16:37












          • Well, you don't listen: Spring Integration is still not going to work there with just plain Java & annotation configuration. You need to add at least simple XML with that tag and @ImportResource it on your @Configuration

            – Artem Bilan
            Nov 13 '18 at 16:39











          • I added one and import it as suggested but same result. I edited my post for more infos

            – akuma8
            Nov 13 '18 at 16:54











          • Works fine now, it seems like using @ServiceActivator for a queue channel causes some trouble since we have any way to define a poller inside the annotation. Thanks a lot for your help

            – akuma8
            Nov 13 '18 at 21:38











          • Right, you can't use QueueChannel for @ServiceActivator in that old version. That becomes available in face of @Poller sub-annotation since version 4.0

            – Artem Bilan
            Nov 13 '18 at 21:42













          1












          1








          1







          You are missing missing to add into your XML config this:



          <int:annotation-config/>

          <xsd:element name="annotation-config">
          <xsd:annotation>
          <xsd:documentation>
          Enables annotation support for Message Endpoints.
          </xsd:documentation>
          </xsd:annotation>


          Unfortunately that old version can't go just with plain annotations. The whole Spring Integration engine is triggered from XML.



          And no: you can't upgrade Spring Integration without upgrading Spring Framework.






          share|improve this answer













          You are missing missing to add into your XML config this:



          <int:annotation-config/>

          <xsd:element name="annotation-config">
          <xsd:annotation>
          <xsd:documentation>
          Enables annotation support for Message Endpoints.
          </xsd:documentation>
          </xsd:annotation>


          Unfortunately that old version can't go just with plain annotations. The whole Spring Integration engine is triggered from XML.



          And no: you can't upgrade Spring Integration without upgrading Spring Framework.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 16:35









          Artem BilanArtem Bilan

          64.8k84668




          64.8k84668












          • In my main class I use annotation config :AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class);

            – akuma8
            Nov 13 '18 at 16:37












          • Well, you don't listen: Spring Integration is still not going to work there with just plain Java & annotation configuration. You need to add at least simple XML with that tag and @ImportResource it on your @Configuration

            – Artem Bilan
            Nov 13 '18 at 16:39











          • I added one and import it as suggested but same result. I edited my post for more infos

            – akuma8
            Nov 13 '18 at 16:54











          • Works fine now, it seems like using @ServiceActivator for a queue channel causes some trouble since we have any way to define a poller inside the annotation. Thanks a lot for your help

            – akuma8
            Nov 13 '18 at 21:38











          • Right, you can't use QueueChannel for @ServiceActivator in that old version. That becomes available in face of @Poller sub-annotation since version 4.0

            – Artem Bilan
            Nov 13 '18 at 21:42

















          • In my main class I use annotation config :AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class);

            – akuma8
            Nov 13 '18 at 16:37












          • Well, you don't listen: Spring Integration is still not going to work there with just plain Java & annotation configuration. You need to add at least simple XML with that tag and @ImportResource it on your @Configuration

            – Artem Bilan
            Nov 13 '18 at 16:39











          • I added one and import it as suggested but same result. I edited my post for more infos

            – akuma8
            Nov 13 '18 at 16:54











          • Works fine now, it seems like using @ServiceActivator for a queue channel causes some trouble since we have any way to define a poller inside the annotation. Thanks a lot for your help

            – akuma8
            Nov 13 '18 at 21:38











          • Right, you can't use QueueChannel for @ServiceActivator in that old version. That becomes available in face of @Poller sub-annotation since version 4.0

            – Artem Bilan
            Nov 13 '18 at 21:42
















          In my main class I use annotation config :AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class);

          – akuma8
          Nov 13 '18 at 16:37






          In my main class I use annotation config :AbstractApplicationContext context = new AnnotationConfigApplicationContext(IntegrationConfig.class);

          – akuma8
          Nov 13 '18 at 16:37














          Well, you don't listen: Spring Integration is still not going to work there with just plain Java & annotation configuration. You need to add at least simple XML with that tag and @ImportResource it on your @Configuration

          – Artem Bilan
          Nov 13 '18 at 16:39





          Well, you don't listen: Spring Integration is still not going to work there with just plain Java & annotation configuration. You need to add at least simple XML with that tag and @ImportResource it on your @Configuration

          – Artem Bilan
          Nov 13 '18 at 16:39













          I added one and import it as suggested but same result. I edited my post for more infos

          – akuma8
          Nov 13 '18 at 16:54





          I added one and import it as suggested but same result. I edited my post for more infos

          – akuma8
          Nov 13 '18 at 16:54













          Works fine now, it seems like using @ServiceActivator for a queue channel causes some trouble since we have any way to define a poller inside the annotation. Thanks a lot for your help

          – akuma8
          Nov 13 '18 at 21:38





          Works fine now, it seems like using @ServiceActivator for a queue channel causes some trouble since we have any way to define a poller inside the annotation. Thanks a lot for your help

          – akuma8
          Nov 13 '18 at 21:38













          Right, you can't use QueueChannel for @ServiceActivator in that old version. That becomes available in face of @Poller sub-annotation since version 4.0

          – Artem Bilan
          Nov 13 '18 at 21:42





          Right, you can't use QueueChannel for @ServiceActivator in that old version. That becomes available in face of @Poller sub-annotation since version 4.0

          – Artem Bilan
          Nov 13 '18 at 21:42

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285139%2fspring-integration-2-2-3-release-serviceactivator-not-invoked%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3

          Museum of Modern and Contemporary Art of Trento and Rovereto