Search in sources :

Example 1 with IncidentRecord

use of io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord in project zeebe-process-test by camunda.

the class GrpcToLogStreamGateway method resolveIncident.

@Override
public void resolveIncident(final ResolveIncidentRequest request, final StreamObserver<ResolveIncidentResponse> responseObserver) {
    executor.submit(() -> {
        final Long requestId = registerNewRequest(responseObserver);
        prepareRecordMetadata().requestId(requestId).valueType(ValueType.INCIDENT).intent(IncidentIntent.RESOLVE);
        final IncidentRecord incidentRecord = new IncidentRecord();
        writeCommandWithKey(request.getIncidentKey(), recordMetadata, incidentRecord);
    });
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) IncidentRecord(io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord)

Example 2 with IncidentRecord

use of io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord in project zeebe by camunda.

the class JobBatchActivateProcessor method raiseIncidentJobTooLargeForMessageSize.

private void raiseIncidentJobTooLargeForMessageSize(final long jobKey, final JobRecord job) {
    final String messageSize = ByteValue.prettyPrint(stateWriter.getMaxEventLength());
    final DirectBuffer incidentMessage = wrapString(String.format("The job with key '%s' can not be activated because it is larger than the configured message size (%s). " + "Try to reduce the size by reducing the number of fetched variables or modifying the variable values.", jobKey, messageSize));
    final var incidentEvent = new IncidentRecord().setErrorType(ErrorType.MESSAGE_SIZE_EXCEEDED).setErrorMessage(incidentMessage).setBpmnProcessId(job.getBpmnProcessIdBuffer()).setProcessDefinitionKey(job.getProcessDefinitionKey()).setProcessInstanceKey(job.getProcessInstanceKey()).setElementId(job.getElementIdBuffer()).setElementInstanceKey(job.getElementInstanceKey()).setJobKey(jobKey).setVariableScopeKey(job.getElementInstanceKey());
    stateWriter.appendFollowUpEvent(keyGenerator.nextKey(), IncidentIntent.CREATED, incidentEvent);
}
Also used : DirectBuffer(org.agrona.DirectBuffer) IncidentRecord(io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord) BufferUtil.wrapString(io.camunda.zeebe.util.buffer.BufferUtil.wrapString)

Example 3 with IncidentRecord

use of io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord in project zeebe by camunda.

the class ExporterDirectorTest method shouldApplyRecordFilter.

@Test
public void shouldApplyRecordFilter() {
    // given
    exporters.get(0).onConfigure(withFilter(Arrays.asList(RecordType.COMMAND, RecordType.EVENT), Collections.singletonList(ValueType.DEPLOYMENT)));
    exporters.get(1).onConfigure(withFilter(Collections.singletonList(RecordType.EVENT), Arrays.asList(ValueType.DEPLOYMENT, ValueType.JOB)));
    startExporterDirector(exporterDescriptors);
    // when
    final long deploymentCommand = rule.writeCommand(DeploymentIntent.CREATE, new DeploymentRecord());
    final long deploymentEvent = rule.writeEvent(DeploymentIntent.CREATED, new DeploymentRecord());
    rule.writeEvent(IncidentIntent.CREATED, new IncidentRecord());
    final long jobEvent = rule.writeEvent(JobIntent.CREATED, new JobRecord());
    // then
    waitUntil(() -> exporters.get(1).getExportedRecords().size() == 2);
    assertThat(exporters.get(0).getExportedRecords()).extracting(Record::getPosition).hasSize(2).contains(deploymentCommand, deploymentEvent);
    assertThat(exporters.get(1).getExportedRecords()).extracting(Record::getPosition).hasSize(2).contains(deploymentEvent, jobEvent);
}
Also used : DeploymentRecord(io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord) JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) IncidentRecord(io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord) JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) Record(io.camunda.zeebe.protocol.record.Record) DeploymentRecord(io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord) IncidentRecord(io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord) Test(org.junit.Test)

Example 4 with IncidentRecord

use of io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord in project zeebe by camunda.

the class DbIncidentState method forExistingProcessIncident.

@Override
public void forExistingProcessIncident(final long elementInstanceKey, final ObjLongConsumer<IncidentRecord> resolver) {
    final long processIncidentKey = getProcessInstanceIncidentKey(elementInstanceKey);
    final boolean hasIncident = processIncidentKey != IncidentState.MISSING_INCIDENT;
    if (hasIncident) {
        final IncidentRecord incidentRecord = getIncidentRecord(processIncidentKey);
        resolver.accept(incidentRecord, processIncidentKey);
    }
}
Also used : IncidentRecord(io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord)

Example 5 with IncidentRecord

use of io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord in project zeebe by camunda.

the class IncidentStateTest method shouldNotOverwritePreviousRecord.

@Test
public void shouldNotOverwritePreviousRecord() {
    // given
    final long key = 1L;
    final IncidentRecord writtenRecord = createJobIncident();
    // when
    incidentState.createIncident(key, writtenRecord);
    writtenRecord.setJobKey(2048);
    // then
    final IncidentRecord readRecord = incidentState.getIncidentRecord(1L);
    assertThat(readRecord.getJobKey()).isNotEqualTo(writtenRecord.getJobKey()).isEqualTo(1234);
    assertThat(writtenRecord.getJobKey()).isEqualTo(2048);
}
Also used : IncidentRecord(io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord) Test(org.junit.Test)

Aggregations

IncidentRecord (io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord)61 Test (org.junit.Test)33 DeploymentRecord (io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord)6 JobRecord (io.camunda.zeebe.protocol.impl.record.value.job.JobRecord)6 ControlledTestExporter (io.camunda.zeebe.broker.exporter.util.ControlledTestExporter)3 BrokerResponse (io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse)3 ProcessInstanceRecord (io.camunda.zeebe.protocol.impl.record.value.processinstance.ProcessInstanceRecord)3 Record (io.camunda.zeebe.protocol.record.Record)3 BufferUtil.wrapString (io.camunda.zeebe.util.buffer.BufferUtil.wrapString)3 DirectBuffer (org.agrona.DirectBuffer)3 RecordMetadata (io.camunda.zeebe.protocol.impl.record.RecordMetadata)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1