How to create instance with start message event in JAVA

Hi everyone,

I am struggling find any examples or reference docs on how to make an instance in Java when you have a start message event?
Currently, what I am trying to do is to make an instance with no variables (because I need to reference my .bpmn file in there I believe and I cannot do it in the start message event). And then I am publishing the message:

private ZeebeClient client;

final WorkflowInstanceEvent wfInstance = client.newCreateInstanceCommand()

                                .bpmnProcessId(processId)

                                .latestVersion()

                                .send()

                                .join();

                        

                        logger.info(String.format("Successfully created zeebe workflow instance and data variable name: %s", dataVariableName));

                }

                client.newPublishMessageCommand()

                         .messageName("hello")

                         .correlationKey("")

                         .variables(data).send().join();

I get this error message:

Command 'CREATE' rejected with code 'INVALID_STATE': Expected to create instance of workflow with none start event, but there is no such event; Processor Administratively Yielded for 1 sec: io.zeebe.client.api.command.ClientStatusException: Command 'CREATE' rejected with code 'INVALID_STATE': Expected to create instance of workflow with none start event, but there is no such event

Any ideas what is going on and where to find relevant docs for this?

I got it fixed. I just commented out the instance creation (newCreateInstanceCommand).

2 Likes