alibaba / alibaba/Sentinel

Flow control by caller in Dubbo | Dubbo 根据调用方限流

Open
#2,737 0 comments 0 reactions 0 assignees View on GitHub
area/integrations kind/question
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Sentinel Dubbo Adapter 实现了一个 Filter 用于自动从 consumer 端向 provider 端透传 application name

请问这个 filter 的实现是 com.alibaba.csp.sentinel.adapter.dubbo.DubboAppContextFilter 这个类吗?

### debug了一下这个类,效果是消费者把生产者的 dubboApplication 封装到attachment中

```java
package com.alibaba.csp.sentinel.adapter.dubbo;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.RpcException;

import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER;

/**
* Puts current consumer's application name in the attachment of each invocation.
*
* @author Eric Zhao
*/
@Activate(group = CONSUMER)
public class DubboAppContextFilter implements Filter {

@Override
public Result invoke(Invoker invoker, Invocation invocation) throws RpcException {
String application = invoker.getUrl().getParameter(CommonConstants.APPLICATION_KEY);
if (application != null) {
RpcContext.getContext().setAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, application);
}
return invoker.invoke(invocation);
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reading com.alibaba.csp.sentinel.adapter.dubbo.DubboAppContextFilter and the surrounding Sentinel Dubbo adapter code, then trace how the consumer application name is placed in the invocation attachment. Clarify the expected caller-based flow-control behavior and acceptance criteria before changing the adapter.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.