public sealed class DeadLetterPolicy : IMessage<DeadLetterPolicy>, IEquatable<DeadLetterPolicy>, IDeepCloneable<DeadLetterPolicy>, IBufferMessage, IMessage
Reference documentation and code samples for the Cloud Pub/Sub v1 API class DeadLetterPolicy.
Dead lettering is done on a best effort basis. The same message might be
dead lettered multiple times.
If validation on any of the fields fails at subscription creation/updation,
the create/update subscription request will fail.
Optional. The name of the topic to which dead letter messages should be
published. Format is projects/{project}/topics/{topic}.The Pub/Sub
service account associated with the enclosing subscription's parent project
(i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must
have permission to Publish() to this topic.
The operation will fail if the topic does not exist.
Users should ensure that there is a subscription attached to this topic
since messages published to a topic with no subscriptions are lost.
Optional. The maximum number of delivery attempts for any message. The
value must be between 5 and 100.
The number of delivery attempts is defined as 1 + (the sum of number of
NACKs and number of times the acknowledgment deadline has been exceeded
for the message).
A NACK is any call to ModifyAckDeadline with a 0 deadline. Note that
client libraries may automatically extend ack_deadlines.
This field will be honored on a best effort basis.
If this parameter is 0, a default value of 5 is used.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eDeadLetterPolicy\u003c/code\u003e class in the \u003ccode\u003eGoogle.Cloud.PubSub.V1\u003c/code\u003e namespace is used to configure how messages that fail to be processed are handled within the Cloud Pub/Sub service.\u003c/p\u003e\n"],["\u003cp\u003eThis class allows for setting a \u003ccode\u003eDeadLetterTopic\u003c/code\u003e, which specifies the topic where dead letter messages will be published.\u003c/p\u003e\n"],["\u003cp\u003eIt also enables setting \u003ccode\u003eMaxDeliveryAttempts\u003c/code\u003e, which defines the maximum number of attempts to deliver a message before it is considered dead-lettered, with a default value of 5 if not set, and having to be between 5-100.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of \u003ccode\u003eDeadLetterPolicy\u003c/code\u003e is 3.23.0, with a comprehensive history of prior versions dating back to 2.3.0.\u003c/p\u003e\n"],["\u003cp\u003eThe dead lettering of messages is on a best effort basis, and messages could be dead lettered more than once.\u003c/p\u003e\n"]]],[],null,["# Cloud Pub/Sub v1 API - Class DeadLetterPolicy (3.27.0)\n\nVersion latestkeyboard_arrow_down\n\n- [3.27.0 (latest)](/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.26.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.26.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.25.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.25.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.24.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.24.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.23.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.23.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.22.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.22.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.21.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.21.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.20.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.20.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.19.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.19.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.18.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.18.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.17.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.17.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.16.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.16.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.15.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.15.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.14.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.13.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.12.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.11.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.10.1](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.10.1/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.9.1](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.9.1/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.8.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.7.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.6.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.5.1](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.5.1/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.4.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.3.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.2.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.1.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.1.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [3.0.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/3.0.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [2.10.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/2.10.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [2.9.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/2.9.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [2.8.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/2.8.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [2.7.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/2.7.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [2.6.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/2.6.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/2.5.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/2.4.0/Google.Cloud.PubSub.V1.DeadLetterPolicy)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.PubSub.V1/2.3.0/Google.Cloud.PubSub.V1.DeadLetterPolicy) \n\n public sealed class DeadLetterPolicy : IMessage\u003cDeadLetterPolicy\u003e, IEquatable\u003cDeadLetterPolicy\u003e, IDeepCloneable\u003cDeadLetterPolicy\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Cloud Pub/Sub v1 API class DeadLetterPolicy.\n\nDead lettering is done on a best effort basis. The same message might be\ndead lettered multiple times.\n\nIf validation on any of the fields fails at subscription creation/updation,\nthe create/update subscription request will fail. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e DeadLetterPolicy \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[DeadLetterPolicy](/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.DeadLetterPolicy), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[DeadLetterPolicy](/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.DeadLetterPolicy), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[DeadLetterPolicy](/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1.DeadLetterPolicy), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.PubSub.V1](/dotnet/docs/reference/Google.Cloud.PubSub.V1/latest/Google.Cloud.PubSub.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.PubSub.V1.dll\n\nConstructors\n------------\n\n### DeadLetterPolicy()\n\n public DeadLetterPolicy()\n\n### DeadLetterPolicy(DeadLetterPolicy)\n\n public DeadLetterPolicy(DeadLetterPolicy other)\n\nProperties\n----------\n\n### DeadLetterTopic\n\n public string DeadLetterTopic { get; set; }\n\nOptional. The name of the topic to which dead letter messages should be\npublished. Format is `projects/{project}/topics/{topic}`.The Pub/Sub\nservice account associated with the enclosing subscription's parent project\n(i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must\nhave permission to Publish() to this topic.\n\nThe operation will fail if the topic does not exist.\nUsers should ensure that there is a subscription attached to this topic\nsince messages published to a topic with no subscriptions are lost.\n\n### MaxDeliveryAttempts\n\n public int MaxDeliveryAttempts { get; set; }\n\nOptional. The maximum number of delivery attempts for any message. The\nvalue must be between 5 and 100.\n\nThe number of delivery attempts is defined as 1 + (the sum of number of\nNACKs and number of times the acknowledgment deadline has been exceeded\nfor the message).\n\nA NACK is any call to ModifyAckDeadline with a 0 deadline. Note that\nclient libraries may automatically extend ack_deadlines.\n\nThis field will be honored on a best effort basis.\n\nIf this parameter is 0, a default value of 5 is used."]]