Reading the heartbeat object asynchronously

Hello,

My long running async activity generates various messages (in the form of a POJO) and ideally I would like to send them back to the workflow. I would like to get the last message and return it in the @QueryMethod of the controlling workflow for example. What is the best way to do this? I send the message using context.heartbeat(message) as my activity runs. Can I read the last heartbeat value from the workflow? Is there a better way to get activity progress reported? Or am I missing the point? I could break my activity up into parts which each represent some progress and I have done this for other workflows but in this case the activity does a lot of different mathematics and I do not want to risk breaking it, rather just send messages back about what it is doing.

Thanks,

Matt

If you just want to return the latest value of the heartbeat use DescribeWorkflowExecution API call. Among other data the result of this call includes the list of pending activities which includes the heartbeat data for each activity.

Here is a code that executes that API.