Hi Ryan

I'm scratching my head a little trying to figure out the differences between these two. I'm guessing the issue is that the HTTP binding is using a StreamSource - which only allows parsing just once.

So the <jbi:forward> tries to take the NormalizedMessage.getContent() and use that as its message body.

I think the problem is the HTTP marshaler is using the StreamSource as the content; which can only be parsed once - so when the <jbi:forward> passes the message on its body is empty.

A solution to this is to either, always use <jbi:invoke> or have a special kind of Source which acts like a StreamSource but buffers its contents up so it can be re-parsed a second time if need be.

Incidentally, could you confirm that there are no exceptions or errors generated in the log when running your example?

James


Schweter, Ryan wrote:
I’ve ran into an issue with the XPath Router. We are currently looking at a few open source ESB products to determine if they are a viable solution for us. Any assistance is greatly appreciated.

I’m trying to whip together a quick XPath Router proof of concept. Here’s what I want to do:

1)    Receive XML event from HTTP receiver

2)    Route event based on XPath rules

3)    Ultimately persist to disk

Here’s the config I’m using:

--------------------------------------------------------------------------------

<beans xmlns:bwnet="http://broadwing.net/xml";>

      <container id="jbi">

            <components>

<component id="httpReceiver" service="bwnet:httpBinding" endpoint="httpReceiver" class="org.servicemix.components.http.HttpConnector" destinationService="bwnet:xmlRouter">

                        <property name="host" value="reyonman"/>

                        <property name="port" value="8912"/>

                  </component>

<component id="xmlRouter" service="bwnet:xmlRouter" class="org.servicemix.components.xslt.XsltComponent">

<property name="xsltResource" value="EventFilter.xslt"/>

                        <property name="disableOutput" value="true"/>

                  </component>

<component id="filteredEvents" service="bwnet:filteredEvents" class="org.servicemix.components.file.FileWriter">

<property name="directory" value="/apps/servicemix/broadwing.net/filteredEvents"/>

                        <property name="marshaler">

<bean class="org.servicemix.components.util.DefaultFileMarshaler">

                                    <property name="fileName">

<bean class="org.servicemix.expression.JaxenStringXPathExpression">

<constructor-arg value="concat('Event_', //@router-id, '.xml')"/>

                                          </bean>

                                    </property>

                              </bean>

                        </property>

                  </component>

            </components>

      </container>

</beans>

--------------------------------------------------------------------------------

Here’s EventFilter.xslt (currently immediately routes straight to bwnet:filteredEvents):

--------------------------------------------------------------------------------

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:jbi="xalan://org.servicemix.components.xslt.XalanExtension" extension-element-prefixes="jbi" xmlns:bwnet="http://broadwing.net/xml"; version="1.0">

      <xsl:template match="/*">

            <jbi:forward service="bwnet:filteredEvents" />

      </xsl:template>

</xsl:stylesheet>

--------------------------------------------------------------------------------

And here’s a sample event:

--------------------------------------------------------------------------------

<Event router-id=”231489” />

--------------------------------------------------------------------------------

When I post the event, the router is executed, but filteredEvents is never called. However, if I change my XSLT to use jbi:invoke instead of jbi:forward it works. For example:

--------------------------------------------------------------------------------

<jbi:invoke service="bwnet:filteredEvents">

      <jbi:copyProperties/>

      <xsl:copy-of select="."/>

</jbi:invoke>

--------------------------------------------------------------------------------

For a sanity check, I setup the example found online, using the config file found in the test cases. It seems that the same thing is happening with it as well. The ‘invokes’ (e.g. script) are executing and the ‘forwards’ (i.e. trace) are not.

_____________________________________________________
|\| R Y A N  S C H W E T E R                      |\|
|/|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯                |/|
|\| developer                                      \|
|/| IT Application Delivery
|\| .: 512.742.7875
|/| .: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
|\|
¯¯¯



--

James
-------
http://radio.weblogs.com/0112098/

Reply via email to