GithubHelp home page GithubHelp logo

Comments (5)

chulkilee avatar chulkilee commented on July 22, 2024

Since brod takes atom client id, you may pass the brod client id to broadway and use the same id from your module.

See (see https://github.com/dashbitco/broadway_kafka/blob/v0.1.2/lib/kafka_client.ex#L6 - you can pass the client_id option to broadway.

from broadway_kafka.

josevalim avatar josevalim commented on July 22, 2024

Thanks for the help @chulkilee !

from broadway_kafka.

escobera avatar escobera commented on July 22, 2024

Hello @chulkilee , thanks a lot for the help!

I tried what you suggested, but was getting {:error, :client_down} errors from brod. So I noticed that even after I set up the client_id config it was still using an auto-generated name like this:

[info] [supervisor: {:local, :brod_sup}, started: [pid: #PID<0.2162.0>, id: PropartesPje.Pje1i.BroadwayPje1i.Broadway.Producer_0.Client, mfargs: {:brod_client, :start_link, [[localhost: 9092], PropartesPje.Pje1i.BroadwayPje1i.Broadway.Producer_0.Client, []]}, restart_type: {:permanent, 10}, shutdown: 5000, child_type: :worker]]

My broadway config:

def start_link(_opts) do
    Broadway.start_link(__MODULE__,
      name: __MODULE__,
      producer: [
        module:
          {BroadwayKafka.Producer,
           [
             hosts: Application.get_env(:propartes_pje, :kafka_host, localhost: 9092),
             group_id: "grupo-ex-propartes",
             client_id: :my_test_client,
             topics: ["postgres-pje"],
             client_config: Application.get_env(:propartes_pje, :kafka_client_config, [])
           ]},
        concurrency: 1
      ],
      processors: [
        default: [
          concurrency: 1
        ]
      ]
    )
  end

I think the client_id is being changed here:

client_id = Module.concat([producer_name, Client])

from broadway_kafka.

msaraiva avatar msaraiva commented on July 22, 2024

Hi @escobera!

We could allow the user to set the client_id explicitly but I'm not sure that sharing it would be a good idea. The problem is that each producer process is responsible for the lifecycle of its own client so they should be considered "private" as you can't be sure when it would be available or whether it's being restarted or not. So I think it would be safer to keep them separate. I wouldn't worry much about performance either. It shouldn't add any significant overhead.

from broadway_kafka.

escobera avatar escobera commented on July 22, 2024

Gotcha, thanks for the help!

from broadway_kafka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.