Sidi_Mohammed

Sidi_Mohammed

Rabbitmq does not receive messages

Hello everybody,
I have an issue concerning rabbitmq, I have just followed entirely this tutorial, Iam using rabbitmq management on ubuntu system, the problem is that messages never reach rabbitmq endpoint, when I check via browser interface in localhost:15672 I can see that everything is good, the connections and channels are all there, but concerning queues there is any message there.
I have checked my code I didn’t any mistake, I have used the default exchange as mentionned in the tutorial so I just can’t debug this issue and maybe I have missed something.
Thank you in advance

Most Liked

Sidi_Mohammed

Sidi_Mohammed

Of course @dimitarvp ,
I have a docker instance of rabbitmq management

sudo docker run --rm -it --hostname abdelghani -p 15672:15672 -p 5672:5672 rabbitmq:3-management

The elixir code looks like

mix.exs:
....
{:amqp, "~> 3.3"}
...
rabbitmq.ex:
def subscribe(queue) do
    {:ok, _connection, channel} = start_connection()
    :ok = declare_queue(channel, queue)
    :ok = consume(channel, queue)
    :ok
  end

  def publish(queue, payload) do
      :ok, connection, channel} = start_connection()
      :ok = declare_queue(channel, queue)
      :ok = produce(channel, queue, payload)
      :ok = close_connection(connection)
      :ok
  end

def start_connection() do
    {:ok, connection} = AMQP.Connection.open()
    {:ok, channel} = AMQP.Channel.open(connection)
    {:ok, connection, channel}
  end

  def declare_queue(channel, queue) do
    AMQP.Queue.declare(channel, queue)
    :ok
  end

  def consume(channel, queue) do
    AMQP.Basic.consume(channel, queue, nil, no_ack: true)
    :ok
  end

  def produce(channel, queue, payload) do
    AMQP.Basic.publish(channel, "", queue, payload)
    :ok
  end

  def close_connection(connection) do
    AMQP.Connection.close(connection)
    :ok
  end
end
consumer.ex
:ok = Rabbitmq.subscribe("index")
producer.ex
payload = ....
:ok = Rabbitmq.publish("index", payload)

I can check in web interface that each call for subscribe or publish results in process connection to Rabbitmq server and a new channel created, but the queues are empty and there is no coming data.

Where Next?

Popular in Questions Top

Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
stefanchrobot
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
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement