Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Addressing

NuGet Package: NServiceBus.Transport.PostgreSql (8.x)
Target Version: NServiceBus 9.x

Format

The PostgreSQL Transport address canonical form is a schema-qualified quoted identifier:

""table"".""schema""

Resolution

The address is resolved into a fully-qualified table name that includes the table name and its schema. In the address, the table name is the only mandatory part. An address containing only a table name is a valid address, e.g. MyTable.

Schema

The PostgreSQL transport needs to know what schema to use for a queue table when sending messages. The following API can be used to specify the schema for an endpoint when routing is used to find a destination queue table for a message:

var routing = endpointConfiguration.UseTransport(new PostgreSqlTransport("connectionString"));

routing.RouteToEndpoint(typeof(MyMessage), "MyEndpoint");
routing.UseSchemaForEndpoint(endpointName: "MyEndpoint", schema: "my_schema");

There are several cases when routing is not used and the transport needs specific configuration to find out the schema for a queue table:

Use the following API to configure the schema for a queue:

var transport = new PostgreSqlTransport("connectionString");

transport.Schema.UseSchemaForQueue(queueName: "myqueue", schema: "my_schema");
transport.Schema.UseSchemaForQueue(queueName: "myerror", schema: "sc");

The configuration above is applicable when sending to a queue or when a queue is passed in the configuration:

await messageSession.Send("myqueue", new MyMessage());
endpointConfiguration.SendFailedMessagesTo("myerror");

The entire algorithm for calculating the schema is the following:

  • If the schema is configured for a given queue via UseSchemaForQueue, the configured value is used.
  • If logical routing is used and schema is configured for a given endpoint via UseSchemaForEndpoint, the configured schema is used.
  • If destination address contains a schema, the schema from address is used.
  • If default schema is configured via DefaultSchema, the configured value is used.
  • Otherwise, public is used as a default schema.