Thanks for the hints, Guillaume and Gert! The code seems pretty straightforward (apart from the createMap call).
The observation is that leaving the source and destination endpoints untouched, might cause a loop. Here's why: A sends a ME for B, the NMR intercepts the ME and forwards it to C; C performs some modifications on the ME but does not tamper with the source and destination endpoints (otherwise the ME would not work as it should and the mechanism would no longer be transparent for A and B) and then it sends the same ME to the router. The router is supposed to send the ME to B. But the router will intercept it again via this same mechanism, because the ME would have the same source and destination. Where am I missing something? There should be a way to tell apart the initial ME and the modified one - can it be done via the property object, without generating too much overhead? Cheers, Gabriela -----Original Message----- From: Guillaume Nodet [mailto:[email protected]] Sent: Thursday, February 05, 2009 3:09 PM To: [email protected] Subject: Re: altering routing within the NMR As Gert said, we haven't any generic solution for servicemix 4, though I was in need for that for the clustering stuff. The idea is to use an ExchangeListener and intercept new exchanges. Here is the code I have so far: public void exchangeSent(Exchange exchange) { // Intercept exchanges if (exchange instanceof InternalExchange && exchange.getStatus() == Status.Active && exchange.getRole() == Role.Consumer && exchange.getOut(false) == null && exchange.getFault(false) == null) { // Filter JBI endpoints InternalEndpoint source = ((InternalExchange) exchange).getSource(); for (ClusterRegistration reg : getServices()) { if (reg.match(source)) { exchange.setTarget(getChannel().getNMR().getEndpointRegistry().lookup(Servic eHelper.createMap(Endpoint.NAME, name))); return; } } } } As you can see, the exchange is routed and the target overwritten. This will re-route the exchange to a known endpoint. In this case, the old target is discarded and will be recreated by the endpoint itself, because we still have the JBI addressing properties available. Another way would be to save the old target into a property on the exchange that would be later used by the endpoint. On Thu, Feb 5, 2009 at 11:59, Gabriela Gheorghe <[email protected]> wrote: > Hi, > > > > I need to do a bit of tuning inside the NMR so that messages sent to and > from the SAs could be transparently sent to a certain configurable endpoint > prior to taking their actual route. This of course without having to change > the routes already associated with the deployed components. > > > > Could you please tell me what I should do/use in this case? > > > > Thanks in advance, > > Gabriela > > > > -- Cheers, Guillaume Nodet ------------------------ Blog: http://gnodet.blogspot.com/ ------------------------ Open Source SOA http://fusesource.com
