Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

add bulk pubsub example for js #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Eileen-Yu
Copy link

@Eileen-Yu Eileen-Yu commented Mar 5, 2024

Resolves: https://github.com/diagridio/issues/issues/2733

As discussed in https://github.com/diagridio/issues/issues/2733#issuecomment-1973571828, we need to add bulk pubsub example code additionally to make it compatible with dapr.

tips: the bulk pubsub would use routes pubsub/bulk-orders and pubsub/bulk-neworders, so make sure you setup catalyst resources correctly before trying it :)

I did manual test, and believe this help to drop unexpected retries and let consumer only receive bulk events exactly once: (feel free to change entryId and event to any string)

curl -X POST http://localhost:5001/pubsub/bulk-orders \
  -H 'Content-Type: application/json' \
  -d '[
        {
            "entryId": "1",
            "event":  "first text message..........1111111111",
            "contentType": "text/plain"
        },
        {
            "entryId": "2",
            "event":  {
                "message": "second JSON message......22222222222"
            },
            "contentType": "application/json"
        }
      ]'

OK%
Screenshot 2024-03-07 at 8 56 17 AM Screenshot 2024-03-07 at 8 56 25 AM Screenshot 2024-03-05 at 2 29 36 PM

@Eileen-Yu Eileen-Yu requested a review from famarting March 5, 2024 22:31
@Eileen-Yu Eileen-Yu temporarily deployed to shared-production March 5, 2024 22:32 — with GitHub Actions Inactive
@famarting
Copy link
Collaborator

@kendallroden fyi, wdyt?

@Eileen-Yu Eileen-Yu temporarily deployed to shared-production March 7, 2024 16:51 — with GitHub Actions Inactive
@Eileen-Yu
Copy link
Author

Eileen-Yu commented Mar 7, 2024

tips: the bulk pubsub would use routes pubsub/bulk-orders and pubsub/bulk-neworders, so make sure you setup catalyst resources correctly before trying it :)

@kendallroden
Copy link
Collaborator

lets change the events to match the order domain please

@Eileen-Yu
Copy link
Author

Eileen-Yu commented Mar 12, 2024

lets change the events to match the order domain please

As per discussion the HTTP request sample can be changed flexibly. To make it more align with existing samples, something maybe:

curl -X POST http://localhost:5001/pubsub/bulk-orders \
  -H 'Content-Type: application/json' \
  -d '[
        {
            "entryId": "0",
            "event":  "orderId: 1",
            "contentType": "text/plain"
        },
        {
            "entryId": "1",
            "event":  {
                "message": "orderId: 2"
            },
            "contentType": "application/json"
        }
      ]'

OK%

@famarting
Copy link
Collaborator

lets change the events to match the order domain please

what do you mean "the order domain" ?

@Eileen-Yu
Copy link
Author

what do you mean "the order domain" ?

chatted with @kendallroden and she expected the HTTP sample text can align with the existing order sample for pubsub, so I left this comment

guess we can design it more carefully when updating related docs

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants