【问题标题】:AMQP Connection string to Active MQ using Elixir使用 Elixir 到 Active MQ 的 AMQP 连接字符串
【发布时间】:2014-08-10 01:17:03
【问题描述】:

我使用 ActiveMQ 作为消息代理,并使用 Qpid proton c 库连接到 Erlang 以提供消息服务,并且在运行 ActiveMQ 的情况下似乎可以很好地使用以下命令。

qpidpn:subscribe("amqp://127.0.0.1/topic://destination").
qpidpn:publish(#{address => "amqp://127.0.0.1/topic://destination", body => "hello"}).
flush().
qpidpn:stop().
q().

我需要在 elixir 中编写一个模块来连接到 ActiveMQ 代理,就像上面在 erlang 中所做的一样。 Erlang 虽然使用 qpid 库连接到消息代理服务。请提出建议。

【问题讨论】:

    标签: amqp elixir qpid erlang-shell


    【解决方案1】:

    我还没有尝试过下面的代码,但是从 Elixir 调用 Erlang 库非常简单。

    试试这个:

    :qpidpn.subscribe("amqp://127.0.0.1/topic://destination")
    :qpidpn.publish(%{:address => "amqp://127.0.0.1/topic://destination", :body => "hello"})
    :flush()
    :qpidpn.stop()
    :q()
    

    正如我所说,我还没有尝试过(因为我没有安装 amqp 或 qpidn,所以我没有尝试过),但这可能符合您的要求。

    【讨论】:

    • flush() 和 q() 仅在 Erlang shell 中可用。 OP 想要编写的模块中不需要这些。
    猜你喜欢
    • 2018-05-22
    • 1970-01-01
    • 2017-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-24
    相关资源
    最近更新 更多