msw10100
Is it possible to parameterize a Conduit.Broker?
I have a scenario in which I’d like to be able to launch multiple instances of an app in a single BEAM, and I want each one to have its own broker. The broker (AMQP is the adapter) creates queue bindings based on an identifier of some sort. I’d like to have a single source file for the broker, but parameterize it when it starts up so each instance of it can have its own queue bindings.
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
blatyo
I’ll tentatively say no, but maybe depending on exactly what you need.
Can you give a code example of what the queue bindings would look like and what you’re looking to parameterize?
Also, could explain more about what you’re trying to achieve and why this is how you want to achieve it?
msw10100
Thanks for the reply! I’ll try to explain why I want to do this.
Work queues are queues that can be serviced by any service instance. They have well-known names, so they don’t need to be parameterized. Any worker instance can subscribe to them to receive messages to perform work bound to those queues.
Example Work Queue Name: “TraceLogger”, which binds to “Framework.TraceLogger.#”, so it receives, any message with a routing key that begins with “Framework.TraceLogger”. Any instance of the TraceLogger service can receive a message from this queue and service that message.
Instance queues are specific to a particular instance of a service. They receive responses to requests made by this service instance. Typically this is for handling responses to RPCs, but may also be used for services that perform some stateful function, like receiving and processing blocks of a file. Once a specific instance of a file transfer service has agreed to process a file transfer, all the blocks of that particular file need to come to this particular service instance.
Example Instance Queue Name: “FileTransfer_52f1b81a”. It binds to “Framework.FileTransfer__52f1b81a.#”. The name is used in the ReplyTo field of a response message and becomes the destination of RPC responses and the destination for individual blocks of a file.
There’s another type of queue, a control queue, which enables our service manager to interact with a specific service instance to perform service management functions. It’s like an instance queue, but it doesn’t bind to application-specific messages, but to service control messages.
So an instance of the service is parameterized with a BrokerConfig struct containing service name, instance name, queue options, etc…
Technically speaking, the queue names aren’t important except for the well-known queue name, but the control and instance bindings are unique per service. That’s what we’re trying to parameterize.
If we want to be able to run multiple instances of a service within a single BEAM instance, we need to be able to instantiate a broker for each one, parameterized with a BrokerConfig.
Each is an independent service, made up of a supervision tree of various Elixir processes. Each creates and binds to an instance queue and a control queue and binds to a pre-existing work queue. Our service management framework starts them and shuts them down dynamically within in an Erlang cluster in response to various scaling or application management criteria.
For example, a file transfer service might have several instances, some of which write files to a high speed store, others of which might write files to a low-speed archive store.
All of the services in our AMQP distributed service fabric implement this protocol of queues with dynamic bindings. Our existing services are written in C#, Python, and C++. We are adding Elixir to the mix.
Possible (somewhat hacky) solution: If we made BrokerConfig a per-BEAM Singleton agent we could use logic that limits us to launching a single service instance at a time and it would parameterize itself from that singleton BrokerConfig. Once it’s launched, we could reset the contents of the BrokerConfig and then launch another instance of the service, which would receive the new parameters.
We could also just abandon our naming conventions and use completely random queue names which don’t require parameterization, but since all the other languages can implement the conventions, and our ops people are used to seeing these names in logfiles and rabbitmq management tools, it would be … unfortunate if our Elixir services couldn’t do it.
I know this is long and presents a particular way of interacting with Rabbit that may not be completely standard. It’s a set of conventions that work well for us. Thanks for reading and considering it all.
Cheers!
blatyo
Thanks, I’ll come back to this later and read it more carefully. But, here’s what I think we could do that also supports some other cases I’ve had in mind.
Right now, the config for the broker is all specified in the application config. I’d like someone to be able to override that by passing config to start_link. That way, you’d be able to do something like this in a supervisor.
Additionally, I’d be willing to support passing this config merged with the application config to the name and options functions. This would allow you to specify arbitrary config options and use them for parameterization.
Does that sound like it would work for your case? Would you be willing to work on that?
msw10100
I think that’ll work. I’ll DM you to work out the details and I’ll be happy to work on it.
Thanks!