-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
@SentinelResource stay controller Can use,but service can not use #1053
Comments
BlockHandlerClass is the Class object of the corresponding class. Note that the corresponding function must be a static function, otherwise it cannot be parsed. |
I tried demo here and it works.
|
Please ensure your |
You mean that the blockHandler take no effect? In controller, the method signature is But they both use |
Sorry, I know the problem because the service method does not match the parameter type of the exception method.I have another problem, because the architecture I'm working on now is spring boot + sentinel, and I'm introducing Spring cloud that relies on direct use. We also have the old project Spring mvc, which directly introduces sentinel-core package and nacos. sentinel is not available. I would like to ask if there is Spring MVC + sentinel demo, is it necessary to initialize sentinel? I look forward to your answer. Thanks very much. |
If you mean SpringMVC under containers like tomcat (which is also driven by a https://github.com/alibaba/Sentinel/wiki/Adapters-to-Popular-Framework#web-servlet |
好的,我再试试,非常感谢。 @jasonjoo2010 |
Hello, I just looked at the website below. I saw dubbo. Our framework is spring MVC + dubbo. I looked directly at this website at https://github.com/alibaba/Sentinel/wiki/Adapters-to-Popular-Framework#dubbo. I also looked at sentinel-demo-dubbo project, and did not configure sentinel address. There is no place to configure the address in demo. I look forward to your answer. Thank you very much. @jasonjoo2010 |
The adapters are designed easy to use / out-of-box. So the resource name are generated automatically base on |
Hello, Dubbo on our side is 2.5.3. I just need to introduce sentinel-dubbo-adapter dependency. I can use it out of the box without configuration initialization, right? But I found that sentinel's management platform did not have this project. @jasonjoo2010 |
Dubbo 2.5.3 is too old that See https://github.com/alibaba/Sentinel/wiki/主流框架的适配#dubbo for more information. |
You should also follow the general integration. eg. dashboard.server Refer to |
Sorry, I really don't know much about springmvc + sentinel, because I see the document that says - Dcsp. sentinel. dashboard. server = consoleIp: port after the command boot, but I want to write Dcsp. sentinel. dashboard. server in the dev-filter. properties configuration file, I normally write the address. In the configuration file, do I have to read out the Dcsp. sentinel. dashboard. server of the configuration file and put it in the initialization? That's what I imagined, because I remember you said it was out of the box before. So a little confused, I'm very sorry. @jasonjoo2010 |
Never mind and take it easy. Out-of-box hide the integrating details for specific framework. But you still need to let it know who to report / heartbeat with. Is it appeared in your dashboard sidebar now? |
Hello, I configure it by command and it appears in sentinel console. If I put it in properties, then I have to initialize @bean and get the parameters of properties in @bean, right? Thank you very much. |
Nope, it's not quite that simple if you want use |
Hello, I have another question. I'm sorry. Because I am doing (spring MVC + Dubbo + zookeeper / spring boot + Dubbo + zookeeper) + sentinel + Nacos (because our original registry is zookeeper, not nacos, Nacos is only persistent as sentinel in this area). I also need to integrate Nacos into the project to persist configuration rules and degradation rules. Is this configuration address configured with sentinel on JVM parameters? Thanks very much. |
Nope, you should do it yourself. Please refer to zookeeper version code example: |
Hello, maybe I am not very clear. Nacos is only a persistent tool for sentinel. In fact, the purpose of Nacos is equivalent to sentinel. It is only a registered and persistent tool. I mean - Dcsp. sentinel. dashboard. server = localhost: 8080, is sentinel configured like this? Is Nacos also configured like this? I want to ask these questions. |
They are not the same. Dashboard communicates with projects using http api, not |
Hello, I probably understand the difference between Nacos and sentinel, but I don't quite understand your words. I don't know exactly what to do. I'm sorry to delay you for so long.The following paragraph |
Hello, I built a demo myself. I used spring boot + sentinel + Nacos for my project, and then I introduced these two dependencies directly. Figure 1. This integrates sentinel, nacos, and configuration address Figure 2. Then I found a problem, spring MVC + sentinel, with no Nacos configuration. I added an example to the configuration list below configuration management in nacos, Figure 3. See this traffic rule in the sentinel console. The project using spring MVC did not see it. Is it because of Nacos configuration? |
So do you manage the rules by nacos console not dashboard? If so, there is only one more step in your legacy projects(SpringMVC): Register the readable data sources. |
Code snippets are like the link https://github.com/yoloho/enhanced-spring/blob/master/src/main/java/com/yoloho/enhanced/spring/support/SentinelZookeeperDataSourceInit.java But to replace the zookeeper into nacos. |
Okay, I downloaded your code and read it. I'll write it first. Thank you very much for your help during the day. I've been bothering you for so long. @jasonjoo2010 |
It's okay. If you still don't make it work you are welcome to update it. |
Hello, again, I'll change Zookeeper Writable Data Source Zookeeper to nacos, or use this, Figure 1? Because this Zookeeper Writable Data Source is used in Figure 2. |
No need. If you use Just register readable datasource in you project is enough. And readable datasource of nacos is already provided by |
Hello, thank you very much for your technical support in these two days. I have added the JSON format of process rules to the Nacos console in spring MVC + sentinel + Nacos project. I can see the configuration in the list of sentinel flow control rules. Thank you again.That's what I wrote in the project. @jasonjoo2010 |
So is the problem solved? |
Yes, it's settled. Thank you very much. @jasonjoo2010 |
👍 |
Hello, why can this annotation be used in controller, but not in service
,I found that the breakpoint in the controller would follow the invokeResourceWithSentinel method in the SentinelResourceAspect class, but the service would not follow the invokeResourceWithSentinel method.controller and service are both in one project
The text was updated successfully, but these errors were encountered: