Skip to main content

Publications

Publishing in JustSaying allows you to send messages to AWS SNS topics or SQS queues. Configure your publications using the fluent API within AddJustSaying to define where and how messages are published.

Topics vs Queues

JustSaying supports publishing to both SNS topics and SQS queues, each suited for different messaging patterns:

FeatureTopics (SNS)Queues (SQS)
PatternPublish-Subscribe (fan-out)Point-to-Point
SubscribersMultiple subscribers can receive the same messageSingle consumer processes each message
Use CaseEvents that multiple services need to react toCommands for a specific service
ExampleOrderPlacedEvent → notify inventory, shipping, and analyticsProcessPaymentCommand → payment service only

Configuring Publications

All publication configuration is accessed via the MessagingBusBuilder.Publications fluent API:

services.AddJustSaying(config =>
{
config.Publications(x =>
{
// Publish to SNS topics
x.WithTopic<OrderPlacedEvent>();

// Publish to SQS queues
x.WithQueue<ProcessPaymentCommand>();
});
});

Available Methods

Topic Publications

  • WithTopic<T>() - Publish to an SNS topic (creates if not exists)
  • WithTopicArn<T>(arn) - Publish to an existing topic by ARN

Queue Publications

  • WithQueue<T>() - Publish directly to an SQS queue (creates if not exists)
  • WithQueueArn<T>(arn) - Publish to an existing queue by ARN
  • WithQueueUrl<T>(url) - Publish to an existing queue by URL
  • WithQueueUri<T>(uri) - Publish to an existing queue by URI

Further Configuration

For detailed configuration options, see: