Skip to content

Instantly share code, notes, and snippets.

info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://127.0.0.1:5100
Microsoft.Hosting.Lifetime: Information: Now listening on: http://127.0.0.1:5100
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://127.0.0.1:5102
Microsoft.Hosting.Lifetime: Information: Now listening on: https://127.0.0.1:5102
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
Microsoft.Hosting.Lifetime: Information: Application started. Press Ctrl+C to shut down.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddControllers().AddDapr(builder => builder.UseHttpEndpoint(Configuration.GetValue<string>("DAPR_HTTP_ENDPOINT"))
.UseGrpcEndpoint(Configuration.GetValue<string>("DAPR_GRPC_ENDPOINT")));
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "DaprAdventures.PublisherService", Version = "v1" });
});
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"DAPR_HTTP_ENDPOINT": "http://localhost:5180",
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using DaprAdventures.PublisherService.Models;
using Dapr.Client;
namespace DaprAdventures.PublisherService.Controllers
INFO[1085] actor runtime started. actor idle timeout: 1h0m0s. actor scan interval: 30s app_id=publisher-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime.actor type=log ver=1.2.2
DEBU[1085] try to connect to placement service: dns:///localhost:50005 app_id=publisher-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime.actor.internal.placement type=log ver=1.2.2
DEBU[1085] user app did not subscribe to any topic app_id=publisher-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime type=log ver=1.2.2
DEBU[1085] app responded with subscriptions [] app_id=publisher-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime type=log ver=1.2.2
INFO[1085] dapr initialized. Status: Running. Init Elapsed 1.085427493e+06ms app_id=publisher-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime type=log ver=1.2.2
DEBU[1085] established connection to placement service at dns:///localhost:50005 app_id=publisher-service instance=Kshitijs-MacBook-Pro.local sco
INFO[0000] local service entry announced: subscriber-service -> 192.168.29.185:63682 app_id=subscriber-service instance=Kshitijs-MacBook-Pro.local scope=dapr.contrib type=log ver=1.2.2
INFO[0000] Initialized name resolution to mdns app_id=subscriber-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime type=log ver=1.2.2
INFO[0000] component loaded. name: envvar-secret-store, type: secretstores.local.env/v1 app_id=subscriber-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime type=log ver=1.2.2
INFO[0000] waiting for all outstanding components to be processed app_id=subscriber-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime type=log ver=1.2.2
INFO[0000] component loaded. name: pubsub, type: pubsub.azure.eventhubs/v1 app_id=subscriber-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime type=log ver=1.2.2
INFO[0000] all outstanding components processed app_id=subscriber-service instance=Kshitijs-MacBook-Pro.local scope=dapr.runtime type=log ve
[Topic("pubsub", "dapreventhub")]
[HttpPost("/receiver")]
public async Task<IActionResult> Subscriber(WeatherChange weatherChange)
{
// Deserialize incoming order summary
_logger.LogInformation("Received Weather: {@WeatherChange}", weatherChange);
return Ok();
}
[Topic("pubsub", "dapreventhub")]
[HttpPost("/receiver")]
public async Task<IActionResult> Subscriber(WeatherChange weatherChange)
{
// Deserialize incoming order summary
_logger.LogInformation("Received Weather: {@WeatherChange}", weatherChange);
return Ok();
}
app.UseEndpoints(endpoints =>
{
endpoints.MapSubscribeHandler();
endpoints.MapControllers();
});
@kshitijcode
kshitijcode / daprmapSubscribeHandler
Created July 7, 2021 12:28
MapSubscribeHandlerSnippet
app.UseEndpoints(endpoints =>
{
endpoints.MapSubscribeHandler();
endpoints.MapControllers();
});