forget99 opened a new issue, #249:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/249
### 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);`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]