2016-11-14 50 views
0

我已經在使用基於Azure EventHub的應用程序。現在我需要連接到現有基礎架構的寫入Java接收器。 現有配置:Azure EventHub上的Qpid接收器

事件中心>SomeName>消費集團>SomeGroupName

在管理控制檯中我看不到任何隊列或主題定義。分析工作的C#代碼我可以看到hub-name + group-name足以連接。

我重建了允許我通過java進行連接的URL(並且迄今爲止的連接工作)。

amqps://SomeName.servicebus.windows.net

所以我的問題:

1),而不是隊列/主題我指定的組名,然後我得到異常The messaging entity 'sb://SomeName.servicebus.windows.net/SomeGroupName' could not be found.用的是什麼型號有沒有隊列/主題?

2)如何使用Apache-qpid這樣的基礎設施?

回答

0

爲解決這一問題的最大線索給了我下面的鏈接: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 

其中: enter image description here

之後,下面的代碼讓我創造的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); 
1

您是使用舊門戶中創建的Event Hub還是使用新門戶創建的Event Hub?

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

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

於是地址變爲:

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

你可以發佈你所分析的C#代碼?既然你已經有一個工作正常的應用程序,也許我們可以試着解決現在無法工作的差異。

相關問題