B4J Question [Server] AddHandler with SingleThreadHandler = True

Alessandro71

Well-Known Member
Licensed User
Longtime User
I need to run a server handler in single thread mode.
I see that when a request is sent to that handler, and the previous execution is not finished yet, the second request is paused until the first one is done.
How can I count how many requests are waiting to be executed?
A counter inside the handler is not useful, since the handled is not called until the previous one is running.
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
Why do you need it? Maybe you can add a regular handler that will redirect to the single thread handler.
just for monitoring purpose: if I see a high number of waiting threads, I need to spawn a new server instance to balance the load
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
Why do you need it to be a single thread handler?
making a long story short: converting existing code to server.
the existing code requires massive rewrite to remove global objects dependencies, so the quick solution is using it single-threaded, while rewrite is planned but not imminent
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
the existing code requires massive rewrite to remove global objects dependencies, so the quick solution is using it single-threaded, while rewrite is planned but not imminent
If these variables belong to the handler class then it will "simply work".

You can redirect the request with resp.SendRedirect. Or with a Filter class.
 
Upvote 0
Top