开发者

looking for good solution to invoke http client method in a bean (i.e. MDB, session)

I would like to invoke http client method (HTTP PUT, GET, et al) within a bean, but I want these beans, either MDB or stateless session bean, run as quick as possible (with extreme short life time).

 ---[ejb request]--> bean -----[http request]---->  host

Problem is, the HTTP connection is too slow (especially when connecting to slow hosts). Take MDB for example, due to HTTP latency, the MDB run too long, and the queue is quickly stalled with continuing coming messages. (Message producer is faster than http method invocation.)

How can I solve such problem?

  1. using NIO http client? would it help?
  2. open extra Th开发者_开发百科reads to execute http invocation? (but running explicit thread in bean is not recommended in Java EE)
  3. some async http client? is there any such libs? don't they use Thread?


Using a NIO-based client is not going to resolve change the fact that your connections and target hosts are too slow. Full stop. It sounds like you have a fundamental problem that can be solved by other methods:

  • Time out the connections. Only viable if your clients can fail.
  • Increase concurrency, the number of client connections running at once. This seems like the most logical step to me.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