Skip to content

Commit

Permalink
fixing the last todo
Browse files Browse the repository at this point in the history
  • Loading branch information
tmasternak committed May 14, 2024
1 parent 63c2ac0 commit 9b1e358
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public void SetUp()

var fullTestName = testName + "#" + endpointBuilder;

//TODO: shorten the .delayed to get additional symbols for the queue name
// Max length for table name is 63. We need to reserve space for the:
// - ".delayed" - suffix (8)
// - "_Seq_seq" suffix for auto-created sequence backing up the Seq column (8)
Expand Down
10 changes: 5 additions & 5 deletions src/NServiceBus.Transport.PostgreSql/PostgreSqlConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ THEN 0
";

public string MoveDueDelayedMessageText { get; set; } = @"
WITH message as (DELETE FROM {0} WHERE seq in (SELECT seq from {0} WHERE {0}.Due < now() AT TIME ZONE 'UTC' LIMIT @BatchSize)
RETURNING headers, body)
INSERT into {1} (id, correlationid, replytoaddress, expires, headers, body) SELECT gen_random_uuid(), NULL, NULL, NULL, headers, body FROM message;
WITH message as (DELETE FROM {0} WHERE id in (SELECT id from {0} WHERE {0}.Due < now() AT TIME ZONE 'UTC' LIMIT @BatchSize)
RETURNING id, headers, body)
INSERT into {1} (id, correlationid, replytoaddress, expires, headers, body) SELECT id, NULL, NULL, NULL, headers, body FROM message;
SELECT now() AT TIME ZONE 'UTC' as UtcNow, Due as NextDue
FROM {0}
Expand Down Expand Up @@ -111,10 +111,10 @@ Seq serial NOT NULL

public string CreateDelayedMessageStoreText { get; set; } = @"
CREATE TABLE IF NOT EXISTS {0} (
Id uuid NOT NULL DEFAULT gen_random_uuid(),
Headers text NOT NULL,
Body bytea,
Due timestamptz NOT NULL,
Seq bigint not null generated always as identity
Due timestamptz NOT NULL
);";

//HINT: https://stackoverflow.com/questions/1766046/postgresql-create-table-if-not-exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

class PostgreSqlTransportInfrastructure : TransportInfrastructure
{
//The PostgreSQL limit is 63 but we need to reserve space for "_Seq_seq" suffix used in the
//auto-created sequence and that is 8 bytes less
//The limit is 55=63-max(8,8). 63 is the built-in PostgreSQL limit and we also need to reserve space for:
// - "_Seq_seq" suffix (8 bytes) used in the auto-created sequence for the main queue table
// - ".delayed" suffix (8 bytes) that is used in the delayed messages table
const int TableQueueNameLimit = 55;
readonly PostgreSqlTransport transport;
readonly HostSettings hostSettings;
Expand Down

0 comments on commit 9b1e358

Please sign in to comment.