Mochiweb + AMQP并发消费者

发布于 2024-11-13 11:49:32 字数 498 浏览 7 评论 0原文

我是 Erlang 新手,一直在阅读 O'Reilly 的好书,我也遵循了 Internetz 上的一些教程。我可以像应用程序一样独立运行基本的 Mochiweb 聊天,还可以从运行的 AMQP 队列中获取一些基本的代码来使用。

我现在的问题是我想让所有这些一起运行。然而,我对 mochiweb 使用 (make app PROJECT=projname PREFIX=$HOME/PROJECT/) 生成的代码感到困惑,我可以在其中启动我的 AMQP 消费者。

我计划编写一些代码来将消息从 AMQP“路由”到我构建的 mochiweb 聊天应用程序。我还希望能够生成多个消费者和路由器,以便我可以在必要时进行扩展。

有人可以给我一些关于构建项目的建议吗?我从哪里开始我的消费者?在 projname.erl start() -> 中少量?

我读过的大部分内容都很好地介绍了语法和概念,但如何使用 Erlang 构建一个像样的可扩展架构是我正在努力解决的问题。我想你会说去读一下我没有的乔·阿姆斯特朗的书吧?

I'm new to Erlang and have been reading O'Reilly's great book, I've followed some tutorials on the Internetz as well. I can get my basic Mochiweb chat like application working stand alone and also get a basic bit of code to consume from an AMQP queue running.

My issue now comes in that I want to have all of this running together. However I'm confused in the code generated by mochiweb using (make app PROJECT=projname PREFIX=$HOME/PROJECT/) where I can kick off my AMQP consumer.

I plan to have a bit of code to "route" the messages from AMQP to the mochiweb chat like application I've built. I also want to be able to spawn multiple consumers and routers so that I can scale if necessary.

Can someone give me some advice on structuring my project? Where would I start my consumer? in the projname.erl start() -> bit?

Most of the stuff I've read is great at introducing syntax and concepts but the how to build a decent scalable architecture with Erlang is the bit I'm struggling with. I guess you'll say to go and read the Joe Armstrong book which I don't have?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久光 2024-11-20 11:49:32

将您的使用者添加到为您的项目生成的supervisor中,该supervisor应该是projname_sup.erl。

在此模块中,您将找到仅包含名为“Web”的子级的监督树的定义:

init([]) ->
Web = web_specs(dnd_server_web, 8080),
Processes = [Web],

只需为 AMQP 使用者创建监督规范并将其添加到进程列表中。

Add your consumer to the supervisor that has been generated for your project, which should be projname_sup.erl.

In this module, you'll find the definition of a supervision tree that only contains a child named "Web":

init([]) ->
Web = web_specs(dnd_server_web, 8080),
Processes = [Web],

Just create supervisor specs for your AMQP consumer and add it to the Processes list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文