I want to redirect the message in the DynamicRouterBean depending on where it was sent to by the load balancer EIP. I was trying to access the previous endpoint inside DynamicRouterBean using @Header(Exchange.SLIP_ENDPOINT) but that's being set to null (Why?). Even when i get the Exchange (in the DynamicRouterBean), the fromEndPoint is direct://my-lb (but expected it to be either direct://my-lb-a or direct://my-lb-b??).
I later used the CamelHistory to see which endpoints the message had been but still have the question. Isn't the previous end point (or fromEndPoint, or Exchange.SLIP_ENDPOINT) one of the load balancer end points?
from("direct://my-lb")
.loadBalance().roundRobin()
.to("direct://my-lb-a")
.to("direct://my-lb-b")
.end()
.dynamicRouter(method(DynamicRouterBean.class, "slip"));
This worked for me, Thanks Claus Ibsen. Would be great if you could answer instead of commenting so i can accept your answers :)
public String slip(String body, @Header(Exchange.TO_ENDPOINT) String toEndPoint) {
...
}