External Worker Task not available immediately after being created

Hello, we are using external worker tasks in following scenario:

  1. Listen for external worker task job. There is several ways: event listeners, external worker job interceptor. We are using afterCreateExternalJobInterctor method.
  2. After job is created we sent it to Kafka
  3. After receiving job in kafka we try to acquire and lock it (by topic of course)

It happens almost immediately but job is not available on step 3 via management service acquirer.
Adding 1 second delay before sending to kafka actually solves that problem, but it is not elegant one.

I suppose that method afterCreateExternalJobInterctor should be executed only after transaction is completed.

PS: Also tried with FlowableListener events. It is also not working if we try to send to kafka on ENTITY_CREATED or ENTITY_INITIALIZED events. Both on COMMITED/COMMITING transactions.

Hey @maratkalibek,

It seems like you are using the wrong tools for what you need to achieve.

External worker tasks are meant to be polled by the external system.

If you want to communicate over Kafka I would suggest looking into the Event Registry and using that approach.

Cheers,
Filip