hystrixCommand 注释 - commandKey 的用途是什么
hystrixCommand annotation - what is purpose of commandKey
使用 spring 的 Hystrix 注释 described here
我想知道 commandKey 参数是什么。在以下上下文中,我想知道此参数的含义:
@HystrixCommand(groupKey="UserGroup", commandKey = "GetUserByIdCommand")
public User getUserById(String id) {
return userResource.getUserById(id);
}
注意这里的commandKey定义为GetUserByIdCommand,这跟线程池有关系吗?这是否意味着任何具有该命令键的东西都使用相同的线程池,如果是这样,这是否意味着它的良好做法是我使用故障回复的每个方法都有自己的命令键?
我有大约 8 个 class 我想在其中注释方法。我将用这个注释一些 class 方法,但我想知道如何构建 commandKeys ?我应该使用所有相同的,还是每个 class 相同或所有唯一的等等
终于找到答案了。 CommandKey 用于.
By default the name of command key is command method name: For
example , getUserById but you can rename it to getUserByIdCommand
然后就可以在hystrix命令中使用commandKey来引用方法了。如果您不使用 commandKey(可选)。然后方法名称用作默认值。所以它只是重命名命令。
我找到了所有这些信息here
commandKey跟线程池有关系吗?
HystrixCommand is used for monitoring, circuit-breakers, metrics publishing, caching and other such uses.
It has nothing to do with thread pool.
通常每个 CommandGroupKey 都有自己的线程池,因此任何一组命令都不会使其他命令无法执行 运行。可以通过注入 ThreadPoolKey 显式地为 HystrixCommand 配置线程池。默认 CommandGroupKey 是 class 注释方法的名称。
如何构造命令键?
默认情况下,Commandkey 的名称是命令方法名称,在您的情况下,它是 getUserById。
You don't have to specify a CommandKey unless you want a different name for the command.
使用 spring 的 Hystrix 注释 described here
我想知道 commandKey 参数是什么。在以下上下文中,我想知道此参数的含义:
@HystrixCommand(groupKey="UserGroup", commandKey = "GetUserByIdCommand")
public User getUserById(String id) {
return userResource.getUserById(id);
}
注意这里的commandKey定义为GetUserByIdCommand,这跟线程池有关系吗?这是否意味着任何具有该命令键的东西都使用相同的线程池,如果是这样,这是否意味着它的良好做法是我使用故障回复的每个方法都有自己的命令键?
我有大约 8 个 class 我想在其中注释方法。我将用这个注释一些 class 方法,但我想知道如何构建 commandKeys ?我应该使用所有相同的,还是每个 class 相同或所有唯一的等等
终于找到答案了。 CommandKey 用于.
By default the name of command key is command method name: For example , getUserById but you can rename it to getUserByIdCommand
然后就可以在hystrix命令中使用commandKey来引用方法了。如果您不使用 commandKey(可选)。然后方法名称用作默认值。所以它只是重命名命令。
我找到了所有这些信息here
commandKey跟线程池有关系吗?
HystrixCommand is used for monitoring, circuit-breakers, metrics publishing, caching and other such uses.
It has nothing to do with thread pool.
通常每个 CommandGroupKey 都有自己的线程池,因此任何一组命令都不会使其他命令无法执行 运行。可以通过注入 ThreadPoolKey 显式地为 HystrixCommand 配置线程池。默认 CommandGroupKey 是 class 注释方法的名称。
如何构造命令键?
默认情况下,Commandkey 的名称是命令方法名称,在您的情况下,它是 getUserById。
You don't have to specify a CommandKey unless you want a different name for the command.