MVFC.Aspire.Helpers.GcpPubSub
9.0.3
dotnet add package MVFC.Aspire.Helpers.GcpPubSub --version 9.0.3
NuGet\Install-Package MVFC.Aspire.Helpers.GcpPubSub -Version 9.0.3
<PackageReference Include="MVFC.Aspire.Helpers.GcpPubSub" Version="9.0.3" />
<PackageVersion Include="MVFC.Aspire.Helpers.GcpPubSub" Version="9.0.3" />
<PackageReference Include="MVFC.Aspire.Helpers.GcpPubSub" />
paket add MVFC.Aspire.Helpers.GcpPubSub --version 9.0.3
#r "nuget: MVFC.Aspire.Helpers.GcpPubSub, 9.0.3"
#:package MVFC.Aspire.Helpers.GcpPubSub@9.0.3
#addin nuget:?package=MVFC.Aspire.Helpers.GcpPubSub&version=9.0.3
#tool nuget:?package=MVFC.Aspire.Helpers.GcpPubSub&version=9.0.3
MVFC.Aspire.Helpers.GcpPubSub
π§π· Leia em PortuguΓͺs
Helpers for integrating with Google Pub/Sub in .NET Aspire projects, including support for the emulator and administration interface (UI).
Motivation
Working with Google Pub/Sub locally usually means:
- Spinning up an emulator container by hand.
- Remembering ports, project IDs and environment variables.
- Manually creating topics/subscriptions and DLQs.
With .NET Aspire you can define containers, but you still need to:
- Configure the emulator image and its ports.
- Keep emulator environment variables in sync across projects.
- Define topics/subscriptions/DLQs in a consistent way.
MVFC.Aspire.Helpers.GcpPubSub provides:
AddGcpPubSub(...)to start the emulator.WithPubSubConfigs(...)to describe topics/subscriptions in code.AddGcpPubSubUI(...)to add a simple web UI.WithReference(...)to wire projects to the emulator and/or UI.
Overview
This project facilitates the configuration and integration of Google Pub/Sub in distributed .NET Aspire applications, providing extension methods to:
- Add the Google Pub/Sub emulator.
- Configure topics and subscriptions automatically.
- Support push and pull subscriptions.
- Provide an administration interface (UI) for management.
Pub/Sub emulator advantages
- Simulates message flow between services locally.
- Supports testing push and pull subscriptions without depending on Google Cloud infrastructure.
- Facilitates development and debugging of asynchronous integrations.
Compatible Images
- Emulator:
thekevjames/gcloud-pubsub-emulatormessagebird/gcloud-pubsub-emulator
- UI:
echocode/gcp-pubsub-emulator-ui
Project Structure
MVFC.Aspire.Helpers.GcpPubSub: Helpers and extensions library for Pub/Sub.
Features
- Adds the Google Pub/Sub emulator.
- Creates topics and subscriptions according to configuration.
- Supports push and pull subscriptions.
- Provides a Pub/Sub administration interface (UI).
- Extension methods to facilitate AppHost configuration.
- Dead Letter (DLQ) support.
Installation
dotnet add package MVFC.Aspire.Helpers.GcpPubSub
Quick Aspire usage (AppHost)
using Aspire.Hosting;
using MVFC.Aspire.Helpers.GcpPubSub;
var builder = DistributedApplication.CreateBuilder(args);
var messageConfig = new MessageConfig(
TopicName: "test-topic",
SubscriptionName: "test-subscription",
PushEndpoint: "/api/pub-sub-exit")
{
DeadLetterTopic = "test-dead-letter-topic",
MaxDeliveryAttempts = 5,
AckDeadlineSeconds = 300,
};
var pubSubConfig = new PubSubConfig(
projectId: "test-project",
messageConfig: messageConfig);
var gcpPubSub = builder.AddGcpPubSub("gcp-pubsub")
.WithPubSubConfigs([pubSubConfig])
.WithWaitTimeout(secondsDelay: 5);
var ui = builder.AddGcpPubSubUI("pubsub-ui")
.WithReference(gcpPubSub)
.WaitFor(gcpPubSub);
builder.AddProject<Projects.MVFC_Aspire_Helpers_Playground_Api>("api-example")
.WithReference(gcpPubSub)
.WaitFor(gcpPubSub);
await builder.Build().RunAsync();
Topics and subscriptions configuration
PubSubConfig
| Parameter | Type | Default | Description |
|---|---|---|---|
projectId |
string | β | GCP project ID. |
messageConfig |
MessageConfig |
β | Message configuration. |
secondsDelay |
int | 5 |
Startup delay in seconds. |
MessageConfig
| Parameter | Type | Default | Description |
|---|---|---|---|
TopicName |
string | β | Topic name. |
SubscriptionName |
string? | null |
Subscription name. |
PushEndpoint |
string? | null |
HTTP endpoint for push delivery. |
DeadLetterTopic |
string? | null |
Dead letter topic name (DLQ). |
MaxDeliveryAttempts |
int? | null |
Max attempts before sending to DLQ. |
AckDeadlineSeconds |
int? | null |
Ack deadline (seconds). |
Note: If DeadLetterTopic is provided, the subscription {DeadLetterTopic}-subscription will be created automatically.
Ports
- Emulator port:
8681 - UI port:
8680
Topics and subscriptions diagram
graph TD
A[Pub/Sub Emulator]
B[test-topic]
C[test-subscription push]
D[test-subscription pull]
E[dead-letter-topic]
F[dead-letter-subscription]
A --> B
B --> C
B --> D
C --> E
E --> F
Provisioning diagram
sequenceDiagram
participant Aspire as .NET Aspire
participant Container as Pub/Sub Emulator
participant Configurator as Pub/Sub Processor
Aspire->>Container: Start container (gcloud-pubsub-emulator)
Container-->>Aspire: Ready (port 8681 available)
Aspire->>Configurator: Trigger OnResourceReady
Configurator->>Container: Create Topics
Configurator->>Container: Create Subscriptions
Configurator-->>Aspire: Provisioning Completed
Aspire->>App: Start App with PUBSUB_EMULATOR_HOST
Public methods
AddGcpPubSubβ adds the emulator.AddGcpPubSubUIβ adds the Pub/Sub UI.WithPubSubConfigsβ configures projects, topics and subscriptions.WithWaitTimeoutβ sets startup delay.WithReferenceβ wires projects to emulator/UI and sets env vars.
Requirements
- .NET 9+
- Aspire.Hosting >= 9.5.0
- Google.Cloud.PubSub.V1 >= 3.29.0
License
Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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. |
-
net10.0
- Aspire.Hosting (>= 13.1.2)
- Google.Cloud.PubSub.V1 (>= 3.32.0)
-
net9.0
- Aspire.Hosting (>= 13.1.2)
- Google.Cloud.PubSub.V1 (>= 3.32.0)
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 |
|---|---|---|
| 9.0.3 | 84 | 4/12/2026 |
| 9.0.2 | 78 | 4/12/2026 |
| 9.0.1 | 82 | 4/12/2026 |
| 9.0.0 | 89 | 4/12/2026 |
| 8.0.2 | 86 | 4/11/2026 |
| 8.0.1 | 106 | 4/3/2026 |
| 8.0.0 | 91 | 4/2/2026 |
| 7.3.3 | 92 | 3/31/2026 |
| 7.3.2 | 85 | 3/30/2026 |
| 7.3.1 | 88 | 3/30/2026 |
| 7.3.0 | 91 | 3/30/2026 |
| 7.2.2 | 92 | 3/29/2026 |
| 7.2.1 | 89 | 3/29/2026 |
| 7.2.0 | 89 | 3/29/2026 |
| 7.1.0 | 88 | 3/22/2026 |
| 6.4.4 | 88 | 3/21/2026 |
| 6.4.3 | 89 | 3/15/2026 |
| 6.4.2 | 96 | 3/15/2026 |
| 6.4.1 | 92 | 3/10/2026 |
| 6.4.0 | 92 | 3/9/2026 |