【发布时间】:2021-10-07 21:33:59
【问题描述】:
我正在尝试使用他们文档中提到的公共交通配置将 SNS 主题订阅到 SQS 队列。消息已发布,但不会出现在 SQS 队列中。 SQS 队列名称:“test”,SNS 主题名称:“kbbico-manual-to-replace”。
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddMassTransit(x =>
{
/*Configuring a receive endpoint will use the message topology to create and subscribe SNS topics to SQS queues so that
* published messages will be delivered to the receive endpoint queue*/
x.AddConsumer<OfferConsumer>();
x.UsingAmazonSqs((context, cfg) =>
{
cfg.Host("ca-central-1", h =>
{
//h.Config(AmazonSQSConfig);
//h.Config(AmazonSnsConfig);
});
cfg.ReceiveEndpoint("test", e =>
{
e.ConfigureConsumer<OfferConsumer>(context);
// disable the default topic binding
//e.ConfigureConsumeTopology = false;
//Topic subscibed to a recieve endpoint
e.Subscribe("kbbico-manual-to-replace", s =>
{
// set topic attributes
s.TopicAttributes["DisplayName"] = "Public Event Topic";
s.TopicSubscriptionAttributes["some-subscription-attribute"] = "some-attribute-value";
s.TopicTags.Add("environment", "development");
});
});
cfg.ConfigureEndpoints(context);
});
});
services.AddMassTransitHostedService();
}
【问题讨论】:
标签: .net asp.net-core amazon-sqs amazon-sns masstransit