You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@synapse.apache.org by Java Programmer <jp...@gmail.com> on 2008/12/09 10:09:12 UTC
How to switch message flow form In to Out?
Hello,
I have problem with sending back empty message for some condition:
<sequence name="hotels-sequence">
<filter source="//book:getPackage/hotels" regex="true">
<then>
<send>
<endpoint>
<address uri="http://remote.webservice.test.com:8177/" />
</endpoint>
</send>
</then>
<else>
<xslt key="transform/empty_message.xslt">
<feature name="http://ws.apache.org/ns/synapse/transform/feature/dom"
value="true"/>
</xslt>
<property name="RESPONSE" value="true"/>
<send />
</else>
</filter>
</sequence>
Transformation is done to have simpel XML output:
<response></response> - maybe there is better way?
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
exclude-result-prefixes="fn xs xsi xsl">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/*">
<response></response>
</xsl:template>
</xsl:stylesheet>
I thought that switching property to RESPONSE, and send without
address parameters will send the message back to the aggreagator which
is next step of processing messages, but I have got this instead:
2008-12-09 09:59:29,343 [192.168.3.17-adr-37ac1b] [SynapseWorker-2]
ERROR HttpCoreNIOSender Malformed destination EPR :
/soap/BookingSystemProxy.BookingSystemProxyHttpsSoap12Endpoint
java.net.MalformedURLException: no protocol:
/soap/BookingSystemProxy.BookingSystemProxyHttpsSoap12Endpoint
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.sendAsyncRequest(HttpCoreNIOSender.java:317)
at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.invoke(HttpCoreNIOSender.java:256)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:132)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:202)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:61)
at org.apache.synapse.config.xml.AnonymousListMediator.mediate(AnonymousListMediator.java:30)
at org.apache.synapse.mediators.filters.FilterMediator.mediate(FilterMediator.java:143)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:61)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:111)
at org.apache.synapse.mediators.MediatorWorker.run(MediatorWorker.java:70)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2008-12-09 09:59:29,406 [192.168.3.17-adr-37ac1b] [SynapseWorker-2]
ERROR Axis2Sender Unexpected error sending message back
org.apache.axis2.AxisFault: Malformed destination EPR :
/soap/BookingSystemProxy.BookingSystemProxyHttpsSoap12Endpoint
at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.handleException(HttpCoreNIOSender.java:550)
at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.sendAsyncRequest(HttpCoreNIOSender.java:349)
at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.invoke(HttpCoreNIOSender.java:256)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:448)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:132)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:202)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:61)
at org.apache.synapse.config.xml.AnonymousListMediator.mediate(AnonymousListMediator.java:30)
at org.apache.synapse.mediators.filters.FilterMediator.mediate(FilterMediator.java:143)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:61)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:111)
at org.apache.synapse.mediators.MediatorWorker.run(MediatorWorker.java:70)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.MalformedURLException: no protocol:
/soap/BookingSystemProxy.BookingSystemProxyHttpsSoap12Endpoint
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.apache.synapse.transport.nhttp.HttpCoreNIOSender.sendAsyncRequest(HttpCoreNIOSender.java:317)
... 14 more
What is the solution of my problem - maybe there are some
architectural misunderstandings? I can't drop or makeFault message
because further aggregation don't work - so I think I need to send
empty message back.
Please help if you can, I'm really stuck with that :(
Best regards,
Adr
Re: How to switch message flow form In to Out?
Posted by "Asankha C. Perera" <as...@apache.org>.
Hi Adr
> Thx for answer as you see in second answer I have tried this, but
> there is another problem with aggregation - message seems to go back,
> but after receiving it seems to immediately stops the aggregation and
> sends empty answer: ..............
>
Can you share the high level pseudo code for your "requirement"..
cheers
asankha
--
Asankha C. Perera
http://adroitlogic.org
http://esbmagic.blogspot.com
Re: How to switch message flow form In to Out?
Posted by Java Programmer <jp...@gmail.com>.
> You need to remove the "To" header to send the response back here.. use the
> header mediator
>
> cheers
> asankha
Thx for answer as you see in second answer I have tried this, but
there is another problem with aggregation - message seems to go back,
but after receiving it seems to immediately stops the aggregation and
sends empty answer:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<response>
<imemptytag/>
</response>
</soapenv:Body>
</soapenv:Envelope>
which is aggregated response from only empty_message.xslt :
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
exclude-result-prefixes="fn xs xsi xsl">
<xsl:output method="xml" omit-xml-declaration="yes" encoding="UTF-8"
indent="yes"/>
<xsl:template match="/">
<response><imemptytag /></response>
</xsl:template>
</xsl:stylesheet>
but there should be also message from other endpoint //flights:
<!-- here is the endpoint we want to launch so we setup flights tag to true -->
<sequence name="flights-sequence">
<filter source="//book:getPackage/flights" regex="true">
<then>
<!-- this should be invoked -->
<send>
<endpoint>
<address uri="http://localhost:8166/" />
</endpoint>
</send>
</then>
<else>
<xslt key="transform/empty_message.xslt">
<feature name="http://ws.apache.org/ns/synapse/transform/feature/dom"
value="true"/>
</xslt>
<property name="RESPONSE" value="true"/>
<header name="To" action="remove"/>
<send/>
</else>
</filter>
</sequence>
<!-- we don't want hotels so we set up hotels tag to false -->
<sequence name="hotels-sequence">
<filter source="//book:getPackage/hotels" regex="true">
<then>
<send>
<endpoint>
<address uri="http://localhost:8177/" />
</endpoint>
</send>
</then>
<else>
<!-- this should be invoked -->
<xslt key="transform/empty_message.xslt">
<feature name="http://ws.apache.org/ns/synapse/transform/feature/dom"
value="true"/>
</xslt>
<property name="RESPONSE" value="true"/>
<header name="To" action="remove"/>
<send/>
</else>
</filter>
</sequence>
<proxy name="BookingSystemProxy">
<target>
<inSequence>
<clone continueParent="false">
<target sequence="flights-sequence" />
<target sequence="hotels-sequence" />
</clone>
</inSequence>
<outSequence>
<!-- this part aggregates only one message response empty response
from hotels, no response from flights even they are set up to true -
what's wrong? -->
<aggregate>
<onComplete expression="//response/*">
<send />
</onComplete>
</aggregate>
</outSequence>
</target>
</proxy>
The logs for this case tells me that:
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG AggregateMediator 1 messages of 2 collected in current
aggregation
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG AggregateMediator End : Aggregate mediator
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG SequenceMediator End : Sequence <anonymous>
Very strange because it nearly work for me, and very strange if I
launch both flights=true and hotels=true aggregation works fine, but
not with response made by setting RESPONSE to true (and remove To
header). Do you have any idea what happen in this case?
Best regards,
Adr
Re: How to switch message flow form In to Out?
Posted by "Asankha C. Perera" <as...@apache.org>.
...
> <else>
> <xslt key="transform/empty_message.xslt">
> <feature name="http://ws.apache.org/ns/synapse/transform/feature/dom"
> value="true"/>
> </xslt>
> <property name="RESPONSE" value="true"/>
> <send />
> .....
>
> I thought that switching property to RESPONSE, and send without
> address parameters will send the message back to the aggreagator which
> is next step of processing messages
You need to remove the "To" header to send the response back here.. use
the header mediator
cheers
asankha
--
Asankha C. Perera
http://adroitlogic.org
http://esbmagic.blogspot.com
Re: How to switch message flow form In to Out?
Posted by Java Programmer <jp...@gmail.com>.
> <else>
> <xslt key="transform/empty_message.xslt">
> <feature name="http://ws.apache.org/ns/synapse/transform/feature/dom"
> value="true"/>
> </xslt>
> <property name="RESPONSE" value="true"/>
> <send />
> </else>
Hello,
I have switched a little this out response above into:
<else>
<xslt key="transform/empty_message.xslt">
<feature name="http://ws.apache.org/ns/synapse/transform/feature/dom"
value="true"/>
</xslt>
<property name="RESPONSE" value="true"/>
<header name="To" action="remove"/>
<send/>
</else>
And now there is no error in logs but aggregation which is after that
stopped to work:
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG OutMediator End : Out mediator
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG FilterMediator End : Filter mediator
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG AggregateMediator Start : Aggregate mediator
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG AggregateMediator Creating new Aggregator - without expiry time
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG AggregateMediator Collected a message during aggregation
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG AggregateMediator 1 messages of 2 collected in current
aggregation
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG AggregateMediator End : Aggregate mediator
2008-12-09 14:19:47,718 [192.168.3.17-adr-37ac1b] [HttpClientWorker-4]
DEBUG SequenceMediator End : Sequence <anonymous>
In logs there are only one message (this with response data), and
there are no empty response data. Is this:
<property name="RESPONSE" value="true"/>
<header name="To" action="remove"/>
do something with clone / aggregation properties in message? I think
aggregator need something more to work in this scenario but what?
Best regards,
Adr