简体   繁体   English

使用 Java/Spring 连接到 Azure 事件网格和服务总线

[英]Connecting to Azure Event Grid and Service Bus using Java/Spring

I have a scenario where Azure ServiceBus sends events to Event Grid whenever there is a message in Azure Service bus's queue/topic.我有一个场景,只要 Azure 服务总线的队列/主题中有消息,Azure ServiceBus就会将事件发送到事件网格 So how do I establish the connection in Java/Spring with Event Grid to receive events and also with Service Bus to pull the messages.那么如何在 Java/Spring 中与 Event Grid 建立连接以接收事件以及与 Service Bus 建立连接以提取消息。 What are the configurations are to be done in Java/Spring to establish connections with Event Grid and Azure Service bus?在 Java/Spring 中要进行哪些配置才能与 Event Grid 和 Azure 服务总线建立连接? Also what are the configuration that has to be done on the application side(application.yml or properties file) to include things like connection string and etc.?此外,必须在应用程序端(application.yml 或属性文件)进行哪些配置才能包含连接字符串等内容?

Azure Service Bus to Event Grid integration Azure 服务总线到事件网格集成

Service Bus can now emit events to Event Grid when there are messages in a queue or a subscription when no receivers are present.服务总线现在可以在队列中有消息时向事件网格发出事件,或者在没有接收者的情况下订阅。 You can create Event Grid subscriptions to your Service Bus namespaces, listen to these events, and then react to the events by starting a receiver.您可以为服务总线命名空间创建事件网格订阅,侦听这些事件,然后通过启动接收器对事件做出反应。

To enable the feature, you need the following items:要启用该功能,您需要以下项目:

  • A Service Bus Premium namespace with at least one Service Bus queue or a Service Bus topic with at least one subscription.具有至少一个服务总线队列的服务总线高级命名空间或具有至少一个订阅的服务总线主题。
  • Contributor access to the Service Bus namespace.对服务总线命名空间的贡献者访问。 Navigate to your Service Bus namespace in the Azure portal, and then select Access control (IAM), and select Role assignments tab.导航到 Azure 门户中的服务总线命名空间,然后导航到 select 访问控制 (IAM) 和 select 角色分配选项卡。 Verify that you have the contributor access to the namespace.验证您是否具有对该命名空间的贡献者访问权限。
  • Additionally, you need an Event Grid subscription for the Service Bus namespace.此外,您需要服务总线命名空间的事件网格订阅。 This subscription receives a notification from Event Grid that there are messages to be picked up.此订阅接收来自事件网格的通知,表明有消息要提取。 Typical subscribers could be the Logic Apps feature of Azure App Service, Azure Functions, or a webhook contacting a web app.典型的订阅者可能是 Azure 应用服务、Azure 功能的逻辑应用功能,或联系 web 应用的 webhook。 The subscriber then processes the messages.然后订阅者处理消息。

在此处输入图像描述

Check this Microsoft document for more info.查看此Microsoft 文档以获取更多信息。

Check this one to use Azure Function to connect both.选中此项以使用 Azure Function 连接两者。

Check this doc to use Logic App to connect both.检查此文档以使用Logic App连接两者。

Azure CLI: Azure CLI:

namespaceid=$(az resource show --namespace Microsoft.ServiceBus --resource-type namespaces --name "<service bus namespace>" --resource-group "<resource group that contains the service bus namespace>" --query id --output tsv

az eventgrid event-subscription create --resource-id $namespaceid --name "<YOUR EVENT GRID SUBSCRIPTION NAME>" --endpoint "<your_endpoint_url>" --subject-ends-with "<YOUR SERVICE BUS SUBSCRIPTION NAME>"

Powershell: Powershell:

$namespaceID = (Get-AzServiceBusNamespace -ResourceGroupName "<YOUR RESOURCE GROUP NAME>" -NamespaceName "<YOUR NAMESPACE NAME>").Id

New-AzEVentGridSubscription -EventSubscriptionName "<YOUR EVENT GRID SUBSCRIPTION NAME>" -ResourceId $namespaceID -Endpoint "<YOUR ENDPOINT URL>” -SubjectEndsWith "<YOUR SERVICE BUS SUBSCRIPTION NAME>"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Java中使用Azure Service Bus - Using Azure Service Bus in java 使用Java SDK 0.9.7通过代理服务器连接到Azure服务总线 - Connecting to Azure service bus through a proxy server using Java SDK 0.9.7 使用 apache qpid-client 连接到 Azure 服务总线的问题 - Problem connecting to Azure service bus using apache qpid-client 使用托管标识连接 Azure 服务总线时出现 NumberFormatException - NumberFormatException in connecting Azure Service Bus using Managed Identity 如何在 Java 中使用 spring.cloud 反序列化/序列化 Azure 服务总线 - How to deserialize/serialize Azure Service Bus using spring.cloud in Java 使用Java和AMQP 1.0连接到Windows Server(1.1)上的Service Bus - Connecting to Service Bus on Windows Server (1.1) using Java and AMQP 1.0 使用 azure 服务总线和 spring 集成的多个队列 - Multiple queues using azure service bus and spring integration 带有 Azure 服务总线的 Java 应用程序 - Java application with azure service bus 带有Java的Azure Service总线中继 - Azure Service bus Relay with Java 使用 ServiceBusReceiverAsyncClient 的 Azure 服务总线不同时使用 Java - Azure service bus using ServiceBusReceiverAsyncClient not consuming concurrently Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM