You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by balkishore <ba...@gmail.com> on 2012/09/10 11:25:16 UTC

SOAP session handling in load balncer

Dear members,
I have been playing and working around with apache camel for quite a while
now.
And i would like to thank the developers for producing such a awesome piece
of software suite.

Now my question is how can I enable load balancing via SOAP sessions in
apache camel.
I would like the request to be forwarded to the same server, to which the
previous request was forwarded. My requests are SOAP with SOAP session
enabled. Hence for each transaction a unique session id would be generated.
How can i forward the all the requests with the same session id to a single
server? Well below is my source code.

*public class LoadBalancer {
   public static void main(String args[]) throws Exception {
          CamelContext context = new DefaultCamelContext();

        context.addRoutes(new RouteBuilder() {

            public void configure() {
            	
            	
            	from("jetty://http://0.0.0.0:8080?matchOnUriPrefix=true")

            	 {
            	    
            		private Exchange e;
            	    
					public void process(Exchange exchange) throws Exception {
            	        System.out.println("Received exchange:" + e.getIn());
            	   }
            	});*/
            	.to("log:com.transcat.order?level=INFO")
            	.loadBalance().roundRobin()
               
.to("http://vmxp22-sat-1:8080?throwExceptionOnFailure=false&bridgeEndpoint=true","http://vmxp22-sat-2:8080?throwExceptionOnFailure=false&bridgeEndpoint=true");
            }
        }); *
        



--
View this message in context: http://camel.465427.n5.nabble.com/SOAP-session-handling-in-load-balncer-tp5719015.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: SOAP session handling in load balncer

Posted by balkishore <ba...@gmail.com>.
Hi Willem,
I am new to everything that on working on,  And these things are still
confusing me. Could you please explain them in more simpler term? 
As far I got to know, I have to get my request into camel-cxf endpoint in
PAYLOAD data format and have to extract the header, then I have to use XPath
to qery through the header for ServiceGroupID? correct me if i am wrong. And
is there any real time example that would help me to achieve this? The
problem here is joining the dots, How would I join the CXF with load
balancer processor?

Any help would be of a really appreciated.



--
View this message in context: http://camel.465427.n5.nabble.com/SOAP-session-handling-in-load-balncer-tp5719015p5719093.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: SOAP session handling in load balncer

Posted by balkishore <ba...@gmail.com>.
Hi Willem,
I am extremely sorry, I am new to everything that on working on,  And these
things are still confusing me. Could you please explain them in more simpler
term? 
As far I got to know, I have to get my request into camel-cxf endpoint in
PAYLOAD data format and have to extract the header, then I have to use XPath
to qery through the header for ServiceGroupID? correct me if i am wrong. And
is there any real time example that would help me to achieve this? The
problem here is joining the dots, How would I join the CXF with load
balancer processor?




--
View this message in context: http://camel.465427.n5.nabble.com/SOAP-session-handling-in-load-balncer-tp5719015p5719092.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: SOAP session handling in load balncer

Posted by Willem jiang <wi...@gmail.com>.
You should be able to pick up the ServiceGroupId from the soap header in a processor as  I showed you in the last mail.
Then you can store the ServiceGroupId into to message header, and you can setup the expression with header("ServiceGroupId"). 

At the same time you need to setup the camel-cxf producer with the back end server address as you did before for load balancer to pickup .


-- 
Willem Jiang

FuseSource
Web: http://www.fusesource.com (http://www.fusesource.com/)
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Tuesday, September 11, 2012 at 3:57 PM, balkishore wrote:

> Hi Willem, My SOAP sessions are embedded in the SOAP header and my SOAP
> header looks like this:
> 
> <?xml version="1.0" encoding="http://schemas.xmlsoap.org/soap/envelope/"
> standalone="no"?>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
> <wsa:ReplyTo>
> <wsa:Address>http://www.w3.org/2005/08/addressing/none</wsa:Address>
> <wsa:ReferenceParameters>
> <axis2:ServiceGroupId
> xmlns:axis2="http://ws.apache.org/namespaces/axis2">urn:uuid:99A029EBBC70DBEB221347349722532</axis2:ServiceGroupId>
> </wsa:ReferenceParameters>
> </wsa:ReplyTo>
> <wsa:MessageID>urn:uuid:99A029EBBC70DBEB221347349722564</wsa:MessageID>
> <wsa:Action>Some action to perform</wsa:Action>
> <wsa:RelatesTo>urn:uuid:63AD67826AA44DAE8C1347349721356</wsa:RelatesTo>
> </soapenv:Header>
> 
> How would i use Expression to sort the Service GroupID from the header and
> would pass the request with same ServiceGroupId to same server?
> 
> Any help would be really appreciated.
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/SOAP-session-handling-in-load-balncer-tp5719015p5719087.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: SOAP session handling in load balncer

Posted by balkishore <ba...@gmail.com>.
Hi Willem, My SOAP sessions are embedded in the SOAP header and my SOAP
header looks like this:

<?xml version="1.0" encoding="http://schemas.xmlsoap.org/soap/envelope/"
standalone="no"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/none</wsa:Address>
<wsa:ReferenceParameters>
<axis2:ServiceGroupId
xmlns:axis2="http://ws.apache.org/namespaces/axis2">urn:uuid:99A029EBBC70DBEB221347349722532</axis2:ServiceGroupId>
</wsa:ReferenceParameters>
</wsa:ReplyTo>
<wsa:MessageID>urn:uuid:99A029EBBC70DBEB221347349722564</wsa:MessageID>
<wsa:Action>Some action to perform</wsa:Action>
<wsa:RelatesTo>urn:uuid:63AD67826AA44DAE8C1347349721356</wsa:RelatesTo>
</soapenv:Header>

How would i use Expression to sort the Service GroupID from the header and
would pass the request with same ServiceGroupId to same server?

Any help would be really appreciated.



--
View this message in context: http://camel.465427.n5.nabble.com/SOAP-session-handling-in-load-balncer-tp5719015p5719087.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: SOAP session handling in load balncer

Posted by Willem jiang <wi...@gmail.com>.
Hi, 

I'm not sure what's the request looks like?
It looks like you can ask help of camel-cxf with PAYLOAD[1] data format to extract the session id you want from the soap header and then send the request to the real endpoint.

[1]http://camel.apache.org/cxf.html#CXF-HowtogetandsetSOAPheadersinPAYLOADmode
-- 
Willem Jiang

FuseSource
Web: http://www.fusesource.com (http://www.fusesource.com/)
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang



On Tuesday, September 11, 2012 at 3:30 PM, balkishore wrote:

> Hello Willem,
> Thanks a ton for replying.
> 
> My requests are SOAP messages and the seesion ID in AXIS2 are stored in
> ServiceGroupID node of the SOAP header. How can I extract this Session ID
> and use sticky session? is there any example that would help me understand
> this? any help would be really appreciated.
> 
> Thank you very much in advance.
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/SOAP-session-handling-in-load-balncer-tp5719015p5719081.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: SOAP session handling in load balncer

Posted by balkishore <ba...@gmail.com>.
Hello Willem,
Thanks a ton for replying.

My requests are SOAP messages and the seesion ID in AXIS2 are stored in
ServiceGroupID node of the SOAP header. How can I extract this Session ID
and use sticky session? is there any example that would help me understand
this? any help would be really appreciated.

Thank you very much in advance.



--
View this message in context: http://camel.465427.n5.nabble.com/SOAP-session-handling-in-load-balncer-tp5719015p5719081.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: SOAP session handling in load balncer

Posted by Willem jiang <wi...@gmail.com>.
You can use the StickyLoadBalancer[1] with expression which takes the value from the session id to make sure camel send the request to same back end server if the session id is same.

[1]http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.html 

-- 
Willem Jiang

FuseSource
Web: http://www.fusesource.com (http://www.fusesource.com/)
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Monday, September 10, 2012 at 5:25 PM, balkishore wrote:

> Dear members,
> I have been playing and working around with apache camel for quite a while
> now.
> And i would like to thank the developers for producing such a awesome piece
> of software suite.
> 
> Now my question is how can I enable load balancing via SOAP sessions in
> apache camel.
> I would like the request to be forwarded to the same server, to which the
> previous request was forwarded. My requests are SOAP with SOAP session
> enabled. Hence for each transaction a unique session id would be generated.
> How can i forward the all the requests with the same session id to a single
> server? Well below is my source code.
> 
> *public class LoadBalancer {
> public static void main(String args[]) throws Exception {
> CamelContext context = new DefaultCamelContext();
> 
> context.addRoutes(new RouteBuilder() {
> 
> public void configure() {
> 
> 
> from("jetty://http://0.0.0.0:8080?matchOnUriPrefix=true")
> 
> {
> 
> private Exchange e;
> 
> public void process(Exchange exchange) throws Exception {
> System.out.println("Received exchange:" + e.getIn());
> }
> });*/
> .to("log:com.transcat.order?level=INFO")
> .loadBalance().roundRobin()
> 
> .to("http://vmxp22-sat-1:8080?throwExceptionOnFailure=false&bridgeEndpoint=true","http://vmxp22-sat-2:8080?throwExceptionOnFailure=false&bridgeEndpoint=true");
> }
> }); *
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/SOAP-session-handling-in-load-balncer-tp5719015.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).