Search in sources :

Example 1 with MessageIntent

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

the class MessageImporter method importMessage.

public void importMessage(final Schema.MessageRecord record) {
    final MessageIntent intent = MessageIntent.valueOf(record.getMetadata().getIntent());
    final long key = record.getMetadata().getKey();
    final long timestamp = record.getMetadata().getTimestamp();
    final MessageEntity entity = messageRepository.findById(key).orElseGet(() -> {
        final MessageEntity newEntity = new MessageEntity();
        newEntity.setKey(key);
        newEntity.setName(record.getName());
        newEntity.setCorrelationKey(record.getCorrelationKey());
        newEntity.setMessageId(record.getMessageId());
        newEntity.setPayload(record.getVariables().toString());
        return newEntity;
    });
    entity.setState(intent.name().toLowerCase());
    entity.setTimestamp(timestamp);
    messageRepository.save(entity);
}
Also used : MessageEntity(io.zeebe.monitor.entity.MessageEntity) MessageIntent(io.camunda.zeebe.protocol.record.intent.MessageIntent)

Aggregations

MessageIntent (io.camunda.zeebe.protocol.record.intent.MessageIntent)1 MessageEntity (io.zeebe.monitor.entity.MessageEntity)1