Comments (9)
FWIW, this is very useful for "sharding" queues as well, since RabbitMQ advises to have smaller queues. Broadway either lets you have many consumers connected to a single queue, or many consumers connected to a queue each (if you autodeclare the queue with queue: ""
).
from broadway_rabbitmq.
@whatyouhide i wonder if we should generalize your url/connection patch and allow it to returns a different queue too. This way you can have sharing or fault tolerance in the same API. We can complement the docs with more examples. WDYT?
from broadway_rabbitmq.
@josevalim or, we can generalize to make the whole options a function? I'm good with both things, but yeah this is easy enough to do if we make queue: fn index -> ... end
from broadway_rabbitmq.
We cannot make the whole options a function because some options may be handled by GenStage. One option is to have (merge_options: fun -> ... end), which we would call and merge into. WDYT?
from broadway_rabbitmq.
@josevalim hrm, merge_options
could solve the :connection
option as well as long as we do the merging as the first thing and then validate the options. Do you wanna go ahead with that route? I'm good both ways.
from broadway_rabbitmq.
Yup, let’s go this route then!
from broadway_rabbitmq.
Just wanted to thank you guys for turning this around so quickly!
It took me a little time to fully grok the solution, but for anyone reading this ticket here is an example;
queues = ~w(messages messages2)
queue_count = length(queues)
Broadway.start_link(__MODULE__,
name: __MODULE__,
producer: [
module: {
BroadwayRabbitMQ.Producer,
queue: "",
qos: [
prefetch_count: 50
],
merge_options: fn (index) ->
queue_name = Enum.at(queues, index)
Logger.info(" connecting to queue #{queue_name}")
[queue: queue_name]
end,
},
stages: queue_count
],
processors: [
default: [stages: 10]
],
batchers: [
elasticsearch: [stages: 1, batch_size: 400, batch_timeout: 500]
]
)
from broadway_rabbitmq.
Awesome. I would only use Enum.fetch!
instead of Enum.at
so it raises if you give it less queues than stages.
from broadway_rabbitmq.
Great tip, thanks
from broadway_rabbitmq.
Related Issues (20)
- Crash supervisor after killing Broadway process HOT 1
- econnrefused when deploying elixir project with broadway HOT 3
- ACK timeout kills connection without getting restarted HOT 4
- Ability to retrieve the AMQP Channel used by the Producer HOT 3
- Any plan for new version release? HOT 2
- Allow use of nimble_options 0.4.0 in broadway_rabbitmq HOT 2
- Retrieving additional information from AMQP.Queue.declare HOT 2
- AMQP 1.0 support HOT 7
- Allow usage of connection/channel pool HOT 6
- Update nimble options requirement HOT 1
- publish new version
- Broadway.prepare_messages/2 callback always receives exactly one message HOT 16
- broadway_rabbitmq won't compile on Elixir 1.17 and Erlang 27 HOT 3
- Proposal: require users to specify `:on_failure` HOT 1
- Questions about supported versions of the AMQP protocol HOT 2
- AMQP 2.0 HOT 3
- Multiple producers is an anti-pattern, right? HOT 12
- Working dead letter example HOT 1
- producers keep failing with declare: [no_wait: true] HOT 5
- :message_count is not honoured as metadata option. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from broadway_rabbitmq.