如何设置Elixir项目通过amqp使用RabbitMQ?

时间:2016-07-05 15:28:13

标签: linux rabbitmq elixir phoenix-framework elixir-framework

我想通过amqp从我的elixir phoenix应用程序中使用rabbitMQ。我按照official website上的教程,但仍然在MyApp.User期间,我收到错误:

mix.deps compile

Terminal screenshot

我在mix.exs文件中只添加了:amqp和{:amqp,“〜> 0.1.4”}:

include/amqp_gen_consumer_spec.hrl:30: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:31: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:32: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:34: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:35: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:36: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:37: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:38: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:39: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:42: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:30: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:31: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:32: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:34: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:35: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:36: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:37: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:38: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:39: syntax error before: '/'
include/amqp_gen_consumer_spec.hrl:42: syntax error before: '/'
Compiling src/amqp_selective_consumer.erl failed:
ERROR: compile failed while processing /home/bmarkons/soc2016-marko/telegram/deps/amqp_client: rebar_abort
** (Mix) Could not compile dependency :amqp_client, "/usr/bin/rebar compile skip_deps=true deps_dir="/home/bmarkons/soc2016-marko/telegram/_build/dev/lib"" command failed. You can recompile this dependency with "mix deps.compile amqp_client", update it with "mix deps.update amqp_client" or clean it with "mix deps.clean amqp_client"

我需要做些什么更改才能使我的elixir应用程序与RabbitMQ一起使用?

谢谢

2 个答案:

答案 0 :(得分:7)

这是:amqp项目中报告的问题(https://github.com/pma/amqp/issues/28)它无法使用Erlang 19进行编译。问题在于:amqp_client。存储库中的最后一个版本是固定的,但它不作为十六进制包存在。

更新2016-08-16:

如果您想在项目中使用AMQP和Erlang 19,只需添加当前:amqp_client依赖关系以覆盖AMQP附带的依赖关系:

def deps do
  [{:amqp_client, git: "https://github.com/jbrisbin/amqp_client.git", override: true},
   {:amqp, "~> 0.1.4"}]
end

对于这个具体的例子,你应该有类似的东西:

defp deps do
  [{:phoenix, "~> 1.2.0"},
   {:phoenix_pubsub, "~> 1.0"},
   {:phoenix_ecto, "~> 3.0"},
   {:postgrex, ">= 0.0.0"},
   {:phoenix_html, "~> 2.6"},
   {:phoenix_live_reload, "~> 1.0", only: :dev},
   {:gettext, "~> 0.11"},
   {:cowboy, "~> 1.0"},
   {:amqp_client, git: "https://github.com/jbrisbin/amqp_client.git", override: true},
   {:amqp, "~> 0.1.4"]
end
  

重要提示:如果混合文件的混合文件已经覆盖了依赖项,则应覆盖使用:amqp_client事件的项目中的AMQP依赖项。

我希望这会有所帮助。

答案 1 :(得分:7)

我必须按如下方式定义依赖关系(分支信息)以使其运行:

defp deps do
[
  {:amqp_client, git: "https://github.com/dsrosario/amqp_client.git", branch: "erlang_otp_19", override: true},
  {:amqp, "~> 0.1.4"}
]