apache / apache/apisix-java-plugin-runner

request help: how to relate filter function and postFilter function?

Đang mở
#249 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
152
Fork
102
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### Issue description
如果将filter方法和postFilter方法关联起来,我现在有一个路由配置了ext-plugin-pre-req插件和ext-plugin-post-resp插件,我需要在ext-plugin-pre-req记录接口请求的相关信息(请求路径、请求参数等),需要在ext-plugin-post-resp插件中记录接口的响应信息(响应结果),我测试了一下在没有并发的情况下,就简单的单次调用可以正常记录信息,但是在高并发多个接口同时调用时,ext-plugin-pre-req插件的filter方法和ext-plugin-post-resp插件的postFilter方法不是一 一 对应的,导致我不能正确的记录接口请求中的信息,希望老师帮我看下。please help me!

### Environment

* your apisix-java-plugin-runner version
` @Override
public void filter(HttpRequest request, HttpResponse response, PluginFilterChain chain) {
String uuid = UuidUtil.create2();
Thread thread = Thread.currentThread();
thread.setName(uuid);
filterStrs.add(uuid);

String path = request.getPath();
requestPathMaps.put(uuid, path);
// jsonObject.put(uuid, path);
logger.info("【前置请求路径】:" + uuid + "----" + path);

chain.filter(request, response);
}

@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
Thread thread = Thread.currentThread();
String uuid = thread.getName();

String findStr = this.filterStrs.stream().filter(p -> p.equals(uuid)).findAny().orElse(null);
boolean flage = findStr != null;

String responseBody = formatBody(request.getBody());
String path = requestPathMaps.get(uuid);

logger.info("【后置结果findStr】:" + flage);
logger.info("【后置接口路径】:" + uuid + "---" + path);
logger.info("【后置接口相应】:" + responseBody);`

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.