Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
tom055 opened this issue Oct 29, 2024 · 3 comments
Open
4 tasks done

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

tom055 opened this issue Oct 29, 2024 · 3 comments
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage

Comments

@tom055
Copy link

tom055 commented Oct 29, 2024

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar issues.

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?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@tom055 tom055 added component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage labels Oct 29, 2024
@AlbumenJ
Copy link
Member

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
Copy link
Author

tom055 commented Oct 30, 2024

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage
Projects
Status: Todo
Development

No branches or pull requests

3 participants