Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 479ce00

Browse files
JeffNeffSameer Naik
andauthored
Creates a Dead Letter Sink Guide (#271)
* Creates a DLS Guide. * Update creatingadls.md * Update creatingadls.md * applied review suggestions Co-authored-by: Sameer Naik <[email protected]>
1 parent fa3408e commit 479ce00

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

docs/guides/creatingadls.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Creating a Bridge With a Dead Letter Sink (DLS)
2+
3+
## What is a Dead Letter Sink?
4+
5+
TriggerMesh provides various configuration parameters to control the delivery of events in case of failure. For instance, you can decide to retry sending events that failed to be consumed, and if this didn't work you can decide to forward those events to a dead letter sink.
6+
7+
## Implementing a Dead Letter Sink
8+
9+
There are two ways to implement a dead letter sink, either by use of a Subscription or by use of a Broker.
10+
11+
### Subscription Configuration
12+
13+
You can configure how events are delivered for each Subscription by adding a delivery spec to the Subscription object, as shown in the following example:
14+
15+
```yaml
16+
apiVersion: messaging.knative.dev/v1
17+
kind: Subscription
18+
metadata:
19+
name: example-subscription
20+
namespace: example-namespace
21+
spec:
22+
delivery:
23+
deadLetterSink:
24+
ref:
25+
apiVersion: serving.knative.dev/v1
26+
kind: Service
27+
name: example-sink
28+
backoffDelay: <duration>
29+
backoffPolicy: <policy-type>
30+
retry: <integer>
31+
```
32+
33+
Where:
34+
35+
The `deadLetterSink` spec contains configuration settings to enable using a dead letter sink. This tells the Subscription what happens to events that cannot be delivered to the subscriber. When this is configured, events that fail to be delivered are sent to the dead letter sink destination. The destination can be a Knative Service or a URI. In the example, the destination is a Service object, or Knative Service, named example-sink.
36+
37+
The `backoffDelay` delivery parameter specifies the time delay before an event delivery retry is attempted after a failure. The duration of the backoffDelay parameter is specified using the ISO 8601 format. For example, PT1S specifies a 1 second delay.
38+
39+
The `backoffPolicy` delivery parameter can be used to specify the retry back off policy. The policy can be specified as either linear or exponential. When using the linear back off policy, the back off delay is the time interval specified between retries. When using the exponential back off policy, the back off delay is equal to backoffDelay*2^<numberOfRetries>.
40+
retry specifies the number of times that event delivery is retried before the event is sent to the dead letter sink.
41+
42+
43+
### Broker Configuration
44+
45+
You can configure how events are delivered for each Broker by adding a delivery spec, as shown in the following example:
46+
47+
```yaml
48+
apiVersion: eventing.knative.dev/v1
49+
kind: Broker
50+
metadata:
51+
name: with-dead-letter-sink
52+
spec:
53+
delivery:
54+
deadLetterSink:
55+
ref:
56+
apiVersion: serving.knative.dev/v1
57+
kind: Service
58+
name: example-sink
59+
backoffDelay: <duration>
60+
backoffPolicy: <policy-type>
61+
retry: <integer>
62+
```
63+
64+
### Example Broker Configuration
65+
66+
Lets take a look at an example of a Broker with a dead letter sink and configure a simple bridge with a dead letter sink. For our discussion, let us consider [this example Bridge](../assets/yamlexamples/simple-bridge.yaml) as a starting point:
67+
68+
```yaml
69+
apiVersion: eventing.knative.dev/v1
70+
kind: Broker
71+
metadata:
72+
name: events
73+
---
74+
apiVersion: sources.knative.dev/v1
75+
kind: PingSource
76+
metadata:
77+
name: ping-sockeye
78+
spec:
79+
data: '{"name": "triggermesh"}'
80+
schedule: "*/1 * * * *"
81+
sink:
82+
ref:
83+
apiVersion: eventing.knative.dev/v1
84+
kind: Broker
85+
name: events
86+
```
87+
88+
Now, lets modify this example to add a dead letter sink to the `Broker`. We can accomplish this in two steps:
89+
90+
1. Add a service to catch the "dead letter" events. (We will be using `Sockeye` here, but in a production scenario you would want to use something like SQS, Kafka, or another Sink that has some form of persistence.)
91+
92+
```yaml
93+
---
94+
apiVersion: serving.knative.dev/v1
95+
kind: Service
96+
metadata:
97+
name: sockeye
98+
spec:
99+
template:
100+
spec:
101+
containers:
102+
- image: docker.io/n3wscott/sockeye:v0.7.0@sha256:e603d8494eeacce966e57f8f508e4c4f6bebc71d095e3f5a0a1abaf42c5f0e48
103+
```
104+
105+
2. Update the `Broker` section to the following:
106+
107+
```yaml
108+
---
109+
apiVersion: eventing.knative.dev/v1
110+
kind: Broker
111+
metadata:
112+
name: events
113+
spec:
114+
delivery:
115+
deadLetterSink:
116+
ref:
117+
apiVersion: serving.knative.dev/v1
118+
kind: Service
119+
name: sockeye
120+
backoffDelay: "PT0.5S" # or ISO8601 duration
121+
backoffPolicy: exponential # or linear
122+
retry: 2
123+
```
124+
125+
## Viewing the Results of a Dead Letter Sink
126+
127+
Now that we have all the parts in place, we can monitor the events that are being sent to the dead letter sink. We can do this in two ways:
128+
129+
1. View the pod logs of the `sockeye` service:
130+
* `kubectl get pods` will show the pods that are running. Retrieve the sockeye pod name from the output.
131+
* `kubectl logs <SOCKEYE_POD_NAME> user-container` By replacing the `<SOCKEYE_POD_NAME>` with the pod name you can view the logs of the sockeye pod.
132+
133+
2. View the web service exposed by the `sockeye` service:
134+
* `kubectl get ksvc` will show the KSVC's that are running. Retrieve the sockeye public URL from the `URL` column and navigate to it in your browser.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ nav:
4343
- Guides:
4444
- Creating a Source: guides/creatingasource.md
4545
- Creating a Target: guides/creatingatarget.md
46+
- Creating a DLS: guides/creatingadls.md
4647
- Creating a Wiretap: guides/createawiretap.md
4748
- Writing a Filter: guides/writingafilter.md
4849
- Creating a Splitter: guides/creatingasplitter.md

0 commit comments

Comments
 (0)