Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ TOKEN=$(curl -s --location --request POST 'http://localhost:18080/auth/realms/ca
--data-urlencode 'grant_type=client_credentials' | jq -r .access_token)

echo "Get the task list"
IDLIST=$(curl -X POST \
IDLIST=$(curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"state":"CREATED","sort":[{"field": "creationTime", "order": "ASC"}], "pageSize":200}' \
'http://localhost:8082/v1/tasks/search' | jq -r '.[].id')

echo -n "Number of tasks to complete: "
printf '%s' "$IDLIST" | jq -Rsc 'split("\n") | map(select(length>0)) | length'

echo "Complete the tasks"
while ID= read -r item; do
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d '{"variables": {"errorResolved": false}}' "http://localhost:8088/v2/user-tasks/$item/completion";
Expand Down
12 changes: 6 additions & 6 deletions payment-example-process-application/kube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,21 +354,21 @@ The script executes a Tasklist query, so it requires to grant the payment-app cl

The secret for the payment-app client will be read from the environment variable `CLIENT_SECRET`, that [is already set above](#2-deploying-the-application).

#### 2. Complete Multiple User Tasks by Kubernetes Job
#### 2. Complete User Tasks Every Day with a Kubernetes Cronjob

The folder `kube/manifest` contains a job to complete up to 200 User Tasks setting the `Error resolved?` variable to false and end the process instances.
The Cronjob `kube/manifest/complete-usertask-cronjob.yaml` starts every day at 10:25 to complete 4400 User tasks.

The script executes a Tasklist query, so it requires to grant the payment-app client `read:*` access to the Tasklist API.

The secret for the payment-app will be read from the existing Kubernetes secret.

After starting the job with `kubectl -n c8-payment-demo apply -f complete-usertasks-job.yaml`, it must be deleted with `kc -n c8-payment-demo delete jobs.batch complete-usertasks` to start it again later.
It gets the oldest 200 tasks from with a Tasklist query and completes them with setting the `Error resolved?` variable to false and end the process instances.

#### 3. Complete User Tasks Every Day
The logs will be saved for the last 14 days. Set it up with `kubectl -n c8-payment-demo apply -f complete-usertasks-cronjob.yaml`.

The Cronjob `kube/manifest/complete-usertask-cronjobs.yaml` starts every day at 10:25 to complete 4400 User tasks. The job runs about 1 hour. The logs will be saved for the last 14 days. Set it up with `kubectl -n c8-payment-demo apply -f complete-usertasks-cronjob.yaml`.
Trigger the cronjob immediately with the command `kc -n c8-payment-demo create job --from cronjob/complete-usertasks complete-usertasks-manual-<date>>`.

#### 4. Run the Complete User Tasks Process
#### 3. Run the Complete User Tasks Process

The BPMN Diagram `complete-usertasks/complete-user-tasks.bpmn` reads open user tasks from the Tasklist API and completes all tasks in a multi-instance service task. Both tasks use the REST connector and require secrets configured in the connectors deployment.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ spec:
apk add --no-cache jq

I=0
while [ $I -lt 22 ]; do
ROUNDS=22
while [ $I -lt $ROUNDS ]; do
echo $I
I=$((I + 1))
echo 'Get the token'
Expand All @@ -42,11 +43,14 @@ spec:
--data-urlencode 'grant_type=client_credentials' | jq -r .access_token)

echo 'Get the task list'
IDLIST=$(curl -X POST \
IDLIST=$(curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d "{\"state\":\"CREATED\",\"sort\":[{\"field\": \"creationTime\", \"order\": \"ASC\"}], \"pageSize\":200}" \
"http://camunda-tasklist.camunda.svc.cluster.local/v1/tasks/search" | jq -r '.[].id')

echo -n "Number of tasks to complete: "
printf '%s' "$IDLIST" | jq -Rsc 'split("\n") | map(select(length>0)) | length'

echo "Complete the tasks"
for item in $IDLIST; do
Expand All @@ -55,6 +59,11 @@ spec:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" -d "{\"variables\": {\"errorResolved\": false}}" \
"${URL}" -s;
done

if [ $I -lt $ROUNDS ]; then
echo "Waiting 30 s for the next round"
sleep 30
fi

done
securityContext:
Expand Down

This file was deleted.