I
I
Ivan Roganov2012-08-21 23:03:06
linux
Ivan Roganov, 2012-08-21 23:03:06

How to correctly set up a redirect to services if they accept different parameters?

There is a problem. I have an application written in velocity and inside it has the following code:

#set($regular = true)
#if ($regular)
<frame src="webservice1.com/?id=123&name=misha" />
#else
<frame src="webservice2.com/?UserIdentifier=123&UserName=misha" />
#end

It happens that webservice1 lies down like a copper basin by covering. In this case, I go to this script and change the variable $regular=false
Stupidly - but works well. In this case, webservice2 starts accepting requests from my application.
The problem is that the second service does not provide full functionality and people prefer the first, but the first falls.
The list of parameters passed to the service is the same, but their names are different. There is no possibility to rewrite services.
I have varnish running on the network, which zealously monitors the health of services in a way .probe- everything would be fine with this, but I can’t create a normal director in varnish because I can’t parse the parameters in the proxy server and rebuild them again. And in general, this is not a task for a proxy server - to rummage through the parameters.
I can write my own page like webserviceredirector.vm and redirect from it, but I don't know how to do something like .probevelocity. That is, varnish does probing, and java redirects.
Now I have a question: how to cross all this so that a good prickly hedgehog comes out as a normal redirector that will try services and, if they fall, switch them (for a while until the service rises back)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Roganov, 2012-09-17
@Nurked

Answering your own question ... If it's a varnish, like a proxy, then it's done like this in the config

set req.backend = webservice1;
if (req.backend.healthy)
{ 
     #redirect there 
}

set req.backend = webservice2;
if(req.backend.healthy)
{ 
     #change parameters with regex and redirect
}


Plus the pages have been rewritten to accept the same parameters and nip more. Thank you very much.

1
1nd1go, 2012-08-22
@1nd1go

It seems to me that it's better to write something like a service adapter, which will do the probe (itself), select the one you need, and transfer the parameters. And in src specify " mysite/service ?..."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question