Search in sources :

Example 1 with JobIntent

use of io.camunda.zeebe.protocol.record.intent.JobIntent in project zeebe-simple-monitor by camunda-community-hub.

the class JobImporter method importJob.

public void importJob(final Schema.JobRecord record) {
    final JobIntent intent = JobIntent.valueOf(record.getMetadata().getIntent());
    final long key = record.getMetadata().getKey();
    final long timestamp = record.getMetadata().getTimestamp();
    final JobEntity entity = jobRepository.findById(key).orElseGet(() -> {
        final JobEntity newEntity = new JobEntity();
        newEntity.setKey(key);
        newEntity.setProcessInstanceKey(record.getProcessInstanceKey());
        newEntity.setElementInstanceKey(record.getElementInstanceKey());
        newEntity.setJobType(record.getType());
        return newEntity;
    });
    entity.setState(intent.name().toLowerCase());
    entity.setTimestamp(timestamp);
    entity.setWorker(record.getWorker());
    entity.setRetries(record.getRetries());
    jobRepository.save(entity);
}
Also used : JobEntity(io.zeebe.monitor.entity.JobEntity) JobIntent(io.camunda.zeebe.protocol.record.intent.JobIntent)

Aggregations

JobIntent (io.camunda.zeebe.protocol.record.intent.JobIntent)1 JobEntity (io.zeebe.monitor.entity.JobEntity)1