apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.54k stars 26.44k forks source link

[Bug] The provider is unable to obtain custom URL parameters #14838

Open tom055 opened 1 month ago

tom055 commented 1 month ago

Pre-check

Search before asking

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

Dubbo java 2.7.22

Steps to reproduce this issue

@DubboReference(version = "1.0.0",
            retries = 0,
            timeout=5000,
            parameters = {"responseFilter=true","securityFilter=false"},
            loadbalance = "roundrobin",
            check = false,
            cluster="failsafe",
            protocol = "dubbo",
            mock = "com.tiny.notify.api.mock.NotifyServiceApiMock")

I want to pass some parameters from the parameter to the provider, so that the consumer can obtain custom parameter keys and value values, but the provider cannot obtain these parameters from the URL

What you expected to happen

Did the built-in interceptor filter out my custom URL parameters? Looking forward to your reply. Thank you very much

Anything else

No response

Are you willing to submit a pull request to fix on your own?

Code of Conduct

AlbumenJ commented 1 month ago

Have you tried with parameters = {"responseFilter", "true", "securityFilter", "false"}?

Also, can't you get the value by invoker.getUrl().getParameter("responseFilter")?

BTW, configuring xxxFilter with true or false in parameters cannot enable or disable a certain Filter.

tom055 commented 1 month ago

I only want to obtain the parameters of the URL in the provider's interception. Currently, I am unable to obtain custom parameters (securityFilter) in the provider's interception, but I can obtain them in the consumer's interception. Is there a problem? I am looking forward to your reply very much

CONSUMER

@DubboReference(version = "1.0.0",
            retries = 0,
            timeout=5000,
            parameters = {"securityFilter", "false","responseFilter", "true"},
            loadbalance = "roundrobin",
            check = false,
            cluster="failsafe",
            protocol = "dubbo",
            mock = "com.device.notify.api.mock.NotifyServiceApiMock")
    NotifyServiceApi notifyServiceApi;

PROVIDER

@Activate(group = {CommonConstants.PROVIDER})
public class SecurityFilter extends ListenableFilter {

  @Override
  public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    String securityFilter= invoker.getUrl().getParameter("securityFilter");//value is NULL
    return invoker.invoke(invocation);
  }
}
wcy666103 commented 1 month ago

I only want to obtain the parameters of the URL in the provider's interception. Currently, I am unable to obtain custom parameters (securityFilter) in the provider's interception, but I can obtain them in the consumer's interception. Is there a problem? I am looking forward to your reply very much

CONSUMER

@DubboReference(version = "1.0.0",
            retries = 0,
            timeout=5000,
            parameters = {"securityFilter", "false","responseFilter", "true"},
            loadbalance = "roundrobin",
            check = false,
            cluster="failsafe",
            protocol = "dubbo",
            mock = "com.device.notify.api.mock.NotifyServiceApiMock")
    NotifyServiceApi notifyServiceApi;

PROVIDER

@Activate(group = {CommonConstants.PROVIDER})
public class SecurityFilter extends ListenableFilter {

  @Override
  public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
    String securityFilter= invoker.getUrl().getParameter("securityFilter");//value is NULL
    return invoker.invoke(invocation);
  }
}

I hope this helps you https://dubbo.apache.org/zh-cn/overview/tasks/develop/context