I am trying to figure out the proper way to use 0MQ from a servlet. If I am not mistaken, when a servlet receives an HTTP request, what is really happening is that this servlet runs on a separate thread, allowing the Web container to use many such threads in parallel to serve content to many simultaneous HTTP requests. I would like to have this servlet thread send out a message using 0MQ. In order to do this, I think I would have to initialize / terminate 0MQ from each servlet thread, every time I receive an HTTP request, incurring a cost that might be too high; is this correct? Or is there a place where I could initialize 0MQ just once, for all threads that will use it? (My apologies, I know this last question is not strictly related to 0MQ.)
Now, say there IS a place to initialize 0MQ just once. If I do that, I would have to make a guess as to the number of concurrent threads (HTTP requests) that I would be using it, right? Say, 100 simultaneous HTTP requests. What happens if I initialize 0MQ with that assumption but then, during runtime, end up going above that? Finally, say I have five concurrent threads serving five simultaneous HTTP requests. Each of these threads will want to send out a message over 0MQ, and then wait for a response. It seems to me the only safe way of doing this is using REQ/REP sockets, but if all these threads send a message to the same process (the one that will generate the answers), will I be assured that the answers will come back to the appropriate thread? Have replies any "affinity" to the underlying socket that actually sent the corresponding request? Is this a pattern (let's call it "multi-threaded web server") that is well understood? Has anybody implemented something similar? If yes, can you share some thoughts about it? Or maybe this is a mismatch for 0MQ's architecture? As always, thanks in advance. -- Gonzalo Diethelm ----------------------------------------- Declaración de confidencialidad: Este Mensaje esta destinado para el uso de la o las personas o entidades a quien ha sido dirigido y puede contener información reservada y confidencial que no puede ser divulgada, difundida, ni aprovechada en forma alguna. El uso no autorizado de la información contenida en este correo podrá ser sancionado de conformidad con la ley chilena. Si usted ha recibido este correo electrónico por error, le pedimos eliminarlo junto con los archivos adjuntos y avisar inmediatamente al remitente, respondiendo este mensaje. "Before printing this e-mail think if is really necesary". Disclosure: This Message is to be used by the individual, individuals or entities that it is addressed to and may include private and confidential information that may not be disclosed, made public nor used in any way at all. Unauthorized use of the information in this electronic mail message may be subject to the penalties set forth by Chilean law. If you have received this electronic mail message in error, we ask you to destroy the message and its attached file(s) and to immediately notify the sender by answering this message. _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
