How get the currently running activity instance of the process definition of camunda - camunda

I am a new for camunda.
I want cancel the currently running activity instance and start a new activity instance for move the token state.
But I got a hard time of how get the currently running activity instance id by the java api of camunda.
Any thougs ? Thank you all.

Actully the question is "How get the running activity instances". And I already got the answer from somewhere.
Here is the aswer.
Just use the java api like below
ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getProcessInstanceId());
ActivityInstance[] activityInstances = activityInstance.getChildActivityInstances();
The activityInstances array is the running activity instances. you can use the ids of the activity instances to cancel running activity instance.

Had the same trouble. This line returns a list of ids (whatever they are - user task, service task, and etc). If you don't have parallel active tasks - the list will contain a single activity id.
processEngine.getRuntimeService().getActiveActivityIds(
processInstance.getProcessInstanceId()
);

Related

Camunda process versioning using "Process Instance Modification" migrate call activities

In our project we have problem with camunda process versioning.
We have read some guides and decided to use Process Instance Modification over Process Instance Migration due to limitations that the last approach has.
As we see Process Instance Migration does not allow us to change current variables (based on their previous value, and current wait point we stay), sometimes we only want to change variables because we change delegate executions code and we know that business model (BPMN) haven't bean changed.
So currently I am trying to develop migration framework based on Process Instance Modification.
And first issue I encounter is:
How properly migrate process instance which currently stays on wait point in Call Activity?
For example, I have process:
I start it. One exectuions stays on wait point before Message 1 event. Another gets into Call activity:
And stays there before Message 3 and Message 4.
By using Process Instance Modification I stop processes in Call Activity and then start them again (changing variables, and bpmn model to the latest). How can I attach them to the parent process instance which called Call activity in the first place, to make it return back to the parent process instance (which called Call activity) and proceed with processing (executing Task 6). What if I want to migrate parent process as well?

Fetching currently executing tasks for a flow

We just started with camunda and looking for api which can give us all tasks which are currently getting executed. I know that it does provide state information like PENDING and COMPLETED but I am particularly interested in "EXECUTING" state. Is there a way to find it? Is it safe to assume that if task is not in COMPLETED/ERROR and PENDING state, then it is getting executed?
note: using camunda 7.9.0 - Jboss packaging
Assuming that you are talking about user tasks, the safest way is to perform a claim() on the task when a user starts working.
Then you can assume that every task that has an assignee is currently being worked on.

uknown reason for google cloud compute engine VM shutdown?

One of the vm instances on google cloud compute was shutdown, with an event log in stackdriver without ip or actor (user or service or system) which initiated the event. The instance has onHostMaintenance set to migrate and automaticRestart set to true. This particular instance has migrated on maintenance without error before. The stackdriver event log looks like
{
actor: {
user: ""
},
event_subtype: "compute.instances.stop",
event_timestamp_us: "1531781734907624",
event_type: "GCE_API_CALL",
ip_address: "",
}
The user and ip_address fields are NOT redacted. They have empty values on actual log.
is this common? how does one identify the cause for shutdown in these peculiar cases ?
According to your event type, I dive in the doc of Activity logs,
Compute Engine API calls - GCE_API_CALL events are API calls that change the state of a resource.
It seems like someone may use API calls to shutdown your VM. Looking your settings and logs on the VM instance, it can't be a hostError or Maintenance event. As far as you turn on the onHostMaintenance set to migrate and automaticRestart set to true. Your VM will always be migrated to another hardware.
Out of curiosity, did you restart your VM? did it shutdown again? How often does it happen?
Seems like app engine had an outage during that time, incident .

(AWS SWF) Is there a way to get a list of all activity workers listening on a particular tasklist?

In our beta stack, we have a single EC2 instance listening to a tasklist. Sometimes another developer in the team start's his own instance for testing purposes and forget to turn it off. This creates problems for the next developer who tries to start an activity only for it to be taken up by the last developer's machine. Is there a way to get the hostnames of all activity workers listening to a particular tasklist ?
It is not currently possible to get a list of pollers waiting on a task list through the SWF API. The workaround is to look at the identity field on the ActivityExecutionStarted event after it was picked up by the wrong worker.
One way to avoid this issue is always use a task list name that is specific to a machine or developer to avoid collisions.

aws swf - get workflow execution id from within the workflow

I am using Amazon SWF service to automate some recurring tasks.
I am trying to use signals to execute some commands on remote machines. After the commands are finished executing, I'd like to send a signal back to the workflow to indicate success or failure.
The question is how can I find the workflow execution id programmatically? This is required for the remote machines to send a signal.
Thanks
Per http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/SimpleWorkflow/WorkflowExecution.html, shouldn't
your_workflow_execution_variable.run_id
get you exactly what you're looking for?