[英]AWS SWF: Get worker identity in workflow implementation
I am using the AWS SWF Flow framework for Java and I would like to inject a Logentries Logger inside the workers so I can easily monitor them. 我正在使用适用于Java的AWS SWF Flow框架,我想将Logentries Logger注入工作程序中,以便我可以轻松地对其进行监视。
Right now I am instantiating a Logback logger instance in each Workflow implementation, giving it the implementation identity. 现在,我将在每个Workflow实现中实例化一个Logback记录器实例,并为其提供实现标识。 However, I also want to know which worker the implementation is running on.
但是,我也想知道实现在哪个工作程序上运行。
public class CopyWorkflowImpl implements CopyWorkflow {
private Logger log;
private CopyActivitiesClient operations = new CopyActivitiesClientImpl();
public CopyWorkflowImpl(){
//TODO: somehow get worker ID ?
log = LoggerFactory.getLogger("CopyWorkflowWorker");
}
I could see that the WorkflowWorker class has a getIdentity method exactly for that, however, I can't seem to access it inside the Workflow implementation. 我可以看到WorkflowWorker类具有恰好为此的getIdentity方法,但是,我似乎无法在Workflow实现内部访问它。 Do you have any ideas on how I could achieve that ?
您对我如何实现目标有任何想法吗?
I don't think what you're trying to do is possible, and I think it's that way by design. 我不认为您要尝试做的事是可行的,而我认为这是设计使然。 Within the context of the workflow, it shouldn't matter which specific worker picks up a task, because all workers on one task list should behave the same.
在工作流的上下文中,哪个特定的工作人员接任务无关紧要,因为一个任务列表上的所有工作人员的行为都应相同。 Outside the workflow, you can find it in the ActivityTaskStartedEventAttributes .
在工作流之外,您可以在ActivityTaskStartedEventAttributes中找到它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.