Can I throttle requests made by a distributed app?

前端 未结 6 1225
无人及你
无人及你 2021-02-13 19:07

My application makes Web Service requests; there is a max rate of requests the provider will handle, so I need to throttle them down.

When the app ran on a single server

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-13 19:40

    Since you are already in a Java EE environment, you can create an MDB that handles all requests to the webservice based on a JMS queue. The instances of the application can simply post their requests to the queue and the MDB will recieve them and call the webservice.

    The queue can actually be configured with the appropriate number of sessions that will limit the concurrent access to you webservice, thus your throttling is handled via the queue config.

    The results can be returned via another queue (or even a queue per application instance).

提交回复
热议问题