pyzeebe
pyzeebe copied to clipboard
Cannot fetch Camunda job variables in pyzeebe worker
I have written a python pyzeebe worker that is supposed to interact with my database usinng the values that the variables of the previous user task in the Camunda BPMN hold. I have defined a user task with a form. I have also created a service task and defined the taskDefinition. It seems like the worker can indeed communicate with my zeebe but it is unable to fetch the variables of the form.
from pyzeebe import ZeebeWorker, Job, create_insecure_channel
import asyncio
import psycopg2
import logging
async def handle_database_transaction(job: Job) -> dict:
variables = job.variables
# Log the received variables at INFO level
logging.info(f"Received variables: {variables}")
selected_date = variables.get('selected_date')
selected_project_id = int(variables.get('selected_project_id')) if variables.get('selected_project_id') else None
# Log the extracted field values
logging.info(f"Selected date: {selected_date}, Project ID: {selected_project_id}")
# if selected_date and selected_project_id is not None, I perform the insert query with my database.
return {}
And here is the MappingIO in my BPMN:
<zeebe:ioMapping>
<zeebe:output source="=select_0swn49" target="output_project" />
<zeebe:output source="=datetime_gporzh" target="output_date" />
</zeebe:ioMapping>
<zeebe:ioMapping>
<zeebe:input source="=output_project" target="selected_project_id" />
<zeebe:input source="=output_date" target="selected_date" />
</zeebe:ioMapping>
What part of the procedure am I doing wrong?
Desktop (please complete the following information):
- OS: Windows
- Browser Chrome
- Version 120.0.6099.227
Additional context This issue seems to be raised by other before. Just making sure... https://github.com/camunda-community-hub/pyzeebe/issues/311 https://github.com/camunda-community-hub/pyzeebe/issues/315
See https://github.com/camunda-community-hub/pyzeebe/issues/315#issuecomment-1923155344