masstransit

Kafka Producer with MassTransit - IBusInstance has not been registered

泄露秘密 提交于 2021-01-29 06:51:24
问题 I'm trying to build a Kafka consumer using MassTransit I have this piece of code var services = new ServiceCollection(); services.AddMassTransit(x => { x.AddRider(rider => { rider.AddProducer<string, Request>("request", m => m.Message.RequestId); rider.UsingKafka((context, k) => { k.Host("localhost:9092"); }); }); }); var provider = services.BuildServiceProvider(); var producer = provider.GetRequiredService<ITopicProducer<Request>>(); await producer.Produce(new Request() { RequestId = "abc123

Getting Masstransit to use scoped lifetime

大城市里の小女人 提交于 2021-01-29 06:20:42
问题 I'm having an issue with getting the same instance of the IIdentityService(my own class) or IServiceProvider in my consumer observer. I have an identity service where I set the credentials for the user, which is used later in the consumer pipeline. I have tried the code below along with other code and configuration changes. _serviceProvider.GetRequiredService<IIdentityService>() _serviceProvider.CreateScope() var consumerScopeProvider = _serviceProvider.GetRequiredService

MassTransit/RabbitMq Error queue - how to delete messages?

自古美人都是妖i 提交于 2021-01-28 17:17:09
问题 I have a queue {QueueName}. I defined a consumer and faulted-messages consumer as follows: cfg.ReceiveEndpoint ( queueName: QueueName, e => { e.UseMessageRetry(r => r.Immediate(2)); e.AutoDelete = false; e.Durable = true; e.Consumer(() => container.Resolve<My_Consumer>()); e.Consumer(() => container.Resolve<My_Fault_Consumer>()); } ); When consumer dries out its attempts number to handle the message, the faulted-message-consumer kicks in and handles the message by logging the error. I've

MassTransit/RabbitMq Error queue - how to delete messages?

谁说胖子不能爱 提交于 2021-01-28 17:04:52
问题 I have a queue {QueueName}. I defined a consumer and faulted-messages consumer as follows: cfg.ReceiveEndpoint ( queueName: QueueName, e => { e.UseMessageRetry(r => r.Immediate(2)); e.AutoDelete = false; e.Durable = true; e.Consumer(() => container.Resolve<My_Consumer>()); e.Consumer(() => container.Resolve<My_Fault_Consumer>()); } ); When consumer dries out its attempts number to handle the message, the faulted-message-consumer kicks in and handles the message by logging the error. I've

How to authenticate a user when consuming MassTransit messages in Asp.Net Core Web API?

匆匆过客 提交于 2021-01-21 05:07:12
问题 I have several Asp.Net Core Web APIs that use Bearer authentication and IdentityServer4.AccessTokenValidation middleware to introspect tokens, authenticate the user and create claims. This works fine for HTTP requests. I am in the process of configuring these APIs to also be MassTransit endpoints (for both Publishing and Consuming messages) using RabbitMQ as transport. I followed the instructions here for adding MassTransit to the API and for setting up message consumers. A typical workflow

How to authenticate a user when consuming MassTransit messages in Asp.Net Core Web API?

孤街浪徒 提交于 2021-01-21 05:06:42
问题 I have several Asp.Net Core Web APIs that use Bearer authentication and IdentityServer4.AccessTokenValidation middleware to introspect tokens, authenticate the user and create claims. This works fine for HTTP requests. I am in the process of configuring these APIs to also be MassTransit endpoints (for both Publishing and Consuming messages) using RabbitMQ as transport. I followed the instructions here for adding MassTransit to the API and for setting up message consumers. A typical workflow

MassTransit - Wait for all activities to complete and then continue processing

柔情痞子 提交于 2021-01-03 01:20:15
问题 If I have to much activities, does it cause blocking resources or request time out? Here is my scenario: I have an api controller which sends an Order request to consumer; I use Request/Response patern to recieve ErrorMessage property from consumer and base on that property response back, if it's null I would want to return OK() otherwise, return BadRequest or Ok but with a message like: Product out of stock to notify to the client . In my consumer, I have build a routing slip which have 2

Is there a way to persist messages when the broker is offline?

こ雲淡風輕ζ 提交于 2020-12-14 02:27:47
问题 is there a way to support a scenario where broker is offline so that messages can be stored temporarily in disc and attempt to submit once the broker comes online. This is to provide resilience in scenarios where the broker goes down. I have not found anything in the documentation yet. 回答1: There isn't anything like this built into MassTransit. If the broker is unavailable, messages cannot be published or sent. 来源: https://stackoverflow.com/questions/63492266/is-there-a-way-to-persist

Specify Publish timeouts in mass transit

扶醉桌前 提交于 2020-12-13 04:01:21
问题 Is there a way to specify timeout value when publishing messages using the MassTransit Library. How to handle scenarios when message broker goes down. Now it seems that Publish call waits indefinitely. It would be nice to control these behavior. Should we rely on cancellation token? Timeout implementation might be better. 回答1: You can pass a CancellationToken to Publish . If canceled, an OperationCanceledException will be thrown. If you want to use a timeout, you can create a

Specify Publish timeouts in mass transit

*爱你&永不变心* 提交于 2020-12-13 03:57:06
问题 Is there a way to specify timeout value when publishing messages using the MassTransit Library. How to handle scenarios when message broker goes down. Now it seems that Publish call waits indefinitely. It would be nice to control these behavior. Should we rely on cancellation token? Timeout implementation might be better. 回答1: You can pass a CancellationToken to Publish . If canceled, an OperationCanceledException will be thrown. If you want to use a timeout, you can create a