{"id":442,"date":"2011-06-13T00:41:00","date_gmt":"2011-06-13T00:41:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/apache-cxf-load-balancing-and-failover.html"},"modified":"2012-10-21T19:49:52","modified_gmt":"2012-10-21T19:49:52","slug":"apache-cxf-load-balancing-failover","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html","title":{"rendered":"Apache CXF Load Balancing And Failover"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">\n<div>A while ago we&#8217;ve faced the requirement of load-balancing web services clients based on <a href=\"http:\/\/cxf.apache.org\/\">Apache CXF<\/a>.  Also the clients should automatically fail-over when some of the  servers are down. To make it even worse, the list of servers target  addresses was to be obtained from external service and updated at  runtime.<\/p>\n<p>Eventually we ended up with home-grown load-balancing  micro-library (ESB\/UDDI\/WS-Addressing seemed like an interesting  alternatives, but they were an overkill in our situation). If we only  knew Apache CXF already supports all these features (almost) out of the  box?<\/p>\n<\/div>\n<div>\n<\/div>\n<div>Don&#8217;t blame us though, only <a href=\"http:\/\/cxf.apache.org\/docs\/featureslist.html\">reference<\/a> to this feature points to a very poor <a href=\"http:\/\/cxf.apache.org\/clustering\">documentation<\/a> page (if you call 404 \u201cpoor\u201d). If it&#8217;s not in official documentation, I would expect to find it in <a href=\"http:\/\/www.amazon.com\/gp\/product\/1847195407\/ref=as_li_ss_tl?ie=UTF8&amp;tag=javaandneighb-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399349&amp;creativeASIN=1847195407\">Apache CXF Web Service Development<\/a>  book \u2013 unfortunately, bad luck there as well. But hey, isn&#8217;t exploring  such features yourself even greater fun? This is the client  configuration we are starting with:<\/p>\n<\/div>\n<pre class=\"brush:xml\">&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n       xmlns:jaxws=\"http:\/\/cxf.apache.org\/jaxws\"\r\n       xmlns:clustering=\"http:\/\/cxf.apache.org\/clustering\"\r\n       xmlns:util=\"http:\/\/www.springframework.org\/schema\/util\"&gt;\r\n\r\n    &lt;jaxws:client id=\"testServiceClient\"\r\n                  serviceClass=\"com.blogspot.nurkiewicz.cxfcluster.SimpleService\"\r\n                  address=\"http:\/\/serverA\/simple\"&gt;\r\n    &lt;\/jaxws:client&gt;\r\n\r\n&lt;\/beans&gt;\r\n<\/pre>\n<div>Endpoint interface is not important here, enough to know the <span>testServiceClient<\/span>  is being injected to some other services and load balancing and  failover features shouldn&#8217;t affect existing code. Note the service  address is fixed and hard-coded (of course it can be externalized and  read upon startup).<\/p>\n<div>\n<\/div>\n<div>Surprisingly enabling failover alone is pretty simple, straightforward and self-explanatory (despite being XML):<\/div>\n<pre class=\"brush:xml\">&lt;jaxws:client id=\"testServiceClient\"\r\n              serviceClass=\"com.blogspot.nurkiewicz.cxfcluster.SimpleService\"\r\n              address=\"http:\/\/serverA\/simple\"&gt;\r\n\r\n    &lt;jaxws:features&gt;\r\n        &lt;clustering:failover&gt;\r\n            &lt;clustering:strategy&gt;\r\n                &lt;bean class=\"org.apache.cxf.clustering.RandomStrategy\"&gt;\r\n                    &lt;property name=\"alternateAddresses\"&gt;\r\n                        &lt;util:list&gt;\r\n                            &lt;value&gt;http:\/\/serverB\/simple&lt;\/value&gt;\r\n                            &lt;value&gt;http:\/\/serverC\/simple&lt;\/value&gt;\r\n                            &lt;value&gt;http:\/\/serverD\/simple&lt;\/value&gt;\r\n                        &lt;\/util:list&gt;\r\n                    &lt;\/property&gt;\r\n                &lt;\/bean&gt;\r\n            &lt;\/clustering:strategy&gt;\r\n        &lt;\/clustering:failover&gt;\r\n    &lt;\/jaxws:features&gt;\r\n\r\n&lt;\/jaxws:client&gt;\r\n<\/pre>\n<div>The <span>serverA<\/span> address is used as a primary endpoint, but when it fails all failover endpoints (<span>serverB<\/span>, <span>serverC<\/span> and <span>serverD<\/span>) are examined in random order. To play a bit with this configuration I advice you to turn on Apache CXF <a href=\"http:\/\/cxf.apache.org\/docs\/configuration.html\">logging<\/a> of requests and responses:<\/div>\n<pre class=\"brush:xml\">&lt;cxf:bus&gt;\r\n    &lt;cxf:features&gt;\r\n        &lt;cxf:logging\/&gt;\r\n    &lt;\/cxf:features&gt;\r\n&lt;\/cxf:bus&gt; \r\n<\/pre>\n<div>Once again (!) official documentation does not mention about very convenient configuration parameter <span>prettyLogging<\/span>  that can be applied to logging feature in order to make XML requests  and responses being properly formatted (new lines and indentation)  before being logged. I wouldn&#8217;t recommend it for production setup, but  during development and testing having SOAP messages formatted is  invaluable:<\/div>\n<pre class=\"brush:xml\">&lt;bean id=\"abstractLoggingInterceptor\" abstract=\"true\"&gt;\r\n    &lt;property name=\"prettyLogging\" value=\"true\"\/&gt;\r\n&lt;\/bean&gt;\r\n&lt;bean id=\"loggingInInterceptor\" class=\"org.apache.cxf.interceptor.LoggingInInterceptor\" parent=\"abstractLoggingInterceptor\"\/&gt;\r\n&lt;bean id=\"loggingOutInterceptor\" class=\"org.apache.cxf.interceptor.LoggingOutInterceptor\" parent=\"abstractLoggingInterceptor\"\/&gt;\r\n\r\n&lt;cxf:bus&gt;\r\n    &lt;cxf:inInterceptors&gt;\r\n        &lt;ref bean=\"loggingInInterceptor\"\/&gt;\r\n    &lt;\/cxf:inInterceptors&gt;\r\n    &lt;cxf:outInterceptors&gt;\r\n        &lt;ref bean=\"loggingOutInterceptor\"\/&gt;\r\n    &lt;\/cxf:outInterceptors&gt;\r\n    &lt;cxf:outFaultInterceptors&gt;\r\n        &lt;ref bean=\"loggingOutInterceptor\"\/&gt;\r\n    &lt;\/cxf:outFaultInterceptors&gt;\r\n    &lt;cxf:inFaultInterceptors&gt;\r\n        &lt;ref bean=\"loggingInInterceptor\"\/&gt;\r\n    &lt;\/cxf:inFaultInterceptors&gt;\r\n&lt;\/cxf:bus&gt;\r\n<\/pre>\n<div>So our service nicely fails over to backup endpoints if primary one is  not available. But we have four equivalent servers and we want our  client to treat them equally hitting each one with similar probability  (round robin? random?). Here is when load-balancing is entering the  stage:<\/div>\n<pre class=\"brush:xml\">&lt;jaxws:client id=\"testServiceClient\" serviceClass=\"com.blogspot.nurkiewicz.cxfcluster.SimpleService\"&gt;\r\n\r\n    &lt;jaxws:features&gt;\r\n        &lt;clustering:loadDistributor&gt;\r\n            &lt;clustering:strategy&gt;\r\n                &lt;bean class=\"org.apache.cxf.clustering.SequentialStrategy\"&gt;\r\n                    &lt;property name=\"alternateAddresses\"&gt;\r\n                        &lt;util:list&gt;\r\n                            &lt;value&gt;http:\/\/serverA\/simple&lt;\/value&gt;\r\n                            &lt;value&gt;http:\/\/serverB\/simple&lt;\/value&gt;\r\n                            &lt;value&gt;http:\/\/serverC\/simple&lt;\/value&gt;\r\n                            &lt;value&gt;http:\/\/serverD\/simple&lt;\/value&gt;\r\n                        &lt;\/util:list&gt;\r\n                    &lt;\/property&gt;\r\n                &lt;\/bean&gt;\r\n            &lt;\/clustering:strategy&gt;\r\n        &lt;\/clustering:loadDistributor&gt;\r\n    &lt;\/jaxws:features&gt;\r\n\r\n&lt;\/jaxws:client&gt;\r\n<\/pre>\n<div>\n<div>Please note that the client itself does no longer define the address attribute. This suggests that <span>alternateAddresses<\/span> list is used exclusively throughout all the invocations and no primary address exists \u2013 which is actually the case. <span>SequentialStrategy<\/span> will use one endpoint after another providing nice round robin implementation (<span>RandomStrategy<\/span>  is available as well). Also in this configuration you will get failover  for free \u2013 if any endpoint fails, all endpoints starting from the first  one will be examined (obviously except the one that has just failed).<\/div>\n<div>\n<\/div>\n<div>Great! Now are CXF clients are much more rigid and  fault-tolerant. But in our journey for higher availability and  minimizing downtimes having alternate nodes being loaded only at  application startup (in other words \u2013 adding a new server requires all  clients restart) is too limiting. Fortunately we can make our  load-balancing a bit more dynamic in two simple steps.<\/div>\n<pre class=\"brush:xml\">&lt;jaxws:client id=\"testServiceClient\" serviceClass=\"com.blogspot.nurkiewicz.cxfcluster.SimpleService\"&gt;\r\n\r\n    &lt;jaxws:features&gt;\r\n        &lt;clustering:loadDistributor&gt;\r\n            &lt;clustering:strategy&gt;\r\n                &lt;bean class=\"org.apache.cxf.clustering.SequentialStrategy\"&gt;\r\n                    &lt;property name=\"alternateAddresses\" ref=\"alternateAddresses\"\/&gt;\r\n                &lt;\/bean&gt;\r\n            &lt;\/clustering:strategy&gt;\r\n        &lt;\/clustering:loadDistributor&gt;\r\n    &lt;\/jaxws:features&gt;\r\n\r\n&lt;\/jaxws:client&gt;\r\n\r\n&lt;util:list id=\"alternateAddresses\" list-class=\"java.util.concurrent.CopyOnWriteArrayList\"&gt;\r\n    &lt;value&gt;http:\/\/serverA\/simple&lt;\/value&gt;\r\n    &lt;value&gt;http:\/\/serverB\/simple&lt;\/value&gt;\r\n    &lt;value&gt;http:\/\/serverC\/simple&lt;\/value&gt;\r\n    &lt;value&gt;http:\/\/serverD\/simple&lt;\/value&gt;\r\n&lt;\/util:list&gt;\r\n<\/pre>\n<div>\n<div>Nothing fancy, extracting nested anonymous bean. But having access to this list (please note I used <span>java.util.concurrent.CopyOnWriteArrayList<\/span>)  enables us to inject it to any other service, possibly changing its  state. How do I know this will work? Well, I spent few afternoons  debugging Apache CXF to finally discover load-balancing algorithm: at  first invocation CXF asks strategy for a list of possible nodes. Then it  passes this list back to the strategy asking to pick one (small <i>wtf<\/i> here&#8230;) The strategy decides which address to use and removes picked address from the list (another small <i>one<\/i>  here&#8230;) When CXF discovers the list is empty, story repeats itself. So  if we replace the list of alternate addresses at runtime, after one  round new list will be returned to the core CXF infrastructure.<\/div>\n<div>\n<\/div>\n<div>Because I&#8217;m a huge JMX advocate, here is how we are going to  modify the addresses list (you can use whatever mechanism you like):<\/div>\n<pre class=\"brush:java\">@Service\r\n@ManagedResource\r\npublic class AlternateAddressesManager {\r\n\r\n    @Resource\r\n    private List alternateAddresses;\r\n\r\n    @ManagedOperation\r\n    public void addAlternateAddress(String address) {\r\n        alternateAddresses.add(address);\r\n    }\r\n\r\n    @ManagedOperation\r\n    public boolean removeAlternateAddress(String address) {\r\n        return alternateAddresses.remove(address);\r\n    }\r\n\r\n    @ManagedAttribute\r\n    public List getAlternateAddresses() {\r\n        return Collections.unmodifiableList(alternateAddresses);\r\n    }\r\n\r\n}\r\n<\/pre>\n<div><\/div>\n<div>\n<div>Yep, it&#8217;s the very same <span>alternateAddresses<\/span> list used by <span>SequentialStrategy<\/span>, so by simply modifying it we are altering CXF addressing behaviour. Arguably we could extend <span>CopyOnWriteArrayList<\/span> adding few extra JMX-enabled methods (or, exploting Springs&#8217; flexibility, expose <span>List<\/span> methods directly via JMX!), but this would decrease maintainability and I would consider this as poor design.<\/div>\n<div>\n<\/div>\n<div>Finally, we can launch <span>jconsole<\/span> or JVisualVM as on the screenshots below and enjoy our load-balancing infrastructure:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-SU0gJJbxh7o\/Tes1xEIHXqI\/AAAAAAAAACg\/WFSLPedsKQg\/s1600\/zrzut_ekranu-8.png\"><img decoding=\"async\" border=\"0\" height=\"249\" src=\"http:\/\/4.bp.blogspot.com\/-SU0gJJbxh7o\/Tes1xEIHXqI\/AAAAAAAAACg\/WFSLPedsKQg\/s320\/zrzut_ekranu-8.png\" width=\"320\" \/><\/a><\/div>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/--fF1igPMkdk\/Tes11xfR4UI\/AAAAAAAAACk\/IVDuEN4MJcc\/s1600\/zrzut_ekranu-9.png\"><img decoding=\"async\" border=\"0\" height=\"164\" src=\"http:\/\/2.bp.blogspot.com\/--fF1igPMkdk\/Tes11xfR4UI\/AAAAAAAAACk\/IVDuEN4MJcc\/s320\/zrzut_ekranu-9.png\" width=\"320\" \/><\/a><\/div>\n<\/div>\n<div><\/div>\n<div>\n<div>Happy? Not really. While studying CXF source code I came across this dreadful JavaDoc comment on <span>LoadDistributorFeature<\/span> and <span>FailoverTargetSelector<\/span> classes which take significant part in load-balancing process:<\/div>\n<div>\n<\/div>\n<div>\/**<\/div>\n<div>&nbsp;* [&#8230;]<\/div>\n<div>&nbsp;* Note that this feature changes the conduit on the fly and thus <strong>makes<\/strong><\/div>\n<div>&nbsp;* <strong>the Client not thread safe.<\/strong><\/div>\n<div>&nbsp;*\/<\/div>\n<div>\n<\/div>\n<div>Focus on the text in bold (OK, honestly, I don&#8217;t understand the rest). If you&#8217;ve worked with Spring for some time you know that <span>testServiceClient<\/span>  bean is a shared singleton used by multiple threads concurrently (no,  making it prototype scope won&#8217;t help; why?), in contrary to default EJB  stateless session beans, which are pooled. Fortunately Spring has a  built-in solution for that as well. But before I finally came up with a  right solution, several obstacles arose.<\/div>\n<div>First, <span>jaxws:client<\/span>  tag from CXF namespace does not allow to define bean scope, defaulting  to singleton, while we want to pool our clients. So I had to fall back  to good old bean definition with <span>org.apache.cxf.jaxws.JaxWsProxyFactoryBean<\/span>.  No problem, slightly more verbose, although if you can&#8217;t\/don&#8217;t want to  use custom Spring namespaces, you might have used it from the very  beginning. Now the best part: I can simply wrap any bean with prototype  scope in a special proxy and Spring will <i>automagically<\/i> create an object pool (based on <a href=\"http:\/\/commons.apache.org\/pool\/\">commons-pool<\/a> library) and create as many bean instances as necessary to keep each bean used by only one thread. Here is the configuration:<\/div>\n<pre class=\"brush:xml\">&lt;bean id=\"testServiceClientFactoryBean\" class=\"org.apache.cxf.jaxws.JaxWsProxyFactoryBean\"&gt;\r\n    &lt;property name=\"serviceClass\" value=\"com.blogspot.nurkiewicz.cxfcluster.SimpleService\"\/&gt;\r\n    &lt;property name=\"features\"&gt;\r\n        &lt;util:list&gt;\r\n            &lt;bean class=\"org.apache.cxf.clustering.LoadDistributorFeature\"&gt;\r\n                &lt;property name=\"strategy\"&gt;\r\n                    &lt;bean class=\"org.apache.cxf.clustering.SequentialStrategy\"&gt;\r\n                        &lt;property name=\"alternateAddresses\" ref=\"alternateAddresses\"\/&gt;\r\n                    &lt;\/bean&gt;\r\n                &lt;\/property&gt;\r\n            &lt;\/bean&gt;\r\n        &lt;\/util:list&gt;\r\n    &lt;\/property&gt;\r\n&lt;\/bean&gt;\r\n\r\n&lt;bean id=\"testServiceClientTarget\" factory-bean=\"testServiceClientFactoryBean\" factory-method=\"create\" scope=\"prototype\" lazy-init=\"true\"\/&gt;\r\n\r\n&lt;bean id=\"testServiceClient\" class=\"org.springframework.aop.framework.ProxyFactoryBean\"&gt;\r\n    &lt;property name=\"targetSource\"&gt;\r\n        &lt;bean class=\"org.springframework.aop.target.CommonsPoolTargetSource\"&gt;\r\n            &lt;property name=\"targetClass\" value=\"com.blogspot.nurkiewicz.cxfcluster.SimpleService\"\/&gt;\r\n            &lt;property name=\"targetBeanName\" value=\"testServiceClientTarget\"\/&gt;\r\n            &lt;property name=\"maxSize\" value=\"10\"\/&gt;\r\n            &lt;property name=\"maxWait\" value=\"5000\"\/&gt;\r\n        &lt;\/bean&gt;\r\n    &lt;\/property&gt;\r\n&lt;\/bean&gt;\r\n<\/pre>\n<div>\n<div>Have you noticed <span>maxSize<\/span> and <span>maxWait<\/span> pool attributes? They are <strong>insanely cool<\/strong>!  You can tell Spring not to create more than 10 clients in the pool and  if the pool is empty (all the beans are currently in use), we should  wait no more than 5000ms (and what happens afterwards is configurable!)  This is actually a very simple yet powerful throttling mechanism, much  simpler than JMS or explicit thread pools, we get absolutely for free!  E.g. don&#8217;t want to serve more than 20 concurrent web service clients?  Make your server endpoint access service bean being pooled with size  limited to 20. Client above this limit will be rejected as no service  bean is available.<\/div>\n<div>\n<\/div>\n<div>Of course in adults world nothing works as expected. I quickly discovered that <i>JaxWsProxyFactoryBean.create is not thread-safe<\/i><span style=\"font-style: normal\"> and reported <a href=\"https:\/\/issues.apache.org\/jira\/browse\/CXF-3558\">CXF-3558<\/a>. As a workaround I had to synchronize the client factory used by <\/span><span>CommonsPoolTargetSource<\/span><span style=\"font-style: normal\"> simply by subclassing it:<\/span><\/div>\n<pre class=\"brush:java\">import org.apache.commons.pool.ObjectPool;\r\nimport org.apache.commons.pool.PoolUtils;\r\nimport org.springframework.aop.target.CommonsPoolTargetSource;\r\n\r\npublic class SynchCommonsPoolTargetSource extends CommonsPoolTargetSource {\r\n\r\n    @Override\r\n    protected ObjectPool createObjectPool() {\r\n        return PoolUtils.synchronizedPool(super.createObjectPool());\r\n    }\r\n\r\n}\r\n<\/pre>\n<div>\n<div><span style=\"font-style: normal\">Synchronizing the factory seems like a common need so I created <a href=\"https:\/\/jira.springsource.org\/browse\/SPR-8382\">SPR-8382<\/a> \u2013 maybe it will find its way to official release. BTW while working on this article I also reported <a href=\"http:\/\/youtrack.jetbrains.net\/issue\/IDEA-70365\">IDEA-70365<\/a> \u2013 <\/span><i>Spurious &#8220;Could not autowire&#8221; error reported for beans of List type<\/i><span style=\"font-style: normal\">.<\/span><\/div>\n<div>\n<\/div>\n<div><span style=\"font-style: normal\">Finally! Our load-balancing  and failover works like a charm. Next step would be to temporarily  discard nodes that are down for couple of seconds and increase this time  if the endpoint is still down afterwards. But Apache CXF has so  terrible API in this area that I had to leave this topic for a while.  Maybe YOU can help?<\/span><\/div>\n<\/div>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/nurkiewicz.blogspot.com\/2011\/05\/enabling-load-balancing-and-failover-in.html\">Enabling load balancing and failover in Apache CXF<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Tomasz at the <a href=\"http:\/\/nurkiewicz.blogspot.com\/\">NoBlogDefFound blog<\/a>.<\/p>\n<div style=\"margin: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/11\/jaxws-with-spring-and-maven-tutorial.html\">JAX\u2013WS with Spring and Maven Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/06\/spring-3-restful-web-services.html\">Spring 3 RESTful Web Services<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/restful-web-services-with-resteasy-jax.html\">RESTful Web Services with RESTeasy JAX-RS on Tomcat 7 \u2013 Eclipse and Maven project<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>A while ago we&#8217;ve faced the requirement of load-balancing web services clients based on Apache CXF. Also the clients should automatically fail-over when some of the servers are down. To make it even worse, the list of servers target addresses was to be obtained from external service and updated at runtime. Eventually we ended up &hellip;<\/p>\n","protected":false},"author":13,"featured_media":70,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[171],"class_list":["post-442","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-apache-cxf"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Apache CXF Load Balancing And Failover - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"A while ago we&#039;ve faced the requirement of load-balancing web services clients based on Apache CXF. Also the clients should automatically fail-over when\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apache CXF Load Balancing And Failover - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"A while ago we&#039;ve faced the requirement of load-balancing web services clients based on Apache CXF. Also the clients should automatically fail-over when\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2011-06-13T00:41:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T19:49:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Tomasz Nurkiewicz\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/tnurkiewicz\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tomasz Nurkiewicz\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html\"},\"author\":{\"name\":\"Tomasz Nurkiewicz\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/fb1be85725c10e8361e641fa851e79e1\"},\"headline\":\"Apache CXF Load Balancing And Failover\",\"datePublished\":\"2011-06-13T00:41:00+00:00\",\"dateModified\":\"2012-10-21T19:49:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html\"},\"wordCount\":1288,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-logo.jpg\",\"keywords\":[\"Apache CXF\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html\",\"name\":\"Apache CXF Load Balancing And Failover - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-logo.jpg\",\"datePublished\":\"2011-06-13T00:41:00+00:00\",\"dateModified\":\"2012-10-21T19:49:52+00:00\",\"description\":\"A while ago we've faced the requirement of load-balancing web services clients based on Apache CXF. Also the clients should automatically fail-over when\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/apache-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/06\\\/apache-cxf-load-balancing-failover.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Apache CXF Load Balancing And Failover\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/fb1be85725c10e8361e641fa851e79e1\",\"name\":\"Tomasz Nurkiewicz\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g\",\"caption\":\"Tomasz Nurkiewicz\"},\"description\":\"Java EE developer, Scala enthusiast. Enjoying data analysis and visualization. Strongly believes in the power of testing and automation.\",\"sameAs\":[\"http:\\\/\\\/nurkiewicz.blogspot.com\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/tnurkiewicz\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/tomasz-nurkiewicz\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Apache CXF Load Balancing And Failover - Java Code Geeks","description":"A while ago we've faced the requirement of load-balancing web services clients based on Apache CXF. Also the clients should automatically fail-over when","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html","og_locale":"en_US","og_type":"article","og_title":"Apache CXF Load Balancing And Failover - Java Code Geeks","og_description":"A while ago we've faced the requirement of load-balancing web services clients based on Apache CXF. Also the clients should automatically fail-over when","og_url":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-06-13T00:41:00+00:00","article_modified_time":"2012-10-21T19:49:52+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-logo.jpg","type":"image\/jpeg"}],"author":"Tomasz Nurkiewicz","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/tnurkiewicz","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Tomasz Nurkiewicz","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html"},"author":{"name":"Tomasz Nurkiewicz","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/fb1be85725c10e8361e641fa851e79e1"},"headline":"Apache CXF Load Balancing And Failover","datePublished":"2011-06-13T00:41:00+00:00","dateModified":"2012-10-21T19:49:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html"},"wordCount":1288,"commentCount":4,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-logo.jpg","keywords":["Apache CXF"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html","url":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html","name":"Apache CXF Load Balancing And Failover - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-logo.jpg","datePublished":"2011-06-13T00:41:00+00:00","dateModified":"2012-10-21T19:49:52+00:00","description":"A while ago we've faced the requirement of load-balancing web services clients based on Apache CXF. Also the clients should automatically fail-over when","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/apache-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2011\/06\/apache-cxf-load-balancing-failover.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Apache CXF Load Balancing And Failover"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/fb1be85725c10e8361e641fa851e79e1","name":"Tomasz Nurkiewicz","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g","caption":"Tomasz Nurkiewicz"},"description":"Java EE developer, Scala enthusiast. Enjoying data analysis and visualization. Strongly believes in the power of testing and automation.","sameAs":["http:\/\/nurkiewicz.blogspot.com\/","https:\/\/x.com\/https:\/\/twitter.com\/tnurkiewicz"],"url":"https:\/\/www.javacodegeeks.com\/author\/tomasz-nurkiewicz"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=442"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/442\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/70"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}