class Synapse::ProcessManager::Process

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.

@abstract

Attributes

active[R]

@return [Boolean] True if this process is active

active?[R]

@return [Boolean] True if this process is active

correlations[R]

@return [CorrelationSet] The correlations for this process

id[R]

@return [String] The unique identifier of this process

Public Class Methods

new(id = nil) click to toggle source

@param [String] id @return [undefined]

# File lib/synapse/process_manager/process.rb, line 26
def initialize(id = nil)
  @id = id ||= IdentifierFactory.instance.generate
  @correlations = CorrelationSet.new
  @active = true

  correlate_with :process_id, id
end

Public Instance Methods

handle(event) click to toggle source

Handles the given event

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

@abstract @param [EventMessage] event @return [undefined]

# File lib/synapse/process_manager/process.rb, line 42
def handle(event)
  raise NotImplementedError
end

Protected Instance Methods

correlate_with(key, value) click to toggle source

Correlates this process instance with the given key and value

@api public @param [Symbol] key @param [String] value @return [undefined]

# File lib/synapse/process_manager/process.rb, line 54
def correlate_with(key, value)
  @correlations.add(Correlation.new(key, value))
end
dissociate_from(key, value) click to toggle source

Dissociates this process instance from the given key and value

@api public @param [Symbol] key @param [String] value @return [undefined]

# File lib/synapse/process_manager/process.rb, line 64
def dissociate_from(key, value)
  @correlations.delete(Correlation.new(key, value))
end
finish() click to toggle source

Marks this process as finished @return [undefined]

# File lib/synapse/process_manager/process.rb, line 70
def finish
  @active = false
end