While not technically a transport, use of the Coloc feature in CXF can dramatically speed up the interactions within the same JVM. The Coloc feature works by detecting when a client is calling a service that is registered on the same Bus instance and then bypasses most of the interceptor processing. The actual objects that the client sends are passed directly to the service without any serialization or other processing. Due to this, there are a bunch of restrictions:
- The objects/parameters MUST be the exact same classes. The easiest way is by having the service and client implement the same interface.
- They MUST be in the same classloader. This would be normal if on the same Bus.
- Because it is pass by reference instead of pass by value, the semantics are different than a normal webservice call. Modifications to the objects would be reflected back to the caller.
- Any extra processing at the soap or transport layers would be bypassed. Thus, things like security, WS-RM, JAX-WS handlers, etc... would not be part of the interation.
If the above restrictions are acceptable, the Coloc feature is an easy way to boost performance for clients/services within the same Bus.
The easiest way to enable the coloc capabilities is to use the Coloc feature, either via the feature class of org.apache.cxf.binding.coloc.feature.ColocFeature or using the coloc namespace handler in spring. You can enable the feature at the bus level like:
in which case all clients would check to see if the service is available locally and use them if possible. However, you can configure it on specific clients if you just want it done in the particular cases where the restrictions above are acceptable: