Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAX-WS Client Pool in a Java EE App Server

I have an application running in a Java EE App Server and it needs to call a web service of a partner company.

Using wsimport.exe from my JDK (1.6) I have generated the client classes. I instantiate the service and get the port in order to call the web service.

I noticed that the first call to the web service is slow, and I am led to believe this is because it is validating the WSDL. Subsequent calls are fast.

I could keep the WSDL locally, and apparently that will speed up the first call.

In order to optimise my app, I was thinking I could create a pool of the clients. This has the added advantage that I have some throttling in the app - lets say I have a pool of 5 clients, then at most I will be using memory for 5 clients. If the load increased suddenly on my server, I don't have to worry that an unlimited number of clients would cause an out of memory error. I am assuming, based on past experience, that the web service clients use a lot of memory...

  • Would you bother with a pool?
  • How would you get over the first call to the web service being slow?
  • What is the best way to create that pool, so that I have to do the least amount of programming (i.e. I'd like to use a library / API / whatever, so that I don't have to reinvent the wheel and code some hairy bugs).
like image 234
Ant Kutschera Avatar asked Jan 26 '26 14:01

Ant Kutschera


1 Answers

The Apache Commons Pool might be exactly what I am after.

It is configurable and seems to have thought of everything.

like image 92
Ant Kutschera Avatar answered Jan 29 '26 04:01

Ant Kutschera



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!