From Domain Events to Webhooks
dev.to·2h·
Discuss: DEV
🔌APIs
Preview
Report Post

I work on an ERP system that integrates with various external systems like warehouse management systems, accounting softwares, weighing bridges, etc. When something changes in our system like an order is created, or a shipment is dispatched, multiple external systems need to know about it.

We use domain events internally, and translate those into HTTP webhooks for external consumers.

Here’s how we do it (I’ve simplified it for this post).

Domain Events

Domain events implement this interface:

interface DomainEvent
{
public function aggregateRootId(): string;
public function displayReference(): string;
public function occurredAt(): \DateTimeImmutable;
public static function eventType(): DomainEventType;
}

#[TriggerWebhook]
class OrderConfirmed implements DomainE...

Similar Posts

Loading similar posts...