Skip to content

Commit cbf728a

Browse files
authored
Merge pull request #138 from cnblogs/log-more-for-dapr
fix: event serialize problem
2 parents 5474bc9 + 9699ea3 commit cbf728a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Cnblogs.Architecture.Ddd.EventBus.Dapr/DaprEventBusProvider.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ public DaprEventBusProvider(
3434
public async Task PublishAsync(string eventName, IntegrationEvent @event)
3535
{
3636
_logger.LogInformation(
37-
"Publishing IntegrationEvent, Name: {EventName}, Body: {Event}, TraceId: {TraceId}",
37+
"Publishing IntegrationEvent, PubSub: {PubSubName}, TopicName: {TopicName}, Name: {EventName}, Body: {Event}, TraceId: {TraceId}",
38+
DaprOptions.PubSubName,
39+
DaprUtils.GetDaprTopicName(_daprOptions.AppName, eventName),
3840
eventName,
3941
@event,
4042
@event.TraceId ?? @event.Id);
43+
object data = @event; // do not provide type information to serializer since it's base class.
4144
await _daprClient.PublishEventAsync(
4245
DaprOptions.PubSubName,
4346
DaprUtils.GetDaprTopicName(_daprOptions.AppName, eventName),
44-
@event);
47+
data);
4548
}
4649
}

src/Cnblogs.Architecture.Ddd.EventBus.Dapr/EndPointExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private static void EnsureEventBusRegistered(this IEndpointRouteBuilder builder,
144144
if (!serviceCheck.IsService(typeof(IEventBus)))
145145
{
146146
throw new InvalidOperationException(
147-
$"{nameof(IEventBus)} has not been registered. Did you forget to call IServiceCollection.AddDaprEventBus()?");
147+
$"{nameof(IEventBus)} has not been registered. Did you forget to call IServiceCollection.AddEventBus()?");
148148
}
149149

150150
daprOptions.IsEventBusRegistered = true;

0 commit comments

Comments
 (0)