<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Publish &amp; subscribe messaging on Dapr Docs</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/</link><description>Recent content in Publish &amp; subscribe messaging on Dapr Docs</description><generator>Hugo</generator><language>en</language><atom:link href="https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/index.xml" rel="self" type="application/rss+xml"/><item><title>Publish and subscribe overview</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-overview/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-overview/</guid><description>&lt;p>Publish and subscribe (pub/sub) enables microservices to communicate with each other using messages for event-driven architectures.&lt;/p>
&lt;ul>
&lt;li>The producer, or &lt;strong>publisher&lt;/strong>, writes messages to an input channel and sends them to a topic, unaware which application will receive them.&lt;/li>
&lt;li>The consumer, or &lt;strong>subscriber&lt;/strong>, subscribes to the topic and receives messages from an output channel, unaware which service produced these messages.&lt;/li>
&lt;/ul>
&lt;p>An intermediary message broker copies each message from a publisher&amp;rsquo;s input channel to an output channel for all subscribers interested in that message. This pattern is especially useful when you need to decouple microservices from one another.&lt;/p></description></item><item><title>How to: Publish a message and subscribe to a topic</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/howto-publish-subscribe/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/howto-publish-subscribe/</guid><description>&lt;p>Now that you&amp;rsquo;ve learned what the Dapr pub/sub building block provides, learn how it can work in your service. The below code example loosely describes an application that processes orders with two services, each with Dapr sidecars:&lt;/p>
&lt;ul>
&lt;li>A checkout service using Dapr to subscribe to the topic in the message queue.&lt;/li>
&lt;li>An order processing service using Dapr to publish a message to RabbitMQ.&lt;/li>
&lt;/ul>
&lt;img src="https://v1-18.docs.dapr.io/images/pubsub-howto-overview.png" width=1000 alt="Diagram showing state management of example service">
&lt;p>Dapr automatically wraps the user payload in a CloudEvents v1.0 compliant envelope, using &lt;code>Content-Type&lt;/code> header value for &lt;code>datacontenttype&lt;/code> attribute. &lt;a href="https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-cloudevents/">Learn more about messages with CloudEvents.&lt;/a>&lt;/p></description></item><item><title>Publishing &amp; subscribing messages with Cloudevents</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-cloudevents/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-cloudevents/</guid><description>&lt;p>To enable message routing and provide additional context with each message, Dapr uses the &lt;a href="https://github.com/cloudevents/spec/tree/v1.0">CloudEvents 1.0 specification&lt;/a> as its message format. Any message sent by an application to a topic using Dapr is automatically wrapped in a CloudEvents envelope, using the &lt;a href="https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-overview/#content-types">&lt;code>Content-Type&lt;/code> header value&lt;/a> for &lt;code>datacontenttype&lt;/code> attribute.&lt;/p>
&lt;p>Dapr uses CloudEvents to provide additional context to the event payload, enabling features like:&lt;/p>
&lt;ul>
&lt;li>Tracing&lt;/li>
&lt;li>Content-type for proper deserialization of event data&lt;/li>
&lt;li>Verification of sender application&lt;/li>
&lt;/ul>
&lt;p>You can choose any of three methods for publish a CloudEvent via pub/sub:&lt;/p></description></item><item><title>Publishing &amp; subscribing messages without CloudEvents</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-raw/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-raw/</guid><description>&lt;p>When adding Dapr to your application, some services may still need to communicate via pub/sub messages not encapsulated in CloudEvents, due to either compatibility reasons or some apps not using Dapr. These are referred to as &amp;ldquo;raw&amp;rdquo; pub/sub messages. Dapr enables apps to &lt;a href="https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-cloudevents/#publishing-raw-messages">publish and subscribe to raw events&lt;/a> not wrapped in a CloudEvent for compatibility and to send data that is not JSON serializable.&lt;/p>
&lt;h2 id="publishing-raw-messages">Publishing raw messages&lt;/h2>
&lt;p>Dapr apps are able to publish raw events to pub/sub topics without CloudEvent encapsulation, for compatibility with non-Dapr apps.&lt;/p></description></item><item><title>How-To: Route messages to different event handlers</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/howto-route-messages/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/howto-route-messages/</guid><description>&lt;p>Pub/sub routing is an implementation of &lt;a href="https://www.enterpriseintegrationpatterns.com/ContentBasedRouter.html">content-based routing&lt;/a>, a messaging pattern that utilizes a DSL instead of imperative application code. With pub/sub routing, you use expressions to route &lt;a href="https://cloudevents.io">CloudEvents&lt;/a> (based on their contents) to different URIs/paths and event handlers in your application. If no route matches, then an optional default route is used. This proves useful as your applications expand to support multiple event versions or special cases.&lt;/p>
&lt;p>While routing can be implemented with code, keeping routing rules external from the application can improve portability.&lt;/p></description></item><item><title>Declarative, streaming, and programmatic subscription types</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/subscription-methods/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/subscription-methods/</guid><description>&lt;h2 id="pubsub-api-subscription-types">Pub/sub API subscription types&lt;/h2>
&lt;p>Dapr applications can subscribe to published topics via three subscription types that support the same features: declarative, streaming and programmatic.&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>Subscription type&lt;/th>
 &lt;th>Description&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;a href="https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/subscription-methods/#declarative-subscriptions">&lt;strong>Declarative&lt;/strong>&lt;/a>&lt;/td>
 &lt;td>Subscription is defined in an &lt;strong>external file&lt;/strong>. The declarative approach removes the Dapr dependency from your code and allows for existing applications to subscribe to topics, without having to change code.&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/subscription-methods/#streaming-subscriptions">&lt;strong>Streaming&lt;/strong>&lt;/a>&lt;/td>
 &lt;td>Subscription is defined in the &lt;strong>application code&lt;/strong>. Streaming subscriptions are dynamic, meaning they allow for adding or removing subscriptions at runtime. They do not require a subscription endpoint in your application (that is required by both programmatic and declarative subscriptions), making them easy to configure in code. Streaming subscriptions also do not require an app to be configured with the sidecar to receive messages.&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;a href="https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/subscription-methods/#programmatic-subscriptions">&lt;strong>Programmatic&lt;/strong>&lt;/a>&lt;/td>
 &lt;td>Subscription is defined in the &lt;strong>application code&lt;/strong>. The programmatic approach implements the static subscription and requires an endpoint in your code.&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>The examples below demonstrate pub/sub messaging between a &lt;code>checkout&lt;/code> app and an &lt;code>orderprocessing&lt;/code> app via the &lt;code>orders&lt;/code> topic. The examples demonstrate the same Dapr pub/sub component used first declaratively, then programmatically.&lt;/p></description></item><item><title>Dead Letter Topics</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-deadletter/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-deadletter/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>There are times when applications might not be able to handle messages for a variety of reasons. For example, there could be transient issues retrieving data needed to process a message or the app business logic fails returning an error. Dead letter topics are used to forward messages that cannot be delivered to a subscribing app. This eases the pressure on app by freeing them from dealing with these failed messages, allowing developers to write code that reads from the dead letter topic and either fixes the message and resends this, or abandons it completely.&lt;/p></description></item><item><title>How to: Set up pub/sub namespace consumer groups</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/howto-namespace/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/howto-namespace/</guid><description>&lt;p>You&amp;rsquo;ve set up &lt;a href="https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-overview/">Dapr&amp;rsquo;s pub/sub API building block&lt;/a>, and your applications are publishing and subscribing to topics smoothly, using a centralized message broker. What if you&amp;rsquo;d like to perform simple A/B testing, blue/green deployments, or even canary deployments for your applications? Even with using Dapr, this can prove difficult.&lt;/p>
