Skip to content

Commit

Permalink
Adds dead letter topic example
Browse files Browse the repository at this point in the history
Signed-off-by: joshvanl <[email protected]>
  • Loading branch information
JoshVanL authored and mikeee committed Jul 2, 2024
1 parent ebda4ad commit dbdc439
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/bidipubsub/bidisub/bidisub.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf(">>Created client\n")

var deadLetterTopic = "deadletter"

// Streaming subscription for topic "sendorder" on pubsub component
// "messages". The given subscription handler is called when a message is
// received. The returned `stop` function is used to stop the subscription
// and close the connection.
stop, err := client.SubscribeWithHandler(context.Background(),
daprd.SubscriptionOptions{
PubsubName: "messages",
Topic: "sendorder",
PubsubName: "messages",
Topic: "sendorder",
DeadLetterTopic: &deadLetterTopic,
},
eventHandler,
)
Expand All @@ -49,9 +51,11 @@ func main() {
// Another method of streaming subscriptions, this time for the topic "neworder".
// The returned `sub` object is used to receive messages.
// `sub` must be closed once it's no longer needed.

sub, err := client.Subscribe(context.Background(), daprd.SubscriptionOptions{
PubsubName: "messages",
Topic: "neworder",
PubsubName: "pubsub",
Topic: "neworder",
DeadLetterTopic: &deadLetterTopic,
})
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit dbdc439

Please sign in to comment.