首页 文章

Azure EventHub上的Qpid接收器

提问于
浏览
0

我已经基于Azure EventHub工作了应用程序 . 现在我需要编写连接到现有基础架构的java接收器 . 现有配置:

事件中心> SomeName>使用者组> SomeGroupName

在管理控制台中,我看不到任何QUEUE或TOPIC定义 . 分析工作的c#代码我可以看到hub-name group-name足以连接 .

我重建了url,允许我通过java连接(到目前为止连接工作) .

amqps://SomeName.servicebus.windows.net

所以我的问题:

1)当我指定group-name而不是queue / topic时,我得到异常 The messaging entity 'sb://SomeName.servicebus.windows.net/SomeGroupName' could not be found. 那里使用的模型是什么而不是queue / topic?

2)如何使用Apache-qpid中的此类基础架构?

2 回答

  • 0

    您使用的是在旧门户中创建的事件中心还是使用新门户创建的事件中心?

    EventHub不是消息总线,因此没有队列或主题,这是正确的 .

    消费者群体不是地址的一部分 . 使用命名空间和该命名空间中eventhub的名称构建地址 .

    所以地址变成:

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

    你可以发布你分析过的c#代码吗?既然你有一个已经在工作的应用程序,我们可以解决阻止它现在工作的差异 .

  • 1

    解决问题的最大提示给了我以下链接: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);
    

相关问题