spring-cloud-stream kafka how to produce message with round robin strategy?











up vote
2
down vote

favorite












We have upgrade spring boot to 2.0.3 Release (previously 1.5.10).
Due to that, we have changed the release of kafka & spring-cloud-stream (2.0.0-Release)

In our property YML file we dont always configure partitionKeyExpression and most of our partitionCount is greater than 1.

In previous release, these settings along with not passing any key would lead to produce messages in round robin strategy.


In new release, same settings leads to method isPartitioned to return true, which adds Interceptor with new PartitionHandler where extractKey method fail due to missing key (assert with message "Partition key cannot be null").



The question is, How can we maintain the previous behavior with the same settings or with less changes. How we can keep not using a key and ensure messages goes to partitions in round robin strategy?










share|improve this question




























    up vote
    2
    down vote

    favorite












    We have upgrade spring boot to 2.0.3 Release (previously 1.5.10).
    Due to that, we have changed the release of kafka & spring-cloud-stream (2.0.0-Release)

    In our property YML file we dont always configure partitionKeyExpression and most of our partitionCount is greater than 1.

    In previous release, these settings along with not passing any key would lead to produce messages in round robin strategy.


    In new release, same settings leads to method isPartitioned to return true, which adds Interceptor with new PartitionHandler where extractKey method fail due to missing key (assert with message "Partition key cannot be null").



    The question is, How can we maintain the previous behavior with the same settings or with less changes. How we can keep not using a key and ensure messages goes to partitions in round robin strategy?










    share|improve this question


























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      We have upgrade spring boot to 2.0.3 Release (previously 1.5.10).
      Due to that, we have changed the release of kafka & spring-cloud-stream (2.0.0-Release)

      In our property YML file we dont always configure partitionKeyExpression and most of our partitionCount is greater than 1.

      In previous release, these settings along with not passing any key would lead to produce messages in round robin strategy.


      In new release, same settings leads to method isPartitioned to return true, which adds Interceptor with new PartitionHandler where extractKey method fail due to missing key (assert with message "Partition key cannot be null").



      The question is, How can we maintain the previous behavior with the same settings or with less changes. How we can keep not using a key and ensure messages goes to partitions in round robin strategy?










      share|improve this question















      We have upgrade spring boot to 2.0.3 Release (previously 1.5.10).
      Due to that, we have changed the release of kafka & spring-cloud-stream (2.0.0-Release)

      In our property YML file we dont always configure partitionKeyExpression and most of our partitionCount is greater than 1.

      In previous release, these settings along with not passing any key would lead to produce messages in round robin strategy.


      In new release, same settings leads to method isPartitioned to return true, which adds Interceptor with new PartitionHandler where extractKey method fail due to missing key (assert with message "Partition key cannot be null").



      The question is, How can we maintain the previous behavior with the same settings or with less changes. How we can keep not using a key and ensure messages goes to partitions in round robin strategy?







      spring-boot apache-kafka spring-cloud-stream






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 18 at 12:22

























      asked Nov 18 at 11:44









      Shay Hatab

      113




      113
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          The count is now used in the decision.



          public boolean isPartitioned() {
          return this.partitionCount > 1 || this.partitionKeyExpression != null
          || this.partitionKeyExtractorName != null || this.partitionKeyExtractorClass != null;
          }


          I think this is wrong #1531.



          As a work around, don't set the stream producer.partitionCount if you want to use native kafka partitioning (and the topic already exists).






          share|improve this answer























            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',
            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%2f53360492%2fspring-cloud-stream-kafka-how-to-produce-message-with-round-robin-strategy%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








            up vote
            1
            down vote













            The count is now used in the decision.



            public boolean isPartitioned() {
            return this.partitionCount > 1 || this.partitionKeyExpression != null
            || this.partitionKeyExtractorName != null || this.partitionKeyExtractorClass != null;
            }


            I think this is wrong #1531.



            As a work around, don't set the stream producer.partitionCount if you want to use native kafka partitioning (and the topic already exists).






            share|improve this answer



























              up vote
              1
              down vote













              The count is now used in the decision.



              public boolean isPartitioned() {
              return this.partitionCount > 1 || this.partitionKeyExpression != null
              || this.partitionKeyExtractorName != null || this.partitionKeyExtractorClass != null;
              }


              I think this is wrong #1531.



              As a work around, don't set the stream producer.partitionCount if you want to use native kafka partitioning (and the topic already exists).






              share|improve this answer

























                up vote
                1
                down vote










                up vote
                1
                down vote









                The count is now used in the decision.



                public boolean isPartitioned() {
                return this.partitionCount > 1 || this.partitionKeyExpression != null
                || this.partitionKeyExtractorName != null || this.partitionKeyExtractorClass != null;
                }


                I think this is wrong #1531.



                As a work around, don't set the stream producer.partitionCount if you want to use native kafka partitioning (and the topic already exists).






                share|improve this answer














                The count is now used in the decision.



                public boolean isPartitioned() {
                return this.partitionCount > 1 || this.partitionKeyExpression != null
                || this.partitionKeyExtractorName != null || this.partitionKeyExtractorClass != null;
                }


                I think this is wrong #1531.



                As a work around, don't set the stream producer.partitionCount if you want to use native kafka partitioning (and the topic already exists).







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 18 at 17:46

























                answered Nov 18 at 15:53









                Gary Russell

                76.8k64166




                76.8k64166






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53360492%2fspring-cloud-stream-kafka-how-to-produce-message-with-round-robin-strategy%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

                    If I really need a card on my start hand, how many mulligans make sense? [duplicate]

                    Alcedinidae

                    Can an atomic nucleus contain both particles and antiparticles? [duplicate]