Class: Synapse::ProcessManager::Process Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse/process_manager/process.rb

Overview

This class is abstract.

Processes are used to maintain the state of long-running business transactions

The term process is used in Enterprise Integration Patterns to describe a mechanism used to “maintain the state of the sequence and determine the next processing step based on intermediate results” (Hohpe 279). Processes are also called sagas in some CQRS frameworks.

Consider using the implementation of a process that uses the mapping DSL.

Direct Known Subclasses

MappingProcess

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id = nil) ⇒ undefined

Parameters:

  • id (String) (defaults to: nil)


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/synapse/process_manager/process.rb', line 26

def initialize(id = nil)
  unless id
    id = IdentifierFactory.instance.generate
  end

  @id = id
  @correlations = CorrelationSet.new
  @active = true

  correlate_with :process_id, id
end

Instance Attribute Details

#activeBoolean (readonly) Also known as: active?

Returns True if this process is active.

Returns:

  • (Boolean)

    True if this process is active



20
21
22
# File 'lib/synapse/process_manager/process.rb', line 20

def active
  @active
end

#correlationsCorrelationSet (readonly)

Returns The correlations for this process.

Returns:



17
18
19
# File 'lib/synapse/process_manager/process.rb', line 17

def correlations
  @correlations
end

#idString (readonly)

Returns The unique identifier of this process.

Returns:

  • (String)

    The unique identifier of this process



14
15
16
# File 'lib/synapse/process_manager/process.rb', line 14

def id
  @id
end

Instance Method Details

#handle(event) ⇒ undefined

This method is abstract.

Handles the given event

The actual result of the processing depends on the implementation of the process. Implementations are highly discouraged from throwing exceptions.

Parameters:

  • event (EventMessage)

Returns:

  • (undefined)

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/synapse/process_manager/process.rb', line 46

def handle(event)
  raise NotImplementedError
end