I tried this..
context.getRouteDefinitions().get(0).adviceWith(context, new
RouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mock:mina:tcp://unreachable.splunk.server:9000")
.skipSendToOriginalEndpoint()
.to("mock:mina-advised");
}
});
I have multiple routes in my config - does get(0) just get the first route?
I also tried this..
context.getRouteDefinition("toSplunk").adviceWith(context, new
RouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mock:mina:tcp://unreachable.splunk.server:9000")
.skipSendToOriginalEndpoint()
.to("mock:mina-advised");
}
});
and this (with direct component - not mock)..
context.getRouteDefinition("toSplunk").adviceWith(context, new
RouteBuilder() {
@Override
public void configure() throws Exception {
interceptSendToEndpoint("mina:tcp://unreachable.splunk.server:9000")
.skipSendToOriginalEndpoint()
.to("mock:mina-advised");
}
});
All give java.nio.channels.UnresolvedAddressException because they are
trying to write to splunk server.
My route looks like:
<route autoStartup="true" id="tosplunk" xmlns="
http://camel.apache.org/schema/spring">
<from uri="direct:splunk.in"/>
<filter>
<xpath>//*[local-name() = "event"]</xpath>
<bean ref="unWrapEnvelopeXml"/>
<bean ref="ispyXmlToSplunk"/>
<to
uri="mina:tcp://unreachable.splunk.server:9000?textline=true&textlineDelimiter=UNIX&sync=false"/>
</filter>
</route>
Thanks, Tom
On Mon, Mar 28, 2011 at 8:24 PM, Tom Howe <[email protected]> wrote:
> Is this what you are pointing me to? .skipSendToOriginalEndpoint()
>
> How do I use this in my spring xml routes?
>
>
> On Mon, Mar 28, 2011 at 7:02 PM, Claus Ibsen <[email protected]>wrote:
>
>> See
>> http://camel.apache.org/advicewith.html
>>
>> On Mon, Mar 28, 2011 at 7:47 PM, Tom Howe <[email protected]> wrote:
>> > I have a route such as:
>> >
>> > <route autoStartup="true" xmlns="http://camel.apache.org/schema/spring
>> ">
>> > <from uri="activemq:somequeue"/>
>> > ...
>> > <to uri="http:hostname/some/path"/>
>> > </route>
>> >
>> > If I set up mocking, using a wrapper xml file containing:
>> >
>> > <bean id="mockAllEndpoints"
>> > class="org.apache.camel.impl.InterceptSendToMockEndpointStrategy"/>
>> >
>> > I can now intercept the endpoints to see what was sent but how to I
>> prevent
>> > the test from connecting to activemq and the remote http server so I can
>> run
>> > the test without any external interaction?
>> >
>> > I managed to use
>> > <bean id="activemq"
>> > class="org.apache.camel.component.direct.DirectComponent" />
>> >
>> > to prevent activemq connecting, but the same trick did not work with
>> mina or
>> > http since the parameters passed are not appropriate.
>> >
>> >
>> > Thanks, Tom
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: [email protected]
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>
>