Search in sources :

Example 1 with MessageSubscriptionEntity

use of io.zeebe.monitor.entity.MessageSubscriptionEntity in project zeebe-simple-monitor by camunda-community-hub.

the class MessageSubscriptionImporter method importMessageSubscription.

public void importMessageSubscription(final Schema.MessageSubscriptionRecord record) {
    final MessageSubscriptionIntent intent = MessageSubscriptionIntent.valueOf(record.getMetadata().getIntent());
    final long timestamp = record.getMetadata().getTimestamp();
    final MessageSubscriptionEntity entity = messageSubscriptionRepository.findByElementInstanceKeyAndMessageName(record.getElementInstanceKey(), record.getMessageName()).orElseGet(() -> {
        final MessageSubscriptionEntity newEntity = new MessageSubscriptionEntity();
        newEntity.setId(// message subscription doesn't have a key - it is always '-1'
        generateId());
        newEntity.setElementInstanceKey(record.getElementInstanceKey());
        newEntity.setMessageName(record.getMessageName());
        newEntity.setCorrelationKey(record.getCorrelationKey());
        newEntity.setProcessInstanceKey(record.getProcessInstanceKey());
        return newEntity;
    });
    entity.setState(intent.name().toLowerCase());
    entity.setTimestamp(timestamp);
    messageSubscriptionRepository.save(entity);
}
Also used : MessageSubscriptionEntity(io.zeebe.monitor.entity.MessageSubscriptionEntity) MessageSubscriptionIntent(io.camunda.zeebe.protocol.record.intent.MessageSubscriptionIntent)

Example 2 with MessageSubscriptionEntity

use of io.zeebe.monitor.entity.MessageSubscriptionEntity in project zeebe-simple-monitor by camunda-community-hub.

the class MessageSubscriptionImporter method importMessageStartEventSubscription.

public void importMessageStartEventSubscription(final Schema.MessageStartEventSubscriptionRecord record) {
    final MessageStartEventSubscriptionIntent intent = MessageStartEventSubscriptionIntent.valueOf(record.getMetadata().getIntent());
    final long timestamp = record.getMetadata().getTimestamp();
    final MessageSubscriptionEntity entity = messageSubscriptionRepository.findByProcessDefinitionKeyAndMessageName(record.getProcessDefinitionKey(), record.getMessageName()).orElseGet(() -> {
        final MessageSubscriptionEntity newEntity = new MessageSubscriptionEntity();
        newEntity.setId(// message subscription doesn't have a key - it is always '-1'
        generateId());
        newEntity.setMessageName(record.getMessageName());
        newEntity.setProcessDefinitionKey(record.getProcessDefinitionKey());
        newEntity.setTargetFlowNodeId(record.getStartEventId());
        return newEntity;
    });
    entity.setState(intent.name().toLowerCase());
    entity.setTimestamp(timestamp);
    messageSubscriptionRepository.save(entity);
}
Also used : MessageStartEventSubscriptionIntent(io.camunda.zeebe.protocol.record.intent.MessageStartEventSubscriptionIntent) MessageSubscriptionEntity(io.zeebe.monitor.entity.MessageSubscriptionEntity)

Aggregations

MessageSubscriptionEntity (io.zeebe.monitor.entity.MessageSubscriptionEntity)2 MessageStartEventSubscriptionIntent (io.camunda.zeebe.protocol.record.intent.MessageStartEventSubscriptionIntent)1 MessageSubscriptionIntent (io.camunda.zeebe.protocol.record.intent.MessageSubscriptionIntent)1