ReplyRequiredException on attempt to get data from ?












1















I would like to define an
<int-jdbc:outbound-gateway/> with query and without update to retrieve data from database. Then I would like to use the int-jdbc:outbound-gateway as an implementation of Service.findSomeData() interface method. The data retrieved from interface implementation is used in my custom transformer's CheckService class. See the configuration below:



<int:service-activator method=“performCheck”>
<bean class=“com.example.service.CheckService”
c:service-ref=“service”
</int:service-activator>

<int:gateway id=“service” service-interface=“com.example.service.Service”>
<int:method name=“findSomeData” request-channel=“jdbcChan” reply-channel=“jdbcChanReply”/>
</int:gateway>

<int-jdbc:outbound-gateway request-channel=“jdbcChan”
data-source=“pooledDs” row-mapper=“dataRowMapper” reply-channel=“jdbcChanReply”>
<int-jdbc:query>
select some, data from some_table
</int-jdbc:query>




The problem is that I get ReplyRequiredException exception when I move my payload to jdbcChan:




org.springframework.integration.handler.ReplyRequiredException: No reply produced by handler 'org.springframework.integration.jdbc.JdbcOutboundGateway#0', and its 'requiresReply' property is set to true.




I decided to pay more attention on example located in spring in spring-integration-samples repository on GitHub, but looks like it also does not work as expected. I get exactly the same exception in example project trying to find User by name foo. You can easily reproduce the exception with basic jdbc example located on GitHub and the following test method:



@Test
public void findPerson() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"/META-INF/spring/integration/spring-integration-context.xml");
PersonService service = context.getBean(PersonService.class);
final List<Person> foo = service.findPersonByName("foo");
assertThat(foo, is(not(empty())));
}


Am I doing it wrong or there is a bug in latest Spring Integration JDBC? (for me looks like even example is broken)










share|improve this question



























    1















    I would like to define an
    <int-jdbc:outbound-gateway/> with query and without update to retrieve data from database. Then I would like to use the int-jdbc:outbound-gateway as an implementation of Service.findSomeData() interface method. The data retrieved from interface implementation is used in my custom transformer's CheckService class. See the configuration below:



    <int:service-activator method=“performCheck”>
    <bean class=“com.example.service.CheckService”
    c:service-ref=“service”
    </int:service-activator>

    <int:gateway id=“service” service-interface=“com.example.service.Service”>
    <int:method name=“findSomeData” request-channel=“jdbcChan” reply-channel=“jdbcChanReply”/>
    </int:gateway>

    <int-jdbc:outbound-gateway request-channel=“jdbcChan”
    data-source=“pooledDs” row-mapper=“dataRowMapper” reply-channel=“jdbcChanReply”>
    <int-jdbc:query>
    select some, data from some_table
    </int-jdbc:query>




    The problem is that I get ReplyRequiredException exception when I move my payload to jdbcChan:




    org.springframework.integration.handler.ReplyRequiredException: No reply produced by handler 'org.springframework.integration.jdbc.JdbcOutboundGateway#0', and its 'requiresReply' property is set to true.




    I decided to pay more attention on example located in spring in spring-integration-samples repository on GitHub, but looks like it also does not work as expected. I get exactly the same exception in example project trying to find User by name foo. You can easily reproduce the exception with basic jdbc example located on GitHub and the following test method:



    @Test
    public void findPerson() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
    "/META-INF/spring/integration/spring-integration-context.xml");
    PersonService service = context.getBean(PersonService.class);
    final List<Person> foo = service.findPersonByName("foo");
    assertThat(foo, is(not(empty())));
    }


    Am I doing it wrong or there is a bug in latest Spring Integration JDBC? (for me looks like even example is broken)










    share|improve this question

























      1












      1








      1








      I would like to define an
      <int-jdbc:outbound-gateway/> with query and without update to retrieve data from database. Then I would like to use the int-jdbc:outbound-gateway as an implementation of Service.findSomeData() interface method. The data retrieved from interface implementation is used in my custom transformer's CheckService class. See the configuration below:



      <int:service-activator method=“performCheck”>
      <bean class=“com.example.service.CheckService”
      c:service-ref=“service”
      </int:service-activator>

      <int:gateway id=“service” service-interface=“com.example.service.Service”>
      <int:method name=“findSomeData” request-channel=“jdbcChan” reply-channel=“jdbcChanReply”/>
      </int:gateway>

      <int-jdbc:outbound-gateway request-channel=“jdbcChan”
      data-source=“pooledDs” row-mapper=“dataRowMapper” reply-channel=“jdbcChanReply”>
      <int-jdbc:query>
      select some, data from some_table
      </int-jdbc:query>




      The problem is that I get ReplyRequiredException exception when I move my payload to jdbcChan:




      org.springframework.integration.handler.ReplyRequiredException: No reply produced by handler 'org.springframework.integration.jdbc.JdbcOutboundGateway#0', and its 'requiresReply' property is set to true.




      I decided to pay more attention on example located in spring in spring-integration-samples repository on GitHub, but looks like it also does not work as expected. I get exactly the same exception in example project trying to find User by name foo. You can easily reproduce the exception with basic jdbc example located on GitHub and the following test method:



      @Test
      public void findPerson() {
      ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
      "/META-INF/spring/integration/spring-integration-context.xml");
      PersonService service = context.getBean(PersonService.class);
      final List<Person> foo = service.findPersonByName("foo");
      assertThat(foo, is(not(empty())));
      }


      Am I doing it wrong or there is a bug in latest Spring Integration JDBC? (for me looks like even example is broken)










      share|improve this question














      I would like to define an
      <int-jdbc:outbound-gateway/> with query and without update to retrieve data from database. Then I would like to use the int-jdbc:outbound-gateway as an implementation of Service.findSomeData() interface method. The data retrieved from interface implementation is used in my custom transformer's CheckService class. See the configuration below:



      <int:service-activator method=“performCheck”>
      <bean class=“com.example.service.CheckService”
      c:service-ref=“service”
      </int:service-activator>

      <int:gateway id=“service” service-interface=“com.example.service.Service”>
      <int:method name=“findSomeData” request-channel=“jdbcChan” reply-channel=“jdbcChanReply”/>
      </int:gateway>

      <int-jdbc:outbound-gateway request-channel=“jdbcChan”
      data-source=“pooledDs” row-mapper=“dataRowMapper” reply-channel=“jdbcChanReply”>
      <int-jdbc:query>
      select some, data from some_table
      </int-jdbc:query>




      The problem is that I get ReplyRequiredException exception when I move my payload to jdbcChan:




      org.springframework.integration.handler.ReplyRequiredException: No reply produced by handler 'org.springframework.integration.jdbc.JdbcOutboundGateway#0', and its 'requiresReply' property is set to true.




      I decided to pay more attention on example located in spring in spring-integration-samples repository on GitHub, but looks like it also does not work as expected. I get exactly the same exception in example project trying to find User by name foo. You can easily reproduce the exception with basic jdbc example located on GitHub and the following test method:



      @Test
      public void findPerson() {
      ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
      "/META-INF/spring/integration/spring-integration-context.xml");
      PersonService service = context.getBean(PersonService.class);
      final List<Person> foo = service.findPersonByName("foo");
      assertThat(foo, is(not(empty())));
      }


      Am I doing it wrong or there is a bug in latest Spring Integration JDBC? (for me looks like even example is broken)







      spring-integration






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 21:39









      DerpDerp

      1,09511426




      1,09511426
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I fixed the sample.



          We changed the default for requires-reply to true a long time ago but the sample was never updated.




          assertThat(foo, is(not(empty())));




          However, the List<Person> is null when no results are received.



          EDIT




          But I would expect empty list instead of a null if ResultSet was empty.




          That's not how it works.



          If the resultSet is empty, null is returned (hence the original error you were seeing).



          If the resultSet has 1 entry, just that entry is returned.



          Otherwise a list of entities is returned.



          Object payload = list;
          if (list.isEmpty()) {
          return null;
          }
          if (list.size() == 1) {
          payload = list.get(0);
          }
          return payload;


          It's been like that forever but I believe the single Object Vs. List is wrong (if maxRows > 1).



          maxRows is 1 by default so it made sense then; however, if maxRows is > 1 and only 1 row is returned I think it should still be a list of 1. The application shouldn't have to check the type of the result. It either expects a list or a single object (or null). INT-4559.






          share|improve this answer


























          • Thanks. I checked and it works now if you add a Person to a database. But I would expect empty list instead of a null if ResultSet was empty.

            – Derp
            Nov 24 '18 at 16:41











          • That's not how it works; see the edit to my answer.

            – Gary Russell
            Nov 24 '18 at 16:56











          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%2f53453209%2freplyrequiredexception-on-attempt-to-get-data-from-int-jdbcoutbound-gateway%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














          I fixed the sample.



          We changed the default for requires-reply to true a long time ago but the sample was never updated.




          assertThat(foo, is(not(empty())));




          However, the List<Person> is null when no results are received.



          EDIT




          But I would expect empty list instead of a null if ResultSet was empty.




          That's not how it works.



          If the resultSet is empty, null is returned (hence the original error you were seeing).



          If the resultSet has 1 entry, just that entry is returned.



          Otherwise a list of entities is returned.



          Object payload = list;
          if (list.isEmpty()) {
          return null;
          }
          if (list.size() == 1) {
          payload = list.get(0);
          }
          return payload;


          It's been like that forever but I believe the single Object Vs. List is wrong (if maxRows > 1).



          maxRows is 1 by default so it made sense then; however, if maxRows is > 1 and only 1 row is returned I think it should still be a list of 1. The application shouldn't have to check the type of the result. It either expects a list or a single object (or null). INT-4559.






          share|improve this answer


























          • Thanks. I checked and it works now if you add a Person to a database. But I would expect empty list instead of a null if ResultSet was empty.

            – Derp
            Nov 24 '18 at 16:41











          • That's not how it works; see the edit to my answer.

            – Gary Russell
            Nov 24 '18 at 16:56
















          1














          I fixed the sample.



          We changed the default for requires-reply to true a long time ago but the sample was never updated.




          assertThat(foo, is(not(empty())));




          However, the List<Person> is null when no results are received.



          EDIT




          But I would expect empty list instead of a null if ResultSet was empty.




          That's not how it works.



          If the resultSet is empty, null is returned (hence the original error you were seeing).



          If the resultSet has 1 entry, just that entry is returned.



          Otherwise a list of entities is returned.



          Object payload = list;
          if (list.isEmpty()) {
          return null;
          }
          if (list.size() == 1) {
          payload = list.get(0);
          }
          return payload;


          It's been like that forever but I believe the single Object Vs. List is wrong (if maxRows > 1).



          maxRows is 1 by default so it made sense then; however, if maxRows is > 1 and only 1 row is returned I think it should still be a list of 1. The application shouldn't have to check the type of the result. It either expects a list or a single object (or null). INT-4559.






          share|improve this answer


























          • Thanks. I checked and it works now if you add a Person to a database. But I would expect empty list instead of a null if ResultSet was empty.

            – Derp
            Nov 24 '18 at 16:41











          • That's not how it works; see the edit to my answer.

            – Gary Russell
            Nov 24 '18 at 16:56














          1












          1








          1







          I fixed the sample.



          We changed the default for requires-reply to true a long time ago but the sample was never updated.




          assertThat(foo, is(not(empty())));




          However, the List<Person> is null when no results are received.



          EDIT




          But I would expect empty list instead of a null if ResultSet was empty.




          That's not how it works.



          If the resultSet is empty, null is returned (hence the original error you were seeing).



          If the resultSet has 1 entry, just that entry is returned.



          Otherwise a list of entities is returned.



          Object payload = list;
          if (list.isEmpty()) {
          return null;
          }
          if (list.size() == 1) {
          payload = list.get(0);
          }
          return payload;


          It's been like that forever but I believe the single Object Vs. List is wrong (if maxRows > 1).



          maxRows is 1 by default so it made sense then; however, if maxRows is > 1 and only 1 row is returned I think it should still be a list of 1. The application shouldn't have to check the type of the result. It either expects a list or a single object (or null). INT-4559.






          share|improve this answer















          I fixed the sample.



          We changed the default for requires-reply to true a long time ago but the sample was never updated.




          assertThat(foo, is(not(empty())));




          However, the List<Person> is null when no results are received.



          EDIT




          But I would expect empty list instead of a null if ResultSet was empty.




          That's not how it works.



          If the resultSet is empty, null is returned (hence the original error you were seeing).



          If the resultSet has 1 entry, just that entry is returned.



          Otherwise a list of entities is returned.



          Object payload = list;
          if (list.isEmpty()) {
          return null;
          }
          if (list.size() == 1) {
          payload = list.get(0);
          }
          return payload;


          It's been like that forever but I believe the single Object Vs. List is wrong (if maxRows > 1).



          maxRows is 1 by default so it made sense then; however, if maxRows is > 1 and only 1 row is returned I think it should still be a list of 1. The application shouldn't have to check the type of the result. It either expects a list or a single object (or null). INT-4559.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 24 '18 at 17:10

























          answered Nov 24 '18 at 15:41









          Gary RussellGary Russell

          82.4k74773




          82.4k74773













          • Thanks. I checked and it works now if you add a Person to a database. But I would expect empty list instead of a null if ResultSet was empty.

            – Derp
            Nov 24 '18 at 16:41











          • That's not how it works; see the edit to my answer.

            – Gary Russell
            Nov 24 '18 at 16:56



















          • Thanks. I checked and it works now if you add a Person to a database. But I would expect empty list instead of a null if ResultSet was empty.

            – Derp
            Nov 24 '18 at 16:41











          • That's not how it works; see the edit to my answer.

            – Gary Russell
            Nov 24 '18 at 16:56

















          Thanks. I checked and it works now if you add a Person to a database. But I would expect empty list instead of a null if ResultSet was empty.

          – Derp
          Nov 24 '18 at 16:41





          Thanks. I checked and it works now if you add a Person to a database. But I would expect empty list instead of a null if ResultSet was empty.

          – Derp
          Nov 24 '18 at 16:41













          That's not how it works; see the edit to my answer.

          – Gary Russell
          Nov 24 '18 at 16:56





          That's not how it works; see the edit to my answer.

          – Gary Russell
          Nov 24 '18 at 16:56




















          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%2f53453209%2freplyrequiredexception-on-attempt-to-get-data-from-int-jdbcoutbound-gateway%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







          Popular posts from this blog

          Create new schema in PostgreSQL using DBeaver

          Deepest pit of an array with Javascript: test on Codility

          Fotorealismo