|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Loaded Classes Keeps RisingI'm hosting a few web services (using metro 2.0 EA) inside an embedded jetty web server in my app (application "A"). I have another app that hosts another jetty server and has a few web services of its own (application "B"). There can be multiple processes of B running in the network. All Bs have the same web services, methods, and parameters. Basically we're using web services as RMI.
So A frequently calls one or more Bs and sends it some data to work on. When I load the Netbeans profiler and watch a call from A to B, I notice that the # of loaded classes increases. That's understandable during the first invocation, but every time I make a call the same thing happens. I know that jax-ws is creating some proxies on-the-fly (e.g. in getPort() of a Service class). But really, after the first invocation, there's no need to recreate any of this or reparse the WSDL. After some time and lots of calls, the # of loaded classes reaches 10,000 then 20,000 and 30,000 and then I saw it reach 100,000 etc. Here's (roughly) the code I'm using to instantiate my client on A: public MyAppPort createPortForB(String hostname, int port, int connectTimeout, Executor executor) { MyAppService svc = new MyAppService(); MyAppPort ret = svc.getMyAppPort(); BindingProvider bp = (BindingProvider)ret; Map<String, Object> ctx = bp.getRequestContext(); ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://" + hostname + ":" + port + "/services/MyApp"); ctx.put("com.sun.xml.ws.connect.timeout", connectTimeout); if (executor != null) svc.setExecutor(executor); return ret; } ... MyAppPort p = createPortForB("someotherhost.com", 1111, 3000, null); p.doMyWork(); Since there's multiple Bs and their hostname/port can go in and out of A at any time, I can't create a static instance of MyAppService and reuse it. The WSDLs are all the same for every B and so I'd like to not have to reparse (which it seems to be doing for some reason) the WSDLs every time I'm creating another instance of MyAppService (which can happen frequently). Is there a way to do this? The connect timeout and executor can vary for each method invocation. I notice that wsit-client.xml and metro-default.xml (or was it default-metro.xml?) seem to be loaded and parsed every time I create a new instance of MyAppService and then call getMyAppPort(). So the first issue is the # of loaded classes keeps rising. Should you provide some kind of cache so this doesn't happen? I'm not sure about other projects, but I wouldn't think you'd need to recreate the proxies every time a new instance is created (unless you're worried the interface is changing at runtime and the WSDLs are indicating new methods or parameters). Create it once per service and then cache and reuse it. But perhaps I'm missing scenarios where recreating it every time is a necessity. Could I have (or is there) an option to turn on caching if that happens to be the case? The second is if what I'm doing is acceptable. If I'm using it in a wildly abnormal fashion, please let me know. I know it might be better to create one instance of MyAppService and one MyAppPort for each host/port pair and reuse them, but that's an issue if every method call might have a different connect timeout. But if the API allows me to use it this way, I'd think it's reasonable to expect no side effects. Anyway, I appreciate any help anyone can offer. Thanks, - David Hoyt --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |