<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>发布/订阅代理 on Dapr 文档库</title><link>https://v1-18.docs.dapr.io/zh-hans/operations/components/setup-pubsub/</link><description>Recent content in 发布/订阅代理 on Dapr 文档库</description><generator>Hugo</generator><language>zh-hans</language><atom:link href="https://v1-18.docs.dapr.io/zh-hans/operations/components/setup-pubsub/index.xml" rel="self" type="application/rss+xml"/><item><title>HowTo: 配置具有多个命名空间的 Pub/Sub 组件</title><link>https://v1-18.docs.dapr.io/zh-hans/operations/components/setup-pubsub/pubsub-namespaces/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/operations/components/setup-pubsub/pubsub-namespaces/</guid><description>&lt;p>在某些情况下，应用程序可能会跨多个命名空间分布，并通过 PubSub 共享队列或主题。在这种情况下，需要在每个命名空间中配置 PubSub 组件。&lt;/p>


&lt;div class="alert alert-primary" role="alert">
&lt;h4 class="alert-heading">注意&lt;/h4>

 命名空间是 Dapr 用于限定应用程序和组件范围的概念。本示例使用 Kubernetes 命名空间，但 Dapr 组件命名空间范围可以在任何支持的平台上使用。阅读 &lt;a href="https://v1-18.docs.dapr.io/zh-hans/operations/components/component-scopes/">How-To: 将组件限定到一个或多个应用程序&lt;/a> 以获取有关限定组件的更多信息。

&lt;/div>

&lt;p>本示例使用 &lt;a href="https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub">PubSub 示例&lt;/a>。Redis 安装和订阅者位于 &lt;code>namespace-a&lt;/code>，而发布者 UI 位于 &lt;code>namespace-b&lt;/code>。即使 Redis 安装在另一个命名空间，或者您使用托管云服务如 Azure ServiceBus、AWS SNS/SQS 或 GCP PubSub，该解决方案也同样适用。&lt;/p>
&lt;p>以下是使用命名空间的示例图。&lt;/p>
&lt;img src="https://v1-18.docs.dapr.io/images/pubsub-multiple-namespaces.png" width=1000>
&lt;br>&lt;/br>
&lt;p>下表显示了哪些资源部署到哪些命名空间：&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>资源&lt;/th>
 &lt;th>namespace-a&lt;/th>
 &lt;th>namespace-b&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>Redis 主节点&lt;/td>
 &lt;td>✅&lt;/td>
 &lt;td>❌&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Redis 副本&lt;/td>
 &lt;td>✅&lt;/td>
 &lt;td>❌&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Dapr 的 PubSub 组件&lt;/td>
 &lt;td>✅&lt;/td>
 &lt;td>✅&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Node 订阅者&lt;/td>
 &lt;td>✅&lt;/td>
 &lt;td>❌&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>Python 订阅者&lt;/td>
 &lt;td>✅&lt;/td>
 &lt;td>❌&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>React UI 发布者&lt;/td>
 &lt;td>❌&lt;/td>
 &lt;td>✅&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>


&lt;div class="alert alert-primary" role="alert">
&lt;h4 class="alert-heading">注意&lt;/h4>

 所有 pub/sub 组件都支持通过 &lt;a href="https://v1-18.docs.dapr.io/zh-hans/developing-applications/building-blocks/pubsub/pubsub-scopes/">命名空间或组件范围&lt;/a> 将 pub/sub 主题限制到特定应用程序。

&lt;/div>

&lt;h2 id="前提条件">前提条件&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://v1-18.docs.dapr.io/zh-hans/operations/hosting/kubernetes/kubernetes-deploy/">在 Kubernetes 上安装 Dapr&lt;/a>，因为 Dapr 在集群级别工作。&lt;/li>
&lt;li>检出并进入 &lt;a href="https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub">PubSub 快速入门&lt;/a> 的目录。&lt;/li>
&lt;/ul>
&lt;h2 id="设置-namespace-a">设置 &lt;code>namespace-a&lt;/code>&lt;/h2>
&lt;p>创建命名空间并切换 kubectl 使用它。&lt;/p></description></item></channel></rss>