This commit is contained in:
Justin Kotalik 2020-11-05 11:24:57 -08:00 коммит произвёл GitHub
Родитель 77ebc0d055
Коммит fae47325b0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@ -10,7 +10,7 @@ namespace orders.Controllers
[ApiController]
public class OrdersController : ControllerBase
{
[Topic("orderplaced")]
[Topic("messagebus", "orderplaced")]
[HttpPost("orderplaced")]
public async Task PlaceOrder(Order order, [FromServices] DaprClient dapr, [FromServices] ILogger<OrdersController> logger)
{
@ -49,7 +49,7 @@ namespace orders.Controllers
};
}
await dapr.PublishEventAsync("orderprocessed", confirmation);
await dapr.PublishEventAsync("messagebus", "orderprocessed", confirmation);
logger.LogInformation("Sent confirmation for order {OrderId}", order.OrderId);

Просмотреть файл

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.AspNetCore" Version="0.8.0-preview01" />
<PackageReference Include="Dapr.AspNetCore" Version="0.11.0-preview02" />
</ItemGroup>
</Project>

Просмотреть файл

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.AspNetCore" Version="0.8.0-preview01" />
<PackageReference Include="Dapr.AspNetCore" Version="0.11.0-preview02" />
</ItemGroup>
</Project>

Просмотреть файл

@ -46,7 +46,7 @@
var task = Broker.GetOrderConfirmationAsync(orderId, cts.Token);
await Dapr.PublishEventAsync("orderplaced", new Order()
await Dapr.PublishEventAsync("messagebus", "orderplaced", new Order()
{
ProductId = Product.Id,
OrderId = orderId,

Просмотреть файл

@ -1,6 +1,7 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
@ -63,9 +64,12 @@ namespace store
var broker = endpoints.ServiceProvider.GetRequiredService<OrdersEventBroker>();
endpoints.MapPost("/orderprocessed", async context =>
{
var confirmation = await JsonSerializer.DeserializeAsync<OrderConfirmation>(context.Request.Body);
var confirmation = await JsonSerializer.DeserializeAsync<OrderConfirmation>(context.Request.Body, new JsonSerializerOptions()
{
PropertyNameCaseInsensitive = true
});
broker.Complete(confirmation);
}).WithTopic("orderprocessed");
}).WithTopic("messagebus", "orderprocessed");
});
}
}

Просмотреть файл

@ -5,7 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapr.AspNetCore" Version="0.8.0-preview01" />
<PackageReference Include="Dapr.AspNetCore" Version="0.11.0-preview02" />
</ItemGroup>
</Project>