Skip to content

Commit dbdc439

Browse files
JoshVanLmikeee
authored andcommitted
Adds dead letter topic example
Signed-off-by: joshvanl <[email protected]>
1 parent ebda4ad commit dbdc439

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

examples/bidipubsub/bidisub/bidisub.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ func main() {
2929
if err != nil {
3030
log.Fatal(err)
3131
}
32-
fmt.Printf(">>Created client\n")
32+
33+
var deadLetterTopic = "deadletter"
3334

3435
// Streaming subscription for topic "sendorder" on pubsub component
3536
// "messages". The given subscription handler is called when a message is
3637
// received. The returned `stop` function is used to stop the subscription
3738
// and close the connection.
3839
stop, err := client.SubscribeWithHandler(context.Background(),
3940
daprd.SubscriptionOptions{
40-
PubsubName: "messages",
41-
Topic: "sendorder",
41+
PubsubName: "messages",
42+
Topic: "sendorder",
43+
DeadLetterTopic: &deadLetterTopic,
4244
},
4345
eventHandler,
4446
)
@@ -49,9 +51,11 @@ func main() {
4951
// Another method of streaming subscriptions, this time for the topic "neworder".
5052
// The returned `sub` object is used to receive messages.
5153
// `sub` must be closed once it's no longer needed.
54+
5255
sub, err := client.Subscribe(context.Background(), daprd.SubscriptionOptions{
53-
PubsubName: "messages",
54-
Topic: "neworder",
56+
PubsubName: "pubsub",
57+
Topic: "neworder",
58+
DeadLetterTopic: &deadLetterTopic,
5559
})
5660
if err != nil {
5761
log.Fatal(err)

0 commit comments

Comments
 (0)