I’m building a Java microservice using Spring Boot 3.5.7, Kafka, and the Outbox Pattern.
In my domain layer, I raise a domain event:
package com.turkcell.reservation_service.domain.event;
import com.turkcell.reservation_service.domain.model.BookId;
import com.turkcell.reservation_service.domain.model.ReservationId;
import com.turkcell.reservation_service.domain.model.ReservationStatus;
import java.time.OffsetDateTime;
public record ReservationCreatedEvent(
ReservationId id,
OffsetDateTime reservationDate,
ReservationStatus reservationStatus,
BookId bookId) {
}
Then, in my command handler, I convert this domain event to an integration event before saving it to the Outbox table:
@Override
@Transactional
public ReservationResponse handle(CreateReservationCommand command) throws JsonProcessingException {
Reservation reservation = reservationMapper.toDomain(command);
reservationRepository.save(reservation);
//Domain Event to Integration Event
ReservationCreatedEvent event = new ReservationCreatedEvent(
new ReservationId(reservation.id().value()),
reservation.reservationDate(),
reservation.status(),
new BookId(reservation.bookId().value()));
ReservationCreatedIntegrationEvent integrationEvent = integrationEventMapper.toIntegrationEvent(event);
Outbox outbox = outboxMapper.toOutbox(integrationEvent);
outbox.setPayloadJson(objectMapper.writeValueAsString(integrationEvent));
outboxRepository.save(outbox); //save event to outbox as json
return reservationMapper.toResponse(reservation);
}
My question is:
In a DDD-based microservice using the Outbox Pattern, is it recommended to create a separate Integration Event object, or can the Domain Event itself be serialized and saved to the Outbox table?
I’m looking for a fact-based explanation — ideally with reasoning or references from DDD or Clean Architecture literature (e.g., Vaughn Vernon’s Implementing Domain-Driven Design or Chris Richardson’s Microservices Patterns).
I want to understand the architectural implications of both approaches (in terms of bounded contexts, coupling, and event evolution), not just personal preference