If you can, certainly use the same port object, but be careful of the areas in which it’s not thread safe. Using the thread safe request context can certainly help in most cases.
Beyond that, creating a pool of the ports is usually the next best option. Check one out of the pool, use it, check it back in. Dan > On Dec 22, 2014, at 2:23 PM, Irvine, Chuck R <[email protected]> wrote: > > I'm concerned that my CXF client code might have poor performance due to the > way I have it structured. > > Each time my client code calls the service, I do this: > > MyService service = new MyService(); > MyPort port = service.getMyPort(); > Client client = ClientProxy.getClient(port); > client.getRequestContext().put(Message.ENDPOINT_ADDRESS, theServiceAddress); > MyResponse myResponse = port.myOperation(myRequestObject). > > My feeling is that it would be better in theory to create all of my port > objects once and then reuse them on each service call. However, I've read > that the service and port objects aren't thread safe. I also see > documentation to the effect that they are "mostly" thread safe. > > I would be very, very appreciative for any advice that anyone might have. > > Regards, > > Chuck Irvine > DST - Brokerage > > > > Please consider the environment before printing this email and any > attachments. > > This e-mail and any attachments are intended only for the individual or > company to which it is addressed and may contain information which is > privileged, confidential and prohibited from disclosure or unauthorized use > under applicable law. If you are not the intended recipient of this e-mail, > you are hereby notified that any use, dissemination, or copying of this > e-mail or the information contained in this e-mail is strictly prohibited by > the sender. If you have received this transmission in error, please return > the material received to the sender and delete all copies from your system. -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
