12.5. 例
以下のルートでは browse: コンポーネントを挿入し、パススルーしているエクスチェンジを参照できます。
from("activemq:order.in").to("browse:orderReceived").to("bean:processOrder");
これで、Java コード内から受信したエクスチェンジを検査できます。
private CamelContext context;
public void inspectReceivedOrders() {
BrowsableEndpoint browse = context.getEndpoint("browse:orderReceived", BrowsableEndpoint.class);
List<Exchange> exchanges = browse.getExchanges();
// then we can inspect the list of received exchanges from Java
for (Exchange exchange : exchanges) {
String payload = exchange.getIn().getBody();
// do something with payload
}
}