Kafka - Redirect messages from “Topic A” to “Topic B” based on header valueZookeeper having KeeperException but Kafka able to create topics and produce/consumeKafka - Docker - Error when sending message from Host to Container (Batch Expired)Problems to consume from kafka created by docker-composeGetting error while consuming kafka messagespring-cloud-starter-stream-kafka does not creates topic provided to spring.boot.cloud.stream.bindings.output.destinationKafka consumer not able to consume messages using bootstrap server nameUnable to access topic from scaled Kafka cluster in DockerHow to expose kafka endpoint from azure and consume it from onpremise application?Spark Streaming not reading from Kafka topics

Does norwegian.no airline overbook flights?

Which note goes on which side of the stem?

Start from ones

Is “I am getting married with my sister” ambiguous?

Average period of peer review process

What is the hex versus octal timeline?

Is using a hyperlink to close a modal a poor design decision?

Why does trim() NOT remove char 160?

Science fiction short story where aliens contact a drunk about Earth's impending destruction

Did it used to be possible to target a zone?

Why different interest rates for checking and savings?

See details of old sessions

What to say to a student who has failed?

Prove your innocence

What are some interesting features that are common cross-linguistically but don't exist in English?

What magic extends life or grants immortality?

Does travel insurance for short flight delays exist?

Why don't electrons take the shorter path in coils?

Why were movies shot on film shot at 24 frames per second?

Fried gnocchi with spinach, bacon, cream sauce in a single pan

In the MCU, why does Mjölnir retain its enchantments after Ragnarok?

Why can't an Airbus A330 dump fuel in an emergency?

Numbers Decrease while Letters Increase

C++20 constexpr std::copy optimizations for run-time



Kafka - Redirect messages from “Topic A” to “Topic B” based on header value


Zookeeper having KeeperException but Kafka able to create topics and produce/consumeKafka - Docker - Error when sending message from Host to Container (Batch Expired)Problems to consume from kafka created by docker-composeGetting error while consuming kafka messagespring-cloud-starter-stream-kafka does not creates topic provided to spring.boot.cloud.stream.bindings.output.destinationKafka consumer not able to consume messages using bootstrap server nameUnable to access topic from scaled Kafka cluster in DockerHow to expose kafka endpoint from azure and consume it from onpremise application?Spark Streaming not reading from Kafka topics






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I would like to redirect kafka messages from a topic called "all-topic" to a topic named "headervalue-topic" where headervalue is the value of a custom header each message has.



At the moment i'm using a custom console application that consumes messages and redirects the messages to the correct topic, but it only process 16 messages per second.



Both kafka and zookeeper are running in a docker container, configured as such :



zookeeper:
image: "wurstmeister/zookeeper:latest"
restart: always
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_SERVER_ID: 1

kafka:
hostname: kafka
image: "wurstmeister/kafka:latest"
restart: always
depends_on:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ADVERTISED_PORT: 9092


What is the best and fastest way to achieve my goal?



I do know about the existence of Kafka Streams, but i'm not familiar with Java so in case you'd like to suggest Kafka Streams a little example would be appreciated :)



Many Thanks!










share|improve this question


























  • And yes, you need to write a Kafka Stream application to achieve this. There are lots of example of Kafka stream app available at kafka.apache.org/documentation/streams

    – JR ibkr
    Mar 27 at 19:48

















0















I would like to redirect kafka messages from a topic called "all-topic" to a topic named "headervalue-topic" where headervalue is the value of a custom header each message has.



At the moment i'm using a custom console application that consumes messages and redirects the messages to the correct topic, but it only process 16 messages per second.



Both kafka and zookeeper are running in a docker container, configured as such :



zookeeper:
image: "wurstmeister/zookeeper:latest"
restart: always
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_SERVER_ID: 1

kafka:
hostname: kafka
image: "wurstmeister/kafka:latest"
restart: always
depends_on:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ADVERTISED_PORT: 9092


What is the best and fastest way to achieve my goal?



I do know about the existence of Kafka Streams, but i'm not familiar with Java so in case you'd like to suggest Kafka Streams a little example would be appreciated :)



Many Thanks!










share|improve this question


























  • And yes, you need to write a Kafka Stream application to achieve this. There are lots of example of Kafka stream app available at kafka.apache.org/documentation/streams

    – JR ibkr
    Mar 27 at 19:48













0












0








0








I would like to redirect kafka messages from a topic called "all-topic" to a topic named "headervalue-topic" where headervalue is the value of a custom header each message has.



At the moment i'm using a custom console application that consumes messages and redirects the messages to the correct topic, but it only process 16 messages per second.



Both kafka and zookeeper are running in a docker container, configured as such :



zookeeper:
image: "wurstmeister/zookeeper:latest"
restart: always
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_SERVER_ID: 1

kafka:
hostname: kafka
image: "wurstmeister/kafka:latest"
restart: always
depends_on:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ADVERTISED_PORT: 9092


What is the best and fastest way to achieve my goal?



I do know about the existence of Kafka Streams, but i'm not familiar with Java so in case you'd like to suggest Kafka Streams a little example would be appreciated :)



Many Thanks!










share|improve this question
















