apache / apache/apisix-java-plugin-runner

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

Abierto
#249 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Java
Estrellas
152
Forks
102
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### 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);`

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.