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:
| Feature | Topics (SNS) | Queues (SQS) |
|---|---|---|
| Pattern | Publish-Subscribe (fan-out) | Point-to-Point |
| Subscribers | Multiple subscribers can receive the same message | Single consumer processes each message |
| Use Case | Events that multiple services need to react to | Commands for a specific service |
| Example | OrderPlacedEvent → notify inventory, shipping, and analytics | ProcessPaymentCommand → 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 ARNWithQueueUrl<T>(url)- Publish to an existing queue by URLWithQueueUri<T>(uri)- Publish to an existing queue by URI
Further Configuration
For detailed configuration options, see:
- Configuration - Overview of publication configuration
- Write Configuration - Encryption, compression, and advanced options
- Batch Publishing - Publishing multiple messages efficiently