Class: Synapse::Domain::DomainEventMessage

Inherits:
EventMessage show all
Defined in:
lib/synapse/domain/message.rb

Overview

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.

Instance Attribute Summary collapse

Attributes inherited from Message

#id, #metadata, #payload, #timestamp

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

#and_metadata, as_message, build, #payload_type, #with_metadata

Constructor Details

#initialize(id, metadata, payload, timestamp, aggregate_id, sequence_number) ⇒ undefined

Parameters:

  • id (String)
  • metadata (Hash)
  • payload (Object)
  • timestamp (Time)
  • aggregate_id (Object)
  • sequence_number (Integer)


34
35
36
37
38
39
# File 'lib/synapse/domain/message.rb', line 34

def initialize(id, , payload, timestamp, aggregate_id, sequence_number)
  super id, , payload, timestamp

  @aggregate_id = aggregate_id
  @sequence_number = sequence_number
end

Instance Attribute Details

#aggregate_idObject (readonly)

The identifier of the aggregate that reported the event

Returns:

  • (Object)


21
22
23
# File 'lib/synapse/domain/message.rb', line 21

def aggregate_id
  @aggregate_id
end

#sequence_numberInteger (readonly)

The sequence number of the event in the order of generation

Returns:

  • (Integer)


25
26
27
# File 'lib/synapse/domain/message.rb', line 25

def sequence_number
  @sequence_number
end

Class Method Details

.builderClass

Returns:

  • (Class)


42
43
44
# File 'lib/synapse/domain/message.rb', line 42

def self.builder
  DomainEventMessageBuilder
end