AWS SWF: Get worker identity in workflow implementation

441 views Asked by At

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.

Right now I am instantiating a Logback logger instance in each Workflow implementation, giving it the implementation identity. 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. Do you have any ideas on how I could achieve that ?

1

There are 1 answers

1
LiVi On BEST ANSWER

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.