Hello everybody,
my application works as a middle ware, receiving requests from clients, then transforming it in certain logic and sending the transformed requests to another service provider as normal HTTP requests or Webservice soap requests. The application was deployed on two jboss servers (in cluster) behind a load balancer.
let's say my application is A, the service provider is S.
Now i am informed that, every year S will be down several (3-5) times. Each down time will last about 4 hours. I can get a schedule about the down time.
During the downtime, A should not transform and send request to S any longer, but put received requests in a Queue. After S is back, the requests in the queue should be processed.
Note:
The requests A received must be processed in exact order as they came.One by one. Processing a request means A sending transformed requests to S, and getting the response success or error. usually this won't take much time.
Base on 1, when A is working on queued requests, new incoming requests should be enqueued, although S is already available. until the queue is empty, A can continue sending request directly to S.
Every minute A receives 2-3 requests.
Since we have two Jboss, I planed to maintain this Queue in Database, threads working on queue and managing the Downtime status. However, the synchronization between two jboss always makes me headache.
shortly, the problems I met were:
how to set the down time flag, so that the two jboss do the request enqeue, instead of sending. (solution i thought was, before processing each request, query database for this flag. The flag was set by thread. it might be the worse solution.)
after S is back, how to design the Dequeue operation of two jboss. (it seems that, same time, there is always one jboss is idle... )
how to inform two jboss," now the queue is empty, don't do enqueue any longer."
The logic is a bit complicated. I hope I explained my problem clearly...
Do you guys have any idea on that?
Some more description about the FIFO. If there was no downtime, A can process those requests from different clients in parallel. Because this 'transaction-liked' order is ensured by the clients. for example.
client x :
-send http://..../createUser...
-received 'success' from A
-send http://../updateUser...
-received 'success' from A
if createUser() failed, the updateUser is not gonna be sent.
client y:
-send http://.. createCompany...
Given that there was another client (y) sending request createCompany at same time as x.createUser. these two requests can be processed by A in parallel.
Once thinking about the downtime and the queue:
-send http://..../createUser...
(downtime)
-received 'enqueue'
(S is back)
-send http://../updateUser...
now the order "create->update" needs to be ensured by A, not clients.
Thanks in advance!
Kent