Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressing the ability to fully customize the external message table … #1178

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,33 @@ public async Task end_to_end_default_variable_message_types()
var envelope = tracked.Received.SingleEnvelope<Message2>();
envelope.Destination.ShouldBe(new Uri("external-table://external.incoming1/"));
}

[Fact]
public async Task end_to_end_default_variable_message_types_customize_table_in_every_possible_way()
{
using var host = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
opts.UsePostgresqlPersistenceAndTransport(Servers.PostgresConnectionString, "external");

opts.ListenForMessagesFromExternalDatabaseTable("external", "incoming1", table =>
{
table.IdColumnName = "pk";
table.TimestampColumnName = "added";
table.JsonBodyColumnName = "message_body";
table.MessageTypeColumnName = "message_kind";

table.PollingInterval = 1.Seconds();
});

}).StartAsync();

var tracked = await host.TrackActivity().Timeout(1.Minutes()).WaitForMessageToBeReceivedAt<Message2>(host).ExecuteAndWaitAsync(
_ => host.SendMessageThroughExternalTable("external.incoming1", new Message2()));

var envelope = tracked.Received.SingleEnvelope<Message2>();
envelope.Destination.ShouldBe(new Uri("external-table://external.incoming1/"));
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,33 @@ public async Task end_to_end_default_variable_message_types()
envelope.Destination.ShouldBe(new Uri("external-table://outgoing.incoming1/"));
}

[Fact]
public async Task end_to_end_default_variable_message_types_customize_table_in_every_possible_way()
{
using var host = await Host.CreateDefaultBuilder()
.UseWolverine(opts =>
{
opts.UseSqlServerPersistenceAndTransport(Servers.SqlServerConnectionString, "outside");

opts.ListenForMessagesFromExternalDatabaseTable("outside", "incoming1", table =>
{
table.IdColumnName = "pk";
table.TimestampColumnName = "added";
table.JsonBodyColumnName = "message_body";
table.MessageTypeColumnName = "message_kind";

table.PollingInterval = 1.Seconds();
});

}).StartAsync();

var tracked = await host.TrackActivity().Timeout(1.Minutes()).WaitForMessageToBeReceivedAt<Message2>(host).ExecuteAndWaitAsync(
_ => host.SendMessageThroughExternalTable("outside.incoming1", new Message2()));

var envelope = tracked.Received.SingleEnvelope<Message2>();
envelope.Destination.ShouldBe(new Uri("external-table://outside.incoming1/"));
}

}

public static class Message1Handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ public override ISchemaObject AddExternalMessageTable(ExternalMessageTable defin
table.AddColumn(definition.JsonBodyColumnName, "jsonb").NotNull();
if (definition.TimestampColumnName.IsNotEmpty())
{
table.AddColumn<DateTimeOffset>("timestamp").DefaultValueByExpression("((now() at time zone 'utc'))");
table.AddColumn<DateTimeOffset>(definition.TimestampColumnName).DefaultValueByExpression("((now() at time zone 'utc'))");
}

if (definition.MessageTypeColumnName.IsNotEmpty())
{
table.AddColumn<string>("message_type");
table.AddColumn<string>(definition.MessageTypeColumnName);
}

return table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,12 @@ public override ISchemaObject AddExternalMessageTable(ExternalMessageTable defin
table.AddColumn(definition.JsonBodyColumnName, "varbinary(max)").NotNull();
if (definition.TimestampColumnName.IsNotEmpty())
{
table.AddColumn<DateTimeOffset>("timestamp").DefaultValueByExpression("SYSDATETIMEOFFSET()");
table.AddColumn<DateTimeOffset>(definition.TimestampColumnName).DefaultValueByExpression("SYSDATETIMEOFFSET()");
}

if (definition.MessageTypeColumnName.IsNotEmpty())
{
table.AddColumn("message_type", "varchar(250)");
table.AddColumn(definition.MessageTypeColumnName, "varchar(250)");
}

return table;
Expand Down
Loading