54.3. 例

以下のルートでは、通過する Exchange を参照できるように、browse: コンポーネントを挿入します。

from("activemq:order.in").to("browse:orderReceived").to("bean:processOrder");

受信した交換を Java コード内から検査できるようになりました。

private CamelContext context;

public void inspectRecievedOrders() {
    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
    }
}