84.8. 샘플

아래 경로에서 Disruptor를 사용하여 다른 스레드에서 추가 처리를 위해 fire-and-forget 메시지를 보낼 수 있도록 이 비동기 대기열에 요청을 보내고 이 스레드의 지속적인 응답을 원래 호출자에게 반환합니다.

public void configure() throws Exception {
    from("direct:start")
        // send it to the disruptor that is async
        .to("disruptor:next")
        // return a constant response
        .transform(constant("OK"));

    from("disruptor:next").to("mock:result");
}

여기에서 Hello World 메시지를 보내고 응답이 OK일 것으로 예상합니다.

Object out = template.requestBody("direct:start", "Hello World");
assertEquals("OK", out);

추가 처리를 위해 다른 스레드의 Disruptor에서 "Hello World" 메시지가 사용됩니다. 이는 단위 테스트에서이므로 단위 테스트에서 어설션을 수행할 수 있는 mock 엔드포인트로 전송됩니다.