Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outbox pattern Pub-Sub wrong cloudevent datacontenttype and missing OTEL info. #7047

Closed
GFlisch opened this issue Oct 16, 2023 · 1 comment · Fixed by #7198
Closed

Outbox pattern Pub-Sub wrong cloudevent datacontenttype and missing OTEL info. #7047

GFlisch opened this issue Oct 16, 2023 · 1 comment · Fixed by #7198
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@GFlisch
Copy link

GFlisch commented Oct 16, 2023

In what area(s)?

/area runtime

What version of Dapr?

1.2.x

Expected Behavior

When using the outbox pattern in v1.12, the CloudEvent message must have all the field filled like in a normal pub-sub event.

{
"messageId": "sxauFohHeQwaDAjExBCzWl",
"metadata": "{"cloudevent.type":"licmanager.contract.company.created"}",
"body": {
"data": {
"billingAddress": {
"city": "Wsp",
"country": "Belgium",
"postalCode": "1150",
"stateProvince": "Brussels",
"streetAddress": "Avenue des Cerisiers"
},
"id": "2e48c277-8edf-4b34-be8f-40ad0dd942f2",
"name": "Test1",
"vat": null
},
"datacontenttype": "application/json",
"id": "786ce798-9055-4b05-8ee7-adef60d817b5",
"pubsubname": "contract-only-pubsub",
"source": "licmanager-contract",
"specversion": "1.0",
"time": "2023-10-16T22:19:54+02:00",
"topic": "contract-domain-events",
"traceid": "00-90e2e408784262d4d9f62e802dfd7057-aaac747362a48de0-00",
"traceparent": "00-90e2e408784262d4d9f62e802dfd7057-aaac747362a48de0-00",
"tracestate": "",
"type": "licmanager.contract.company.created"
},
"timestamp": "2023-10-16 20:19:54",
"sequence": 23,
"tags": "{"ContentType":""}"
}

Actual Behavior

Some fields are not filled!

{
"messageId": "sxauFohHeQwaDAjExBCzeZ",
"body": {
"data": "{"Id":"2e48c277-8edf-4b34-be8f-40ad0dd942f2","Name":"Test1","VAT":null,"BillingAddress":{"StreetAddress":"Avenue des Cerisiers","City":"Wsp","PostalCode":"1150","StateProvince":"Brussels","Country":"Belgium"}}",
"datacontenttype": "text/plain",
"id": "944cecf8-d45b-41b0-9529-e09d830adf33",
"pubsubname": "contract-only-pubsub",
"source": "licmanager-contract",
"specversion": "1.0",
"time": "2023-10-16T22:22:54+02:00",
"topic": "contract-domain-events",
"traceid": "",
"traceparent": "",
"tracestate": "",
"type": "com.dapr.event.sent"
},
"timestamp": "2023-10-16 20:22:54",
"sequence": 24,
"tags": "{"ContentType":"text/plain"}"
}

The DataContent type is also not correct => text/plain instead of application/json

Steps to Reproduce the Problem

  1. define an outbox entry
    apiVersion: dapr.io/v1alpha1
    kind: Component
    metadata:
    name: contract-outbox
    spec:
    type: state.redis
    version: v1
    metadata:
  • name: redisHost
    value: localhost:6379
  • name: redisPassword
    value: ""
  • name: outboxPublishPubsub # Required
    value: "contract-only-pubsub"
  • name: outboxPublishTopic # Required
    value: "contract-domain-events"
  1. Add the pub-sub
    apiVersion: dapr.io/v1alpha1
    kind: Component
    metadata:
    name: contract-only-pubsub
    spec:
    type: pubsub.kubemq
    version: v1
    metadata:
    • name: address
      value: "localhost:40000"
    • name: store
      value: true
    • name: group
      value: licmanage-contract
      scopes:
  • licmanager-contract
  1. The Subscription

apiVersion: dapr.io/v2alpha1
kind: Subscription
metadata:
name: user
spec:
topic: contract-domain-events
pubsubname: contract-only-pubsub
routes:
default: /dapr/outboxevent
deadLetterTopic: poisonMessages

scopes:

  • licmanager-contract
  1. Test with pub-sub

    var entity = _mapper.Map(entityResult.Value);
    await _dapr.PublishEventAsync("contract-only-pubsub", "contract-domain-events", entity, cancellationToken: cancellationToken, metadata: new Dictionary<string, string> { { "cloudevent.type", "licmanager.contract.company.created" } })).ConfigureAwait(false);

Give the correct message!

  1. Use the outbox pattern

     var entity = _mapper.Map<CompanyCreated>(entityResult.Value);
    
     var requests = new List<StateTransactionRequest>()
             {
                 new($"{entity.Id}",
                     _serializer.Serialize(entity) ,
                     StateOperationType.Upsert,
                     metadata:new Dictionary<string, string> { { "ttlInSeconds", "60" } })
     };
    
    
     await  _dapr.ExecuteStateTransactionAsync("contract-outbox", requests, cancellationToken: cancellationToken).ConfigureAwait(false);
    

=> will give the expected message.

RELEASE NOTE:

@GFlisch GFlisch added the kind/bug Something isn't working label Oct 16, 2023
@yaron2
Copy link
Member

yaron2 commented Oct 17, 2023

Extending outbox with the ability to set metadata for the cloud-event is what's needed to support this, and this is a good feature request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants