class Synapse::Domain::DomainEventMessage

Message that contains a domain event as a payload that represents a state change in the domain.

In contrast to a regular event message, this type of message contains the identifier of the aggregate that reported it. It also contains a sequence number that allows the messages to be placed in the order they were reported.

Attributes

aggregate_id[R]

The identifier of the aggregate that reported the event @return [Object]

sequence_number[R]

The sequence number of the event in the order of generation @return [Integer]

Public Class Methods

builder() click to toggle source

@return [Class]

# File lib/synapse/domain/message.rb, line 42
def self.builder
  DomainEventMessageBuilder
end
new(id, metadata, payload, timestamp, aggregate_id, sequence_number) click to toggle source

@param [String] id @param [Hash] metadata @param [Object] payload @param [Time] timestamp @param [Object] aggregate_id @param [Integer] sequence_number @return [undefined]

Calls superclass method Synapse::Message::new
# File lib/synapse/domain/message.rb, line 34
def initialize(id, metadata, payload, timestamp, aggregate_id, sequence_number)
  super id, metadata, payload, timestamp

  @aggregate_id = aggregate_id
  @sequence_number = sequence_number
end

Protected Instance Methods

build_duplicate(builder, metadata) click to toggle source

@param [DomainEventMessageBuilder] builder @param [Hash] metadata @return [undefined]

Calls superclass method Synapse::Message#build_duplicate
# File lib/synapse/domain/message.rb, line 51
def build_duplicate(builder, metadata)
  super
  builder.aggregate_id = @aggregate_id
  builder.sequence_number = @sequence_number
end