英文:
MassTransit Consuming Raw Json from an existing SQS queue
问题
我有一个应用程序,它正在从一个现有的SQS队列中消耗原始JSON以与另一个系统进行互操作。我们正在使用Amazon SQS客户端(.Net SDK)。我想将这个过渡到使用MassTransit消费者来拉取原始JSON。
我已经观看了显示如何绑定到RabbitMQ队列以消费没有MT包装的消息的视频,但我看不到如何手动订阅消费者到SQS。
IAmazonSqsReceiveEndpointConfigurator只有与主题相关的Subscribe方法,没有与SQS相关的方法。
英文:
I have an app that is consuming raw json from a pre-existing SQS queue for interoperability with another system. We're using the Amazon Sqs client (.Net Sdk). I'd like to switch this to have a MassTransit consumer pull the raw json.
I've watched the video that shows how to Bind to a RabbitMQ queue to consume messages without MT wrappers, but I can't see how to subscribe the consumer to SQS manually.
There is no sns topic, just the sqs queue.
IAmazonSqsReceiveEndpointConfigurator only has Subscribe methods that refer to topics.
答案1
得分: 1
使用MassTransit从SQS消耗原始JSON很容易。
services.AddMassTransit(x =>
{
x.AddConsumer<SomeConsumer>();
x.UsingAmazonSqs((context, cfg) =>
{
cfg.Host(...);
cfg.ReceiveEndpoint("existing-sqs-queue", e =>
{
e.UseRawJsonSerializer(isDefault: true);
e.ConfigureConsumer<SomeConsumer>();
});
});
});
队列上的任何消息都将传递给消费者。
英文:
Consuming raw JSON from an SQS with MassTransit is easy.
services.AddMassTransit(x =>
{
x.AddConsumer<SomeConsumer>();
x.UsingAmazonSqs((context, cfg) =>
{
cfg.Host(...);
cfg.ReceiveEndpoint("existing-sqs-queue", e =>
{
e.UseRawJsonSerializer(isDefault: true);
e.ConfigureConsumer<SomeConsumer>();
});
});
});
Any message on the queue will be delivered to the consumer.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论