ReactiveX / RxNetty

Reactive Extension (Rx) Adaptor for Netty

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question regarding RequestCorrelator and Rxnetty 0.4

jaume-pinyol opened this issue · comments

Hi,

I have an issue regarding RequestCorrelator and I don't know if I'm doing something wrong or I've configured it wrongly. The case is that inside the application code (The router or handler) I can't have access to the request id(I could always get it from the request, but I think that's why the request correlator is for...).
When I try to do:

RxContexts.DEFAULT_CORRELATOR.getRequestIdForClientRequest()

It is always null, I've debugged the code and when there is a new request the id is catched|generated properly in:

https://github.com/ReactiveX/RxNetty/blob/0.4.x/rxnetty-contexts/src/main/java/io/reactivex/netty/contexts/http/HttpRequestIdProvider.java#L85

This is how I start the server

 HttpServerBuilder<ByteBuf, ByteBuf> serverBuilder = RxContexts
                .newHttpServerBuilder(port, requestHandlerWrapper, RxContexts.DEFAULT_CORRELATOR)
                .withRequestProcessingThreads(requestProcessingThreads);

I think it may be related to setting the withRequestProcessingThreads, because it make the request to be processed in a different thread(rx-request-processor) instead of the nio-eventloop where the Threadlocal info is set.

Do you think this is the case? Or am I using it wrong?

Thanks in advance!

@jaume-pinyol you are correct that the reason for not finding the requestId is because you are using the withRequestProcessingThreads() option.
If you are not using any blocking code as part of the processing of a request, you most likely do not require withRequestProcessingThreads.

Thanks for the quick response! I think I've managed to fix my issue