【问题标题】:Qpid receiver on Azure EventHubAzure EventHub 上的 Qpid 接收器
【发布时间】:2017-03-28 14:06:20
【问题描述】:

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

事件中心 > SomeName > 消费者组 > SomeGroupName

在管理控制台中,我看不到任何 QUEUE 或 TOPIC 定义。分析工作 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 的此类基础架构?

【问题讨论】:

    标签: java azure amqp azure-eventhub qpid


    【解决方案1】:

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

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

    消费者组不是地址的一部分。该地址是使用命名空间和该命名空间中的 eventthub 的名称构建的。

    所以地址变成:

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

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-05-28
        • 2021-07-17
        • 1970-01-01
        • 1970-01-01
        • 2016-11-25
        • 1970-01-01
        • 1970-01-01
        • 2017-03-09
        相关资源
        最近更新 更多