Difficulties changing serviceProxy destination URL in Groovy interceptor

22 views
Skip to first unread message

mats....@yahoo.com

unread,
May 3, 2017, 6:30:47 PM5/3/17
to membrane-monitor
Hi,

I'm a bit confused of how Membrane works in some aspects and think I could need some help.

I'm using the standard <rewriter> interceptor in a <serviceProxy> to route incoming requests to an external service. Since the destination URL requires some more advanced rewriting than what can be achieved with the <map> element, I was thinking about "post-processing" the mapped destination URL in a Groovy interceptor (e.g. with a script line like: exc.request.setUri(...)).

I have tried this, but it doesn't seem to work. While on the Calls page in the Membrane admin console I can see the post-processed URL showing up in the Path column, from the response I observe in the browser it seems the request is still dispatched to the non-post-processed URL!

What is also confusing to me is that the Groovy interceptor seems to be executed twice for every request (I have a println statement in it, so can see this in the logs). This inspite of the fact that the interceptor is nested in a <request> element.

Would be grateful for some help here. I guess it a way to understand a bit better what is happening would be to enable DEBUG/TRACE level logging, however, this also I am having some difficulties with... :).

/ Mats


mats....@yahoo.com

unread,
May 4, 2017, 3:02:04 AM5/4/17
to membrane-monitor
Update: Managed to have debugging messages outputted (had forgotten that I bound SLF4J to Simple implementation. Have now replaced it with Log4J). Hope this will bring some clarity to the original problem... /Mats

mats....@yahoo.com

unread,
May 4, 2017, 3:57:41 AM5/4/17
to membrane-monitor
Update 2: Ok, think I got some clarity to the side-question concerning double invokation of the Groovy interceptor element nested in a request element. It seems the interceptor must be an immediate child of the request element in order for it not to be invoked twice (i.e. in both the request and response phases). I had an <if> element in between, and this seems to have been the problem! (I thought the request and response elements affected all its descendants). / Mats

mats....@yahoo.com

unread,
May 4, 2017, 6:31:27 AM5/4/17
to membrane-monitor
Update 3: Ok, think I also solved the original problem -- that of modifying the destination URL. Instead of using request.setUri(), I am now using getDestinations().set(0, newuri), and it works!
Reply all
Reply to author
Forward
0 new messages