alexiss
GenServer, subscribed to multiple RabbitMQ queues [SOLVED]
Hi, I want to handle messages from multiple RabbitMQ queues in one GenServer. So with following code:
def init(_) do
...
AMQP.Queue.declare(channel, "q1")
AMQP.Queue.declare(channel, "q2")
AMQP.Basic.consume(channel, "q", nilm no_ack: true)
AMQP.Basic.consume(channel, "q", nilm no_ack: true)
...
end
def handle_info({:basic_deliver, payload, _meta}, state) do
IO.inspect(payload)
{:noreplay, state}
end
Is where any way to detect inside handle_info from wich queue message received?
Thanks!
Marked As Solved
egze
Try to inspect the meta parameter.
Also Liked
alexiss
Thank you!
IO.inspect(meta) in my case gives me:
%{
app_id: :undefined,
cluster_id: :undefined,
consumer_tag: "amq.ctag-BFsF3LZZU_oFnf15FdzgFw",
content_encoding: :undefined,
content_type: :undefined,
correlation_id: :undefined,
delivery_tag: 1,
exchange: "",
expiration: :undefined,
headers: :undefined,
message_id: :undefined,
persistent: false,
priority: :undefined,
redelivered: false,
reply_to: :undefined,
routing_key: "hello",
timestamp: :undefined,
type: :undefined,
user_id: :undefined
}
I think, I can use consumer_tag for this purposes.
Solved
1
Popular in Questions
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
Hey guys.
I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
I have a User schema with a :from_id field set to type :string:
defmodule TweetBot.Repo.Migrations.CreateUsers do
use Ecto.Migration
...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Other popular topics
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
I have a super simple question about elixir - how would I take a file like this
foo bar baz
and output a new file that enumerates th...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New







