Skip to content

Commit bdcecb1

Browse files
committed
newtonsoft removal
1 parent 037b991 commit bdcecb1

34 files changed

+1100
-49
lines changed

MassTransit.PostgresOutbox.Demo.Consumer/Context/Migrations/20241127065933_Initial.Designer.cs

+79
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
#nullable disable
5+
6+
namespace MassTransit.PostgresOutbox.Demo.Consumer.Context.Migrations
7+
{
8+
/// <inheritdoc />
9+
public partial class Initial : Migration
10+
{
11+
/// <inheritdoc />
12+
protected override void Up(MigrationBuilder migrationBuilder)
13+
{
14+
migrationBuilder.CreateTable(
15+
name: "InboxMessages",
16+
columns: table => new
17+
{
18+
MessageId = table.Column<Guid>(type: "uuid", nullable: false),
19+
ConsumerId = table.Column<string>(type: "text", nullable: false),
20+
State = table.Column<int>(type: "integer", nullable: false),
21+
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
22+
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
23+
},
24+
constraints: table =>
25+
{
26+
table.PrimaryKey("PK_InboxMessages", x => new { x.MessageId, x.ConsumerId });
27+
});
28+
29+
migrationBuilder.CreateTable(
30+
name: "OutboxMessages",
31+
columns: table => new
32+
{
33+
Id = table.Column<Guid>(type: "uuid", nullable: false),
34+
State = table.Column<int>(type: "integer", nullable: false),
35+
Payload = table.Column<string>(type: "text", nullable: false),
36+
Type = table.Column<string>(type: "text", nullable: false),
37+
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
38+
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
39+
},
40+
constraints: table =>
41+
{
42+
table.PrimaryKey("PK_OutboxMessages", x => x.Id);
43+
});
44+
}
45+
46+
/// <inheritdoc />
47+
protected override void Down(MigrationBuilder migrationBuilder)
48+
{
49+
migrationBuilder.DropTable(
50+
name: "InboxMessages");
51+
52+
migrationBuilder.DropTable(
53+
name: "OutboxMessages");
54+
}
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// <auto-generated />
2+
using System;
3+
using MassTransit.PostgresOutbox.Demo.Consumer.Contexts;
4+
using Microsoft.EntityFrameworkCore;
5+
using Microsoft.EntityFrameworkCore.Infrastructure;
6+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7+
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
8+
9+
#nullable disable
10+
11+
namespace MassTransit.PostgresOutbox.Demo.Consumer.Context.Migrations
12+
{
13+
[DbContext(typeof(ConsumerContext))]
14+
partial class ConsumerContextModelSnapshot : ModelSnapshot
15+
{
16+
protected override void BuildModel(ModelBuilder modelBuilder)
17+
{
18+
#pragma warning disable 612, 618
19+
modelBuilder
20+
.HasAnnotation("ProductVersion", "9.0.0")
21+
.HasAnnotation("Relational:MaxIdentifierLength", 63);
22+
23+
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
24+
25+
modelBuilder.Entity("MassTransit.PostgresOutbox.Entities.InboxMessage", b =>
26+
{
27+
b.Property<Guid>("MessageId")
28+
.HasColumnType("uuid");
29+
30+
b.Property<string>("ConsumerId")
31+
.HasColumnType("text");
32+
33+
b.Property<DateTime>("CreatedAt")
34+
.HasColumnType("timestamp with time zone");
35+
36+
b.Property<int>("State")
37+
.HasColumnType("integer");
38+
39+
b.Property<DateTime?>("UpdatedAt")
40+
.HasColumnType("timestamp with time zone");
41+
42+
b.HasKey("MessageId", "ConsumerId");
43+
44+
b.ToTable("InboxMessages");
45+
});
46+
47+
modelBuilder.Entity("MassTransit.PostgresOutbox.Entities.OutboxMessage", b =>
48+
{
49+
b.Property<Guid>("Id")
50+
.HasColumnType("uuid");
51+
52+
b.Property<DateTime>("CreatedAt")
53+
.HasColumnType("timestamp with time zone");
54+
55+
b.Property<string>("Payload")
56+
.IsRequired()
57+
.HasColumnType("text");
58+
59+
b.Property<int>("State")
60+
.HasColumnType("integer");
61+
62+
b.Property<string>("Type")
63+
.IsRequired()
64+
.HasColumnType("text");
65+
66+
b.Property<DateTime?>("UpdatedAt")
67+
.HasColumnType("timestamp with time zone");
68+
69+
b.HasKey("Id");
70+
71+
b.ToTable("OutboxMessages");
72+
});
73+
#pragma warning restore 612, 618
74+
}
75+
}
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using MassTransit.PostgresOutbox.Abstractions;
2+
using MassTransit.PostgresOutbox.Entities;
3+
using MassTransit.PostgresOutbox.Extensions;
4+
using Microsoft.EntityFrameworkCore;
5+
6+
namespace MassTransit.PostgresOutbox.Demo.Consumer.Contexts;
7+
public class ConsumerContext(DbContextOptions<ConsumerContext> options) : DbContext(options)
8+
, IOutboxDbContext, IInboxDbContext
9+
{
10+
public DbSet<InboxMessage> InboxMessages { get; set; }
11+
public DbSet<OutboxMessage> OutboxMessages { get; set; }
12+
13+
protected override void OnModelCreating(ModelBuilder modelBuilder)
14+
{
15+
base.OnModelCreating(modelBuilder);
16+
17+
modelBuilder.ApplyConfigurationsFromAssembly(typeof(ConsumerContext).Assembly);
18+
modelBuilder.ConfigureInboxOutboxEntities();
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using Microsoft.EntityFrameworkCore.Design;
3+
4+
namespace MassTransit.PostgresOutbox.Demo.Consumer.Contexts;
5+
6+
public class ConsumerContextFactory : IDesignTimeDbContextFactory<ConsumerContext>
7+
{
8+
public ConsumerContext CreateDbContext(string[] args)
9+
{
10+
var optionsBuilder = new DbContextOptionsBuilder<ConsumerContext>();
11+
12+
optionsBuilder
13+
.UseNpgsql();
14+
15+
return new ConsumerContext(optionsBuilder.Options);
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13+
</PackageReference>
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
18+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0"/>
19+
</ItemGroup>
20+
21+
<ItemGroup>
22+
<ProjectReference Include="..\MassTransit.PostgresOutbox.Demo.Shared\MassTransit.PostgresOutbox.Demo.Shared.csproj" />
23+
</ItemGroup>
24+
25+
26+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using MassTransit.PostgresOutbox.Demo.Consumer.Contexts;
2+
using MassTransit.PostgresOutbox.Demo.Shared.Extensions;
3+
using MassTransit.PostgresOutbox.Extensions;
4+
5+
var builder = WebApplication.CreateBuilder(args);
6+
7+
builder.Services.AddEndpointsApiExplorer();
8+
builder.Services.AddOpenApi();
9+
builder.AddMassTransit(typeof(Program).Assembly);
10+
11+
builder.AddPostgresContext<ConsumerContext>(
12+
"Server=localhost;Port=5432;Database=nuget_consumer_demo;User Id=test;Password=test;Include Error Detail=True;");
13+
builder.Services.AddOutboxInboxServices<ConsumerContext>();
14+
15+
16+
var app = builder.Build();
17+
app.MapOpenApi();
18+
app.MigrateDatabase<ConsumerContext>();
19+
20+
21+
app.Run();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": false,
8+
"applicationUrl": "http://localhost:5181",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
}
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using MassTransit.PostgresOutbox.Abstractions;
2+
using MassTransit.PostgresOutbox.Demo.Consumer.Contexts;
3+
using MassTransit.PostgresOutbox.Demo.Shared.Events;
4+
5+
namespace MassTransit.PostgresOutbox.Demo.Consumer.Services;
6+
7+
public class ConsumeService(ConsumerContext dbContext, IServiceScopeFactory serviceScopeFactory)
8+
: InboxConsumer<ComplexObjectEvent, ConsumerContext>(serviceScopeFactory)
9+
{
10+
protected override Task Consume(ComplexObjectEvent message)
11+
{
12+
var original = ComplexObjectEvent.Init();
13+
var match = message.Equals(original);
14+
Console.WriteLine($"Match: {match}");
15+
return Task.CompletedTask;
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Warning",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

0 commit comments

Comments
 (0)