The reason and solution of openFeign call interface without any response

Problem phenomenon:

        There is no response when calling the feign interface, and the server does not have any logs

reason:

        Whether the child thread initiates the interface call of Feign, feign does not support non-main thread calls, at this time because

No response due to missing RequestAttributes

  Solution:

        1. Avoid sub-thread calls

        2. Obtain RequestAttributes information in the main thread and pass it to the child thread

        

// 主线程中获取
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// 子线程中设置
RequestContextHolder.setRequestAttributes(requestAttributes);

        3. Organize and fill the RequestAttributes in the child thread to ensure that the data is not null, or you can

        4. For special scenarios, openFeign can be discarded and directly called by http

Guess you like

Origin blog.csdn.net/m0_37298500/article/details/129883313
Recommended