Getting Started
Architecture
NServiceBus
Transports
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Combining PostgreSQL Persistence and Transport

Component: Sql Persistence
Target Version: NServiceBus 9.x

When using SQL persistence using the PostgreSQL dialect in combination with the PostgreSQL transport, the location of saga data depends both on whether the outbox is enabled and on the transaction mode.

Outbox disabled

PostgreSQL Transport
TransactionMode
Connection sharingSaga data location
SendsAtomicWithReceiveisolated transaction for send and receiveTransport DB
ReceiveOnlyisolated transaction for receiveTransport DB
NoneNo transactionsPersistence DB

With the outbox disabled, the persistence uses the connection and transaction context established by the transport to access saga data. This behavior ensures exactly-once message processing, since the state change of a saga is committed atomically with the consumption of the message that caused it.

This behavior may be disabled, to force the persistance to create its own connection, as it does when the outbox is enabled:

var persistence = endpointConfiguration.UsePersistence<SqlPersistence>();
var dialect = persistence.SqlDialect<SqlDialect.PostgreSql>();
dialect.DoNotUsePostgreSqlTransportConnection();

Outbox enabled

PostgreSQL Transport
TransactionMode
Connection sharingSaga data location
SendsAtomicWithReceiveNot supportedN/A
ReceiveOnlyvia Transport storage contextPersistence DB
NoneNot supportedN/A

Related Articles