아래 경로에서 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");
}
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");
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
여기에서 Hello World 메시지를 보내고 회신이 OK가 될 것으로 예상합니다.
Object out = template.requestBody("direct:start", "Hello World");
assertEquals("OK", out);
Object out = template.requestBody("direct:start", "Hello World");
assertEquals("OK", out);
Copy to ClipboardCopied!Toggle word wrapToggle overflow
"Hello World" 메시지는 추가 처리를 위해 다른 스레드의 Disruptor에서 사용됩니다. 이는 단위 테스트에서 가져온 것이므로 단위 테스트에서 어설션을 수행할 수 있는 mock 엔드포인트로 전송됩니다.