簡體   English   中英

Azure EventHub上的Qpid接收器

[英]Qpid receiver on Azure EventHub

我已經有基於Azure EventHub的應用程序。 現在,我需要編寫連接到現有基礎結構的java接收器。 現有配置:

事件中心> SomeName >消費者組> SomeGroupName

在管理控制台中,我看不到任何QUEUE或TOPIC定義。 分析工作的C#代碼,我可以看到集線器名稱+組名稱足以連接。

我重構了URL,使我可以通過Java進行連接(到目前為止,連接仍然有效)。

amqps://SomeName.servicebus.windows.net

所以我的問題是:

1)當我不是隊列/ topic而是指定組名時,我得到了例外The messaging entity 'sb://SomeName.servicebus.windows.net/SomeGroupName' could not be found. 在那里使用的是什么模型而不是隊列/主題?

2)如何從Apache-qpid使用此類基礎結構?

您是使用在舊門戶中創建的事件中心還是使用新門戶中創建的事件中心?

EventHub不是消息總線,因此沒有隊列或主題,這是正確的。

消費者組不是地址的一部分。 該地址是使用名稱空間和該名稱空間中的eventhub的名稱構建的。

因此地址變為:

sb://SomeNameSpaceName.servicebus.windows.net/SomeEventHubName 

您可以發布您分析過的C#代碼嗎? 由於您已經有一個可以使用的應用程序,也許我們可以鍛煉一下阻止它現在無法正常運行的差異。

解決該問題的最大提示是給我以下鏈接: http : //theitjourney.blogspot.com/2015/12/sendreceive-messages-using-amqp-in-java.html

因此,在此模型中,沒有主題既沒有排隊。 您需要連接到特定的提供程序並指定正確的EventHub,如下所示:

application.properties

connectionfactory.SBCF=amqps://<PolicyName>:<PolicyKey>@<DomainName>.servicebus.windows.net
queue.EventHub=<EventHubName>/ConsumerGroups/$Default/Partitions/0

哪里: 在此處輸入圖片說明

之后,以下代碼允許我創建MessageConsumer:

Hashtable<String, String> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY,
               "org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory");
env.put(Context.PROVIDER_URL, 
    getClass().getResource("/application.properties").toString());
Context context = null;

context = new InitialContext(env);
// Look up ConnectionFactory 
ConnectionFactory cf = (ConnectionFactory) context.lookup("SBCF");
Destination queue = (Destination) context.lookup("EventHub");

// Create Connection
Connection connection = cf.createConnection();

// Create receiver-side Session, MessageConsumer
Session receiveSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer receiver = receiveSession.createConsumer(queue);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM