Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 1.08 KB

causation_metadata_enricher.md

File metadata and controls

26 lines (18 loc) · 1.08 KB

Causation Metadata Enricher

If the dispatched command is an instance of Prooph\Common\Messaging\Message the transaction manager will also add causation metadata to each recorded event during the transaction. Two entries are added to the metadata:

  • causation_id = $command->uuid()->toString()
  • causation_name = $command->messageName().

Set Up

The CausationMetadataEnricher is a dual plugin, it's a plugin for event-store as well as for the message-bus.

$causationMetadataEnricher = new CausationMetadataEnricher();
$causationMetadataEnricher->attachToEventStore($eventStore);
$causationMetadataEnricher->attachToMessageBus($commandBus);

That's it!

Container-Driven Set Up

If you are using the container-aware factories shipped with prooph/event-store and prooph/service-bus you may also want to auto register the CausationMetadataEnricher.

Add the CausationMetadataEnricher as plugin to the command bus as well as the event-store. Keep in mind, that this service must be shared in order to work (which it is by default in most container implementations).