ejabberd - Comments for "Spawning a new process for each message" https://www.ejabberd.im/forum/25358/spawning-new-process-each-message en Let's take spawning and https://www.ejabberd.im/forum/25358/spawning-new-process-each-message#comment-66559 <p>Let's take spawning and terminating an erlang process for each xmpp message as the baseline. You could implement that and test how well it behaves.</p> <p>If you want an alternative that doesn't spawn a process per stanza, try this:<br /> 1. At module start, spawn an erlang process that waits in an endless loop. Register that process with name "yourmodule_yourvhost"<br /> 2. When the hooked function is called, it just sends an erlang message to that process: yourmodule_yourvhost ! {handlethis, Content}<br /> 3. Your process awaits reception of those messages, performs its duty (HTTP request), and continues the loop.</p> <p>That erlang process has a queue where the erlang messages you send await automatically. This means that only one HTTP request is done at each time, as you have only one process in that duty.</p> <p>There are examples in ejabberd, see the loop in mod_vcard.</p> Mon, 08 Feb 2016 15:54:52 +0000 badlop comment 66559 at https://www.ejabberd.im