Closed marcelloti closed 4 years ago
For checking if it's already deployed currently I am doing this:
async function checkIfProcessExists(zb, processId) {
let processExists = true;
try {
await zb.createWorkflowInstance({
bpmnProcessId: processId,
version: 0, // Putting version equals to zero in here apparently does nothing in "createWorkflowInstance" command
});
} catch (err) {
processExists = false;
}
return processExists;
}
[Edit]: "version: 0" it does something... So, it is not a solution...
Zeebe prior to 0.18 had an API to listDeployedWorkflows, but it was removed.
I usually deploy on startup. Restarting a broker can cause that to be a problem, because you need to restart your client app to redeploy.
I have also dealt with it using something like this:
// Have to verify that this is how you test for this error
const notDeployed = err => err.message.indexOf('5:') === 0
function createWorkflowInstance(bpmnProcessId, variables) {
return zbc.createWorkflowInstance(bpmnProcessId, variables)
.catch(err => notDeployed(err) ?
deploy(bpmnProcessId).then(() => doIt(bpmnProcessId, variables)) :
throw new Error(err))
}
function deploy(bpmnProcessId) {
// Lookup your resources
const model = ModelRepository.get(bpmnProcessId)
return zbc.deployWorkflow(model.filename)
}
Hum... interesting... So, currently, for because some bug or update in broker container, if I had to restart the broker, I really need to redeploy all workflows ? I actually have notice this behaviour on zeebe monitor (all workflows dissapear) but I was thinking that was a bug/behaviour of Zeebe Monitor (not Zeebe). Actually, I already have been tested this scenario:
Anyway... there is a plan to reimplement the API (like in 0.18 version) in the future?
Anyway... there is a plan to reimplement the API (like in 0.18 version) in the future?
No.
Simple Monitor stores its data in an in-memory H2 database, so restarting the container/app loses everything.
Zeebe stores the Event Log and a projection of the current state on disk, and rebuilds the current state on restart.
So... there really isn't a way I can use to "read" the Zeebe broker event log (even if I manually create code to read the contents of the "data" directory - for example ...), right ?
The easiest way to do it is to run Elastic Search and the Elastic Search exporter, then query Elastic Search.
Have a look at https://github.com/zeebe-io/zeebe-docker-compose and hit up https://forum.zeebe.io if you have more questions about it.
This can be useful for checking if an workflow it's already deploy - by id or name:
Something like this: const deployedWorkflows = await ZbClient.WorkflowList();