开发者

Mochiweb + AMQP consumer concurrently

开发者 https://www.devze.com 2023-03-11 15:47 出处:网络
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

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号