&lt;p>Dapr solves multi-tenancy at-scale with its pub/sub namespace consumer groups construct.&lt;/p>
&lt;h2 id="without-namespace-consumer-groups">Without namespace consumer groups&lt;/h2>
&lt;p>Let&amp;rsquo;s say you have a Kubernetes cluster, with two applications (App1 and App2) deployed to the same namespace (namespace-a). App2 publishes to a topic called &lt;code>order&lt;/code>, while App1 subscribes to the topic called &lt;code>order&lt;/code>. This will create two consumer groups, named after your applications (App1 and App2).&lt;/p></description></item><item><title>How to: Horizontally scale subscribers with StatefulSets</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/howto-subscribe-statefulset/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/howto-subscribe-statefulset/</guid><description>&lt;p>Unlike Deployments, where Pods are ephemeral, &lt;a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/">StatefulSets&lt;/a> allows deployment of stateful applications on Kubernetes by keeping a sticky identity for each Pod.&lt;/p>
&lt;p>Below is an example of a StatefulSet with Dapr:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">apiVersion&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">apps/v1&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">kind&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">StatefulSet&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">metadata&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">python-subscriber&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">spec&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">selector&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">matchLabels&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">app&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">python-subscriber &lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># has to match .spec.template.metadata.labels&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">serviceName&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;python-subscriber&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">replicas&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#0000cf;font-weight:bold">3&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">template&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">metadata&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">labels&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">app&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">python-subscriber&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># has to match .spec.selector.matchLabels&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">annotations&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">dapr.io/enabled&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;true&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">dapr.io/app-id&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;python-subscriber&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">dapr.io/app-port&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;5001&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">spec&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">containers&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>- &lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">python-subscriber&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">image&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">ghcr.io/dapr/samples/pubsub-python-subscriber:latest&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">ports&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>- &lt;span style="color:#204a87;font-weight:bold">containerPort&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#0000cf;font-weight:bold">5001&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">imagePullPolicy&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">Always&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>When subscribing to a pub/sub topic via Dapr, the application can define the &lt;code>consumerID&lt;/code>, which determines the subscriber&amp;rsquo;s position in the queue or topic. With the StatefulSets sticky identity of Pods, you can have a unique &lt;code>consumerID&lt;/code> per Pod, allowing each horizontal scale of the subscriber application. Dapr keeps track of the name of each Pod, which can be used when declaring components using the &lt;code>{podName}&lt;/code> marker.&lt;/p></description></item><item><title>Scope Pub/sub topic access</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-scopes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-scopes/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>&lt;a href="https://v1-18.docs.dapr.io/operations/components/component-scopes/">Namespaces or component scopes&lt;/a> can be used to limit component access to particular applications. These application scopes added to a component limit only the applications with specific IDs to be able to use the component.&lt;/p>
&lt;p>In addition to this general component scope, the following can be limited for pub/sub components:&lt;/p>
&lt;ul>
&lt;li>Which topics can be used (published or subscribed)&lt;/li>
&lt;li>Which applications are allowed to publish to specific topics&lt;/li>
&lt;li>Which applications are allowed to subscribe to specific topics&lt;/li>
&lt;/ul>
&lt;p>This is called &lt;strong>pub/sub topic scoping&lt;/strong>.&lt;/p></description></item><item><title>Message Time-to-Live (TTL)</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-message-ttl/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-message-ttl/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>Dapr enables per-message time-to-live (TTL). This means that applications can set time-to-live per message, and subscribers do not receive those messages after expiration.&lt;/p>
&lt;p>All Dapr &lt;a href="https://v1-18.docs.dapr.io/reference/components-reference/supported-pubsub/">pub/sub components&lt;/a> are compatible with message TTL, as Dapr handles the TTL logic within the runtime. Simply set the &lt;code>ttlInSeconds&lt;/code> metadata when publishing a message.&lt;/p>
&lt;p>In some components, such as Kafka, time-to-live can be configured in the topic via &lt;code>retention.ms&lt;/code> as per &lt;a href="https://kafka.apache.org/documentation/#topicconfigs_retention.ms">documentation&lt;/a>. With message TTL in Dapr, applications using Kafka can now set time-to-live per message in addition to per topic.&lt;/p></description></item><item><title>Publish and subscribe to bulk messages</title><link>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-bulk/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/developing-applications/building-blocks/pubsub/pubsub-bulk/</guid><description>&lt;p>With the bulk publish and subscribe APIs, you can publish and subscribe to multiple messages in a single request. When writing applications that need to send or receive a large number of messages, using bulk operations allows achieving high throughput by reducing the overall number of requests between the Dapr sidecar, the application, and the underlying pub/sub broker.&lt;/p>
&lt;h2 id="publishing-messages-in-bulk">Publishing messages in bulk&lt;/h2>
&lt;h3 id="restrictions-when-publishing-messages-in-bulk">Restrictions when publishing messages in bulk&lt;/h3>
&lt;p>The bulk publish API allows you to publish multiple messages to a topic in a single request. It is &lt;em>non-transactional&lt;/em>, i.e., from a single bulk request, some messages can succeed and some can fail. If any of the messages fail to publish, the bulk publish operation returns a list of failed messages.&lt;/p></description></item></channel></rss>