如何使用 RabbitMQ 和 Elixir 将 JSON 发送给消费者?

How can I send JSON to consumer using RabbitMQ and Elixir?

我正在尝试使用 RabbitMQ 将 JSON 发送给消费者?这可能吗?如何?我正在使用 Elixir 作为我的编程语言。

关注此 link 以: https://github.com/pma/amqp

有关发送 JSON 的更多信息的未决问题。

iex(1)> {:ok, conn} = AMQP.Connection.open
{:ok, %AMQP.Connection{pid: #PID<0.364.0>}}
iex(2)> {:ok, chan} = AMQP.Channel.open(conn)
{:ok,
 %AMQP.Channel{conn: %AMQP.Connection{pid: #PID<0.364.0>}, pid: #PID<0.376.0>}}
iex(3)> AMQP.Queue.declare chan, "test_queue"
{:ok, %{consumer_count: 0, message_count: 0, queue: "test_queue"}}
iex(4)> AMQP.Exchange.declare chan, "test_exchange"
:ok
iex(5)> AMQP.Queue.bind chan, "test_queue", "test_exchange"
:ok
iex(6)> AMQP.Basic.publish(chan, "test_exchange", "", Poison.encode(%{ name: "S" }), [content_type: "application/json"])
:ok