Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-8409

Kafka producer: when no message key specified, use partition key

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.14.2, 2.15.0
    • 2.14.2, 2.15.0
    • camel-kafka
    • None
    • Patch Available
    • Unknown
    • Regression

    Description

      CAMEL-8190 has introduced behavior that has the potential to break existing code (hence setting to Critical priority so this can be fixed prior to 2.14.2/2.15.0 releases). It broke my code (using 2.14.2-SNAPSHOT builds) in development and staging, and I didn't notice the problem until tonight.

      Prior to CAMEL-8190, the value of the KafkaConstants.PARTITION_KEY header was used for both the key and partitionKey of the kafka KeyedMessage. My downstream consumers depended on this for the correct key of the consumed message. CAMEL-8190, changed things so the key is set only via the KafkaConstants.KEY header, and since my code didn't set that header, the key started coming through as null to downstream consumers.

      I propose the following to fix this (will attach a patch shortly):

      1. If both KEY and PARTITION_KEY are specified, no change from CAMEL-8190
      2. If just one is specified, call the KeyedMessage 3-argument constructor with the value (uses the value for both key and partitionKey)
      3. If neither are specified, pass null for both...but IMHO, a warning should be logged, as it seems unlikely that the user knowingly omitted both values.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            mmindenhall Mark Mindenhall
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: