Camunda Rest API: Cannot fetch and lock an External Task for a Tenant - camunda

I have a Process Instance that was started by the Tenant 949.
I tried to fetch and lock that Task, like described here: https://docs.camunda.org/manual/7.10/reference/rest/external-task/fetch/
Here is the Body of the Request:
{"workerId":"testUser","maxTasks":1,"usePriority":false,
"topics":[
{"topicName":"archive-document","tenantIdIn":["949"],"lockDuration":10000,"localVariables":true,"deserializeValues":false}
]}
I don't get any Task with it.
The same request works if the Process Instance is started without a Tenant and fetched accordingly.
Do I miss something, or is this a Bug of Camunda?

Have you attempted to simply do a query to first retrieve the task? (Rather than attempting to fetch it and lock it?) You could use this endpoint: https://docs.camunda.org/manual/7.10/reference/rest/external-task/get-query/.
You may also want to query the runtime database directly using SQL. Your External Task would be in the ACT_RU_EXT_TASK table and would have a TOPIC_NAME_ defined within it (as well as a TENANT_ID_).

The problem was the Authentication.
I had a different User to start the process and to fetch the Task.
And this User had no rights to fetch the Task for this Tenant.

Related

WSO2 IS - POST_DELETE_USER error while deleting user from IS

We have installed WSO2AM 2.6.0 with IS as KM (5.7). We deployed AM as an active-active all in one instance and IS as KM active-active too following all the directives written on the Official documentation.
Based on the documentation, we created the following databases with their respectives datasources: regdb (registry), carbondb, userdb (user store), mb-store, apimdb.
The issue that we have now is on IS side. We tried several things to check that everything was working correctly, like create users, check registry acces etc. We created a user called "test", chaged some properties, etc and after that, we proceed to delete the user.
When we deleted the user we get the following popup on the IS console:
Checking the logs we find the following:
Caused by: org.postgresql.util.PSQLException: ERROR: relation "cm_receipt" does not exist
Position: 135
TID: [-1234] [] [2020-05-11 09:00:30,062] ERROR {org.wso2.carbon.user.mgt.ui.UserAdminClient} - Error when handling event : POST_DELETE_USER
org.wso2.carbon.user.mgt.stub.UserAdminUserAdminException: UserAdminUserAdminException
We checked on the database and the user was deleted correctly and IS carbon console is not displaying it any more, so the user was correctly deleted. Checking a little bit more, the Delete user process is trying to access table "cm_receipt" on carbondb, but the table exists on apimdb.
On postgres side, we have this log during the delete:
<2020-05-08 11:49:50.452 -03:172.19.35.21(45740):wso2carbon#carbondb:[12476]:>ERROR: relation "cm_receipt" does not exist at character 135
<2020-05-08 11:49:50.452 -03:172.19.35.21(45740):wso2carbon#carbondb:[12476]:>STATEMENT: SELECT R.CONSENT_RECEIPT_ID, R.LANGUAGE, R.PII_PRINCIPAL_ID, R.PRINCIPAL_TENANT_ID, R.STATE,RS.SP_DISPLAY_NAME,RS.SP_DESCRIPTION FROM CM_RECEIPT R INNER JOIN CM_RECEIPT_SP_ASSOC RS ON R.CONSENT_RECEIPT_ID=RS.CONSENT_RECEIPT_ID WHERE PII_PRINCIPAL_ID LIKE $1 AND PRINCIPAL_TENANT_ID =$2 AND SP_NAME LIKE $3 AND STATE LIKE $4 ORDER BY ID ASC LIMIT $5 OFFSET $6
Have you got any idea why it can be happening? There is some bug related or something?
Thanks!
There could be two reasons for this.
You've forgot to execute the D script which contains the consent management tables. /wso2is-5.7.0/dbscripts/consent/postgresql.sql.
Your wso2is-5.7.0/repository/conf/consent-mgt-config.xml configuration file is referring to the wrong datasource.
Solution
Check what's the datasource that the consent-mgt-config.xml file is referring to. By default it's like this.
<ConsentManager xmlns="http://wso2.org/carbon/consent/management" xmlns:svns="http://org.wso2.securevault/configuration">
<DataSource>
<!-- Include a data source name (jndiConfigName) from the set of data sources defined in master-datasources
.xml -->
<Name>jdbc/WSO2IdentityDB</Name>
</DataSource>
Here, it's the jdbc/WSO2IdentityDB. Then go to your wso2is-5.7.0/repository/conf/datasources/master-datasource.xml file and check the database of that datasource. If the mentioned tables are not created in that database you can execute the above mentioned postgre.sql script in that database. (If you've already created these tables in a different datasource, you might want to change the datasource defined in the consent-mgt-config.xml file.)
P.S. Never use -Dsetup argument for automatic executions of database scripts on the startup. Always manually execute the database scripts against the database.
P.S. The reason for the user deletion success is that this user consent removal process being a POST_USER_DELETION event. A failure in a POST handler won't effect the action itself.

