MVFC.Outbox.GcpPubSub 3.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MVFC.Outbox.GcpPubSub --version 3.0.0
                    
NuGet\Install-Package MVFC.Outbox.GcpPubSub -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MVFC.Outbox.GcpPubSub" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MVFC.Outbox.GcpPubSub" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MVFC.Outbox.GcpPubSub" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MVFC.Outbox.GcpPubSub --version 3.0.0
                    
#r "nuget: MVFC.Outbox.GcpPubSub, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MVFC.Outbox.GcpPubSub@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MVFC.Outbox.GcpPubSub&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MVFC.Outbox.GcpPubSub&version=3.0.0
                    
Install as a Cake Tool

MVFC.Outbox.GcpPubSub

🇧🇷 Leia em Português

CI codecov License Platform NuGet Version NuGet Downloads

Main guide · Playground

Publishes MVFC.Outbox messages to GCP Pub/Sub through Wolverine. Uses Google's native emulator detection.

Supports .NET 10 and .NET 11.

dotnet add package MVFC.Outbox.GcpPubSub

Configuration and usage

The examples use the application's services and variables: services, configuration, connection, ct, order and topicId. Register services before building the host. Resolve IOutboxPublisher and your DbContext in the same dependency injection (DI) scope.

using Google.Api.Gax;
using MVFC.Outbox.Extensions;
using MVFC.Outbox.GcpPubSub;
using MVFC.Outbox.GcpPubSub.Extensions;
using MVFC.Outbox.PostgreSql;
using MVFC.Outbox.PostgreSql.Extensions;
using MVFC.Outbox.Publishing;
using Microsoft.Extensions.DependencyInjection;

services.AddOutbox(configuration, outbox => outbox.ConsumerProducer()
    .MapAggregate<Order, Guid>(order => order.Id, "order")
    .UsePostgreSql<ApplicationDbContext>(connection)
    .UseGcpPubSub(pubsub =>
    {
        pubsub.ProjectId = "my-project";
        pubsub.EmulatorDetection = EmulatorDetection.EmulatorOrProduction;
        pubsub.AutoProvision = false;
    }));

var created = Guid.Parse("78214bd7-451a-4896-88be-08d7fcfdc32a");
var audited = Guid.Parse("3b914e8e-e144-4f70-a520-e7d30dbe5bca");
await publisher.For(order).To(created, audited).EnqueueAsync(ct);
await database.SaveChangesAsync(ct);

Topics and routes

{
  "Outbox": {
    "Topics": {
      "78214bd7-451a-4896-88be-08d7fcfdc32a": "orders-created",
      "3b914e8e-e144-4f70-a520-e7d30dbe5bca": "orders-audited"
    },
    "HandlerRoutes": {
      "a6d21ecc-9cd9-4486-8174-e7f3cae7acb8": "order"
    }
  }
}

Emulator, credentials, and per-publication project overrides

  • Emulator vs production: for local use, set PUBSUB_EMULATOR_HOST=localhost:8085. With EmulatorDetection.EmulatorOrProduction, this variable selects the emulator. Without it, the client uses production with Application Default Credentials (ADC).

    When AutoProvision = false, create the topics beforehand.

  • Per-publication project override: use .WithProjectId("billing-project") to send that publication to "billing-project" through GcpPubSubOutboxSender. The topic name still comes from Outbox:Topics[GUID], and the configured credentials or emulator stay the same.

    Create the topic and grant publishing permissions in that project.

  • Custom attributes & reserved headers: every published message includes outbox-message-id, outbox-topic-id, aggregate-id, aggregate-type and schema-version, plus any .WithAttributes(...) entries (which cannot overwrite those reserved keys).

  • Delivery semantics & quotas: Processed means the broker accepted the message; it does not mean a consumer processed it. Delivery is at least once. Consumers must use outbox-message-id to prevent duplicate effects.

    Set MaximumPayloadBytes (default 1,000,000 UTF-8 bytes) to leave room for Pub/Sub attributes, and keep LeaseDuration greater than PublishTimeout.

Requirements

  • An application targeting .NET 10 or .NET 11.

  • A default Google Cloud project ID and GUID-to-topic mappings. In production, configure Application Default Credentials with access to publish to the destination topics. For the emulator, configure PUBSUB_EMULATOR_HOST and the native emulator detection mode.

  • For development, the playground and integration tests, use the .NET 11 SDK specified in global.json.

    To build the packages, also install .NET 10 targeting support. Keep Docker running. See the playground guide.

Contributing

See CONTRIBUTING.md to set up the environment, run the Cake build and follow the test and coverage conventions. Dependency versions are defined in Directory.Packages.props.

License

Distributed under the Apache License 2.0. See LICENSE for all terms: permissions, redistribution conditions, and limits on warranty and liability.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.0 0 12/4/2026
5.0.0 49 12/3/2026
4.1.0 57 12/2/2026
4.0.0 60 12/1/2026
3.0.0 63 12/1/2026
2.0.1 85 11/30/2026
2.0.0 90 11/30/2026
1.1.1 96 11/30/2026
1.1.0 95 11/30/2026
1.0.1 91 11/30/2026
1.0.0 96 11/30/2026