Class PostgresSagaSqlSchema

java.lang.Object
org.axonframework.modelling.saga.repository.jdbc.GenericSagaSqlSchema
org.axonframework.modelling.saga.repository.jdbc.PostgresSagaSqlSchema
All Implemented Interfaces:
SagaSqlSchema

public class PostgresSagaSqlSchema extends GenericSagaSqlSchema
SQL schema supporting PostgreSQL databases.

This implementation uses the appropriate PostgreSQL data types (serial, bytea).

Since:
2.4
Author:
Jochen Munz
  • Constructor Details

    • PostgresSagaSqlSchema

      public PostgresSagaSqlSchema()
      Initialize a PostgresSagaSqlSchema using the default schema configuration.
    • PostgresSagaSqlSchema

      public PostgresSagaSqlSchema(SagaSchema sagaSchema)
      Initialize a PostgresSagaSqlSchema using the given sagaSchema.
      Parameters:
      sagaSchema - the saga schema configuration
  • Method Details

    • sql_createTableAssocValueEntry

      public PreparedStatement sql_createTableAssocValueEntry(Connection conn) throws SQLException
      Description copied from interface: SagaSqlSchema
      Creates a PreparedStatement that creates the table for storing Association Values for Sagas.
      Specified by:
      sql_createTableAssocValueEntry in interface SagaSqlSchema
      Overrides:
      sql_createTableAssocValueEntry in class GenericSagaSqlSchema
      Parameters:
      conn - The connection to create the PreparedStatement for
      Returns:
      a Prepared statement that created the Association Value table, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_createTableSagaEntry

      public PreparedStatement sql_createTableSagaEntry(Connection conn) throws SQLException
      Description copied from interface: SagaSqlSchema
      Creates a PreparedStatement that creates the table for storing Sagas.
      Specified by:
      sql_createTableSagaEntry in interface SagaSqlSchema
      Overrides:
      sql_createTableSagaEntry in class GenericSagaSqlSchema
      Parameters:
      conn - The connection to create the PreparedStatement for
      Returns:
      a Prepared statement that created the Saga table, when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • sql_loadSaga

      public PreparedStatement sql_loadSaga(Connection connection, String sagaId) throws SQLException
      Description copied from interface: SagaSqlSchema
      Creates a PreparedStatement that loads a single Saga, with given sagaId.
      Specified by:
      sql_loadSaga in interface SagaSqlSchema
      Overrides:
      sql_loadSaga in class GenericSagaSqlSchema
      Parameters:
      connection - The connection to create the PreparedStatement for
      sagaId - The identifier of the Saga to return
      Returns:
      a statement, that creates a result set to be processed by SagaSqlSchema.readSerializedSaga(java.sql.ResultSet), when executed
      Throws:
      SQLException - when an error occurs creating the PreparedStatement
    • setExclusiveLoad

      public void setExclusiveLoad(boolean exclusiveLoad)
      Sets whether loading of Sagas should occur exclusively by a single node, by requiring a row lock from the database.

      If true, only one instance of the application may load a saga at a time. This may be used to serialize event handling in sagas in multi-node configurations where no StreamingEventProcessor is used. The given processor type caveat is explained through the fact that a StreamingEventProcessor requires claimed segments to be able to perform any event handling work. Furthermore, this segments originate from a shared resources in a distributed environment.

      As such, a Saga cannot be accessed concurrently through the StreamingEventProcessor. And hence, setting exclusiveLoad to true would not change the underlying behavior at all.