I would like to redirect kafka messages from a topic called "all-topic" to a topic named "headervalue-topic" where headervalue is the value of a custom header each message has.



At the moment i'm using a custom console application that consumes messages and redirects the messages to the correct topic, but it only process 16 messages per second.



Both kafka and zookeeper are running in a docker container, configured as such :



zookeeper:
image: "wurstmeister/zookeeper:latest"
restart: always
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_SERVER_ID: 1

kafka:
hostname: kafka
image: "wurstmeister/kafka:latest"
restart: always
depends_on:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ADVERTISED_PORT: 9092


What is the best and fastest way to achieve my goal?



I do know about the existence of Kafka Streams, but i'm not familiar with Java so in case you'd like to suggest Kafka Streams a little example would be appreciated :)



Many Thanks!







apache-kafka apache-kafka-streams






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 20:15









Robin Moffatt

10.5k18 silver badges31 bronze badges




10.5k18 silver badges31 bronze badges










asked Mar 27 at 16:43









LorenzoScebbaLorenzoScebba

391 silver badge5 bronze badges




391 silver badge5 bronze badges















  • And yes, you need to write a Kafka Stream application to achieve this. There are lots of example of Kafka stream app available at kafka.apache.org/documentation/streams

    – JR ibkr
    Mar 27 at 19:48

















  • And yes, you need to write a Kafka Stream application to achieve this. There are lots of example of Kafka stream app available at kafka.apache.org/documentation/streams

    – JR ibkr
    Mar 27 at 19:48
















And yes, you need to write a Kafka Stream application to achieve this. There are lots of example of Kafka stream app available at kafka.apache.org/documentation/streams

– JR ibkr
Mar 27 at 19:48





And yes, you need to write a Kafka Stream application to achieve this. There are lots of example of Kafka stream app available at kafka.apache.org/documentation/streams

– JR ibkr
Mar 27 at 19:48












1 Answer
1






active

oldest

votes


















0















Here is the solution i came up with, using kafka-streams nodejs library :



const KafkaStreams = require("kafka-streams");
const nativeConfig: config = require("./config.js");

const kafkaStreams = new KafkaStreams(config);
const myConsumerStream = kafkaStreams.getKStream("all-topic");

myConsumerStream
.mapJSONConvenience()
.filter((element) =>
return element.value.type == "Article";
)
.tap((element) => console.log("Got Article"))
.mapWrapKafkaValue()
.to("Article-topic", 1, "buffer");

myConsumerStream.start();





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',
    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%2f55382449%2fkafka-redirect-messages-from-topic-a-to-topic-b-based-on-header-value%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









    0















    Here is the solution i came up with, using kafka-streams nodejs library :



    const KafkaStreams = require("kafka-streams");
    const nativeConfig: config = require("./config.js");

    const kafkaStreams = new KafkaStreams(config);
    const myConsumerStream = kafkaStreams.getKStream("all-topic");

    myConsumerStream
    .mapJSONConvenience()
    .filter((element) =>
    return element.value.type == "Article";
    )
    .tap((element) => console.log("Got Article"))
    .mapWrapKafkaValue()
    .to("Article-topic", 1, "buffer");

    myConsumerStream.start();





    share|improve this answer





























      0















      Here is the solution i came up with, using kafka-streams nodejs library :



      const KafkaStreams = require("kafka-streams");
      const nativeConfig: config = require("./config.js");

      const kafkaStreams = new KafkaStreams(config);
      const myConsumerStream = kafkaStreams.getKStream("all-topic");

      myConsumerStream
      .mapJSONConvenience()
      .filter((element) =>
      return element.value.type == "Article";
      )
      .tap((element) => console.log("Got Article"))
      .mapWrapKafkaValue()
      .to("Article-topic", 1, "buffer");

      myConsumerStream.start();





      share|improve this answer



























        0














        0










        0









        Here is the solution i came up with, using kafka-streams nodejs library :



        const KafkaStreams = require("kafka-streams");
        const nativeConfig: config = require("./config.js");

        const kafkaStreams = new KafkaStreams(config);
        const myConsumerStream = kafkaStreams.getKStream("all-topic");

        myConsumerStream
        .mapJSONConvenience()
        .filter((element) =>
        return element.value.type == "Article";
        )
        .tap((element) => console.log("Got Article"))
        .mapWrapKafkaValue()
        .to("Article-topic", 1, "buffer");

        myConsumerStream.start();





        share|improve this answer













        Here is the solution i came up with, using kafka-streams nodejs library :



        const KafkaStreams = require("kafka-streams");
        const nativeConfig: config = require("./config.js");

        const kafkaStreams = new KafkaStreams(config);
        const myConsumerStream = kafkaStreams.getKStream("all-topic");

        myConsumerStream
        .mapJSONConvenience()
        .filter((element) =>
        return element.value.type == "Article";
        )
        .tap((element) => console.log("Got Article"))
        .mapWrapKafkaValue()
        .to("Article-topic", 1, "buffer");

        myConsumerStream.start();






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 29 at 14:31









        LorenzoScebbaLorenzoScebba

        391 silver badge5 bronze badges




        391 silver badge5 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            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%2f55382449%2fkafka-redirect-messages-from-topic-a-to-topic-b-based-on-header-value%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

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현