Skip to content

Commit

Permalink
fix: Properly publish V2 Event DTO to MessageBus as JSON (#2973)
Browse files Browse the repository at this point in the history
closes #2972

Signed-off-by: lenny <[email protected]>
  • Loading branch information
lenny-goodell authored Dec 29, 2020
1 parent c8e0122 commit 0334f8c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions internal/core/data/v2/application/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,19 @@ func putEventOnQueue(evt dtos.Event, ctx context.Context, dic *di.Container) {
configuration := dataContainer.ConfigurationFrom(dic.Get)
correlationId := correlation.FromContext(ctx)

lc.Debug("Putting V2 API event on message queue", clients.CorrelationHeader, correlationId)
lc.Debug("Putting V2 Event DTO on message queue", clients.CorrelationHeader, correlationId)

var data []byte
var err error
// Re-marshal JSON content into bytes.
if clients.FromContext(ctx, clients.ContentType) == clients.ContentTypeJSON {
data, err = json.Marshal(evt)
if err != nil {
lc.Error(fmt.Sprintf("error marshaling event: %+v", evt), clients.CorrelationHeader, correlationId)
return
}

if len(clients.FromContext(ctx, clients.ContentType)) == 0 {
ctx = context.WithValue(ctx, clients.ContentType, clients.ContentTypeJSON)
}

data, err = json.Marshal(evt)
if err != nil {
lc.Error(fmt.Sprintf("error marshaling V2 Event DTO: %+v", evt), clients.CorrelationHeader, correlationId)
return
}

msgEnvelope := msgTypes.NewMessageEnvelope(data, ctx)
Expand Down

0 comments on commit 0334f8c

Please sign in to comment.