AWS Appsync subscription is not updating my component

I've cloned a repo from here and trying to explore AWS AppSync's subscription. My understanding is that if there is real-time updates to server data, client should expect to see some notification or updates or sorts, so what I did was:
running the app on a simulator
Open DynamoDB console and add the records manually.
I was expecting there is some notifications received on my app but there isn't, and if I refresh the app it will have the updated records? Am I understand the subscription wrongly?
Subscriptions are not triggered from your dynamo db, but from your mutations (defined in your graphql schema). Try to add records via the mutation your subscription listens on. You can run a mutation from the app sync console under "queries".
If your client is set up correctly, it should update accordingly.
Hope this helps :)
Subscription can only be triggered by mutation. When you add record directly to your DB, the mutation is not called hence no subscription is triggered. Does not really servers the purpose for the external db updates. There is work around available.
Scenario 1: If you are making the change to the DB directly via some DB client, you need to call the mutation endpoint explicitly (from AWS console, postman etc.). This will trigger the subscription. I am guessing the direct DB change is done for testing.
Scenario 2: The direct DB change is done by some other external process and not via Appsync mutation. You need to call the none data source mapped mutation in your processor. This dummy mutation will trigger the subscription.
Here's [a link] (https://aws.amazon.com/premiumsupport/knowledge-center/appsync-notify-subscribers-real-time/ ) explaining how to create a none data source mapped mutation.

Tenant ID setting in case of "startBeforeActivity"

ENV: Camunda 7.5
Approach: Single Process Engine With Tenant-Identifiers with Transparent Access Restrictions for Tenants
Given: foo is a process definition key which is deployed without tenant ID, i.e. shared process among all tenants. bar is the ID of a service task within foo.
The TenantIdProvider works well if one start process instances normally (startXXX or startXXXByMessage). For test cases which don't start process instances this way, rather with:
runtimeService.createProcessInstanceByKey('foo')
.startBeforeActivity('bar')
.execute()
the tenant ID doesn't get set. Maybe someone can point out why and how. Thanks!
Not implemented yet. See also: https://app.camunda.com/jira/browse/CAM-6218

How can I write data about process assignees to database

I use camunda 7.2.0 and i'm not very experienced with it. I'm trying to write data about users, who had done something with process instance to database (i'm using rest services) to get some kind of reports later. The problem is that i don't know how to trigger my rest(that sends information to datebase about current user and assignee) when user assignes task to somebody else or claims task to himself. I see that camunda engine sends request like
link: engine/engine/default/task/5f965ab7-e74b-11e4-a710-0050568b5c8a/assignee
post: {"userId":"Tom"}
As partial solution I can think about creating a global variable "currentUser" and on form load check if user is different from current, and if he is - run the rest and change variable. But this solution don't looks correct to me. So is there any better way to do it? Thanks in advance
You could use a task listener which updates your data when the assignee of a task is changed. If you want this behavior for every task you could define a global task listener.

How to get all the Open Graph Beta actions generated by an app?

It is already possible to get all actions for custom app actions and objects:
https://graph.facebook.com/me/{appNameSpace}:{action}/{object}
This will list all the actions generated by an app, but only for a given user...
How do I get all the actions generated by an app (for all its users)?
I've tried this request with an app access token :
https://graph.facebook.com/{appId}/{appNameSpace}:{action}/{object}
But it does not work...
I was also looking for an activities or actions FQL table, since each action has an id, they should be accessible somewhere.
Any suggestions?
AFAIK there is no way to get all actions published by application via OpenGraph, but your application creates those actions, why just not record results of this operation?
Then you create action you should get response like this:
{
id: “{action-instance-id}”
}
Later you may read this action:
GET https://graph.facebook.com/{action-instance-id}
You for sure may benefit from doing request to get multiple actions like this:
GET https://graph.facebook.com/?ids={action-id1},{action-id2},{action-idn}
And even batch those requests