Search in sources :

Example 1 with ProcessInstanceCreationRecord

use of io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord in project zeebe by camunda.

the class UniqueKeyFormatTest method shouldStartProcessInstanceAtNoneStartEvent.

// todo: this does not need to be an integration test if the only test is that the partitionId is
// encoded in the key
@Test
public void shouldStartProcessInstanceAtNoneStartEvent() {
    // given
    apiRule.partitionClient().deploy(Bpmn.createExecutableProcess("process").startEvent("foo").endEvent().done());
    // when
    TestUtil.waitUntil(() -> RecordingExporter.deploymentRecords().withPartitionId(2).exists());
    final ProcessInstanceCreationRecord processInstanceWithResponse = apiRule.partitionClient(2).createProcessInstance(r -> r.setBpmnProcessId("process"));
    // then partition id is encoded in the returned getKey
    final long key = processInstanceWithResponse.getProcessInstanceKey();
    final int partitionId = Protocol.decodePartitionId(key);
    assertThat(partitionId).isEqualTo(2);
}
Also used : ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord) Test(org.junit.Test)

Example 2 with ProcessInstanceCreationRecord

use of io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord in project zeebe by camunda.

the class ClusteringRule method createProcessInstanceOnPartition.

public long createProcessInstanceOnPartition(final int partitionId, final String bpmnProcessId) {
    final BrokerCreateProcessInstanceRequest request = new BrokerCreateProcessInstanceRequest().setBpmnProcessId(bpmnProcessId);
    request.setPartitionId(partitionId);
    final BrokerResponse<ProcessInstanceCreationRecord> response = gateway.getBrokerClient().sendRequestWithRetry(request).join();
    if (response.isResponse()) {
        return response.getResponse().getProcessInstanceKey();
    } else {
        throw new RuntimeException("Failed to create process instance for bpmn process id " + bpmnProcessId + " on partition with id " + partitionId + ": " + response);
    }
}
Also used : ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord) BrokerCreateProcessInstanceRequest(io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest)

Example 3 with ProcessInstanceCreationRecord

use of io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord in project zeebe by camunda.

the class PartitionTestClient method createProcessInstance.

public ProcessInstanceCreationRecord createProcessInstance(final ProcessInstanceCreationRecord record) {
    final ExecuteCommandResponse response = executeCommandRequest(ValueType.PROCESS_INSTANCE_CREATION, ProcessInstanceCreationIntent.CREATE, record);
    assertThat(response.getRecordType()).isEqualTo(RecordType.EVENT);
    assertThat(response.getIntent()).isEqualTo(ProcessInstanceCreationIntent.CREATED);
    return response.readInto(new ProcessInstanceCreationRecord());
}
Also used : ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord)

Example 4 with ProcessInstanceCreationRecord

use of io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord in project zeebe-process-test by camunda-cloud.

the class GrpcToLogStreamGateway method createProcessInstanceWithResult.

@Override
public void createProcessInstanceWithResult(final CreateProcessInstanceWithResultRequest request, final StreamObserver<CreateProcessInstanceWithResultResponse> responseObserver) {
    final Long requestId = gatewayRequestStore.registerNewRequest(request.getClass(), responseObserver);
    final RecordMetadata recordMetadata = prepareRecordMetadata().requestId(requestId).valueType(ValueType.PROCESS_INSTANCE_CREATION).intent(ProcessInstanceCreationIntent.CREATE_WITH_AWAITING_RESULT);
    final ProcessInstanceCreationRecord processInstanceCreationRecord = createProcessInstanceCreationRecord(request.getRequest());
    processInstanceCreationRecord.setFetchVariables(request.getFetchVariablesList());
    writer.writeCommandWithoutKey(processInstanceCreationRecord, recordMetadata);
}
Also used : RecordMetadata(io.camunda.zeebe.protocol.impl.record.RecordMetadata) ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord)

Example 5 with ProcessInstanceCreationRecord

use of io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord in project zeebe-process-test by camunda-cloud.

the class GrpcToLogStreamGateway method createProcessInstanceCreationRecord.

private ProcessInstanceCreationRecord createProcessInstanceCreationRecord(final GatewayOuterClass.CreateProcessInstanceRequest request) {
    final ProcessInstanceCreationRecord processInstanceCreationRecord = new ProcessInstanceCreationRecord();
    processInstanceCreationRecord.setBpmnProcessId(request.getBpmnProcessId());
    processInstanceCreationRecord.setVersion(request.getVersion());
    processInstanceCreationRecord.setProcessDefinitionKey(request.getProcessDefinitionKey());
    final String variables = request.getVariables();
    if (!variables.isEmpty()) {
        processInstanceCreationRecord.setVariables(BufferUtil.wrapArray(MsgPackConverter.convertToMsgPack(variables)));
    }
    return processInstanceCreationRecord;
}
Also used : ProcessInstanceCreationRecord(io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord)

Aggregations

ProcessInstanceCreationRecord (io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceCreationRecord)29 Test (org.junit.Test)9 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)6 BrokerCreateProcessInstanceRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest)6 DeployedProcess (io.camunda.zeebe.engine.state.deployment.DeployedProcess)3 BrokerCreateProcessInstanceWithResultRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceWithResultRequest)3 CreateProcessInstanceRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceRequest)3 CreateProcessInstanceResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceResponse)3 CreateProcessInstanceWithResultRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CreateProcessInstanceWithResultRequest)3 RecordMetadata (io.camunda.zeebe.protocol.impl.record.RecordMetadata)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2