Replies: 3 comments
-
|
Hi Is there a specific reason you want them to be queued? If so, I'm guessing you can take the incoming request and do the queing/waiting part within your Poco::Net::HTTPRequestHandler-derived class if that makes sense? So your server may receive multiple requests, each one spawning an instance of said Poco::Net::HTTPRequestHandler-derived class but then within each instance of your class, you will be waiting for the response from your single request-handling queue.. |
Beta Was this translation helpful? Give feedback.
-
|
Hi Mikallos, thanks for you quick reply. There are several channels for incoming requests, each one has its own thread to accept messages and queues them within the channel. Then there is one thread polling all channels and adding the received requests to a central queue. Then we have multiple handlers each with its own thread that take requests from the central queue, handle them and send the response back via the receiving channel. While I can see that your suggestion would work in theory, I guess that it would be very difficult to implement in that environment. I assume each message would have to own a mutex or something for which handleRequest waits until it returns. Also, if there are e.g. 100 messages in the central queue, there would be 100 threads wating for the responses. |
Beta Was this translation helpful? Give feedback.
-
|
I understand the downsides and the non-scalable nature of my suggestion but (at least with my limited knowledge) I THINK Poco destroys the request/response objects (and possibly the underlying socket) of the incoming request as soon as the HTTPRequestHandler::handleRequest method returns and if i'm correct, you probably cannot achieve what you are after with Poco.. but as i said, I may be wrong on this so let's see if anyone else enlightens both of us |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
we have a server that currently implements communication over websocket using poco. Requests are coming in, put into a request queue handled by multiple threads and then the responses are sent back to the client. via TWebSocket.
Now, we have to provide HTTP as a protocol as well.
In order to to that, we want to store the HTTPServerResponse(Impl) object that comes in in handleRequest until the request is handled and the response can be sent. However, we cannot store the pointer, as the response object seems to be deleted after handleRequest returns. Also we did not find a way to copy the HTTPServerResponse as it has neither copy constructor nor assignment operator (it*s abstract). So, are we overlooking something? Is asynchronous handling of requests thought to be done differently? Is it not possible at all?
-- Kit
Beta Was this translation helpful? Give feedback.
All reactions