Skip to content
cloudemu
Services

Notification

Pub/sub topics with fan-out to multiple subscribers and attribute filtering, modelled on SNS, Notification Hubs, and FCM

aws SNSazr Notification Hubsgcp FCM

Emulates a managed pub/sub notification service — the topic you publish one message to and have it fanned out to every subscriber at once. You create a topic, attach subscriptions that each point at an endpoint (an email address, an HTTP webhook, an SQS queue), then publish; the message is delivered to all matching subscriptions.

Reach for it in tests when your code announces an event to several independent consumers and you don't want a queue's pull-and-ack cycle — publish is fire-and-forget fan-out. Unlike the message queue, there's no per-consumer acknowledgement: a subscriber either matches the message or it doesn't.

ProviderServiceDriver
AWSSNSaws.SNS
AzureNotification Hubsazure.NotificationHubs
GCPFCMgcp.FCM

Create a topic and subscribe endpoints#

A topic is the fan-out point; subscriptions are the endpoints it delivers to. Create the topic first, then attach one subscription per consumer — each names a Protocol (email, sms, http, https, sqs, lambda) and the Endpoint to reach it at.

import notifdriver "github.com/stackshy/cloudemu/v2/services/notification/driver"

topic, _ := aws.SNS.CreateTopic(ctx, notifdriver.TopicConfig{
    Name: "order-events",
})

sub, _ := aws.SNS.Subscribe(ctx, notifdriver.SubscriptionConfig{
    TopicID:  topic.ID,
    Protocol: "email",
    Endpoint: "team@example.com",
})

Publish a message#

Publish fans one message out to every subscription on the topic. The Attributes map rides along with the message so subscribers can filter on it — a subscription with a matching filter policy receives the message, others are skipped.

aws.SNS.Publish(ctx, notifdriver.PublishInput{
    TopicID: topic.ID,
    Message: "New order received",
    Attributes: map[string]string{"orderType": "express"},
})

Behavior & fidelity#

  • Fan-out delivery. One Publish is delivered to every subscription on the topic; adding or removing a subscription changes the recipient set for subsequent publishes with no change to the producer.
  • Attribute filtering. Message Attributes are matched against each subscription's filter policy, so a single topic can route to different subscribers by attribute — mirroring SNS message-attribute filtering.
  • Subscription status. New subscriptions carry a confirmed/pending status, matching the SNS confirmation handshake rather than assuming every endpoint is immediately live.
  • SDK-compat status — Portable Go API only. Real aws-sdk-go-v2/service/sns, Notification Hubs ARM, and FCM REST clients can't talk to cloudemu yet; notification SDK-compat handlers will ship in lockstep across all three providers in a later phase. Topics, subscriptions, fan-out, and attribute filtering are fully available today through the Portable Go API shown above.

On this page

On this page