简体   繁体   English

如何通过Rest API在事件中心发送和使用消息

[英]how to send and consume messages in Event hub via rest api

I am new to the Azure EventHub. 我是Azure EventHub的新手。 I wanted to write a simple prototype which can send and receive messages from AzureEventHub via its rest api. 我想编写一个简单的原型,该原型可以通过其rest api从AzureEventHub发送和接收消息。

Could you please help me by providing code snippet demonstrating how to use rest api exposed in EventHub for message producing and consuming. 您能否通过提供代码片段来帮助我,该代码片段演示了如何使用EventHub中公开的rest api来生成和使用消息。

Sorry, im not sure if there is any java examples around be here are a few links that might help: 抱歉,我不确定周围是否有任何Java示例,这里有一些链接可能会有所帮助:

Here is a little article that explains how you can generate a SasKey (Shared Access Signature). 这是一篇简短的文章,解释了如何生成SasKey(共享访问签名)。 you to send this key along with every request. 您将把此密钥与每个请求一起发送。 http://www.mikelanzetta.com/2014/09/talking-to-eventhub-from-node/ http://www.mikelanzetta.com/2014/09/talking-to-eventhub-from-node/

There is a (unofficial) Azure Service Bus JavaScript SDK, maybe this illustrates how its working 有一个(非官方的)Azure Service Bus JavaScript SDK,也许这说明了它是如何工作的

It provides following artefacts: 它提供以下伪像:

  • QueueClient QueueClient
  • Topic Client 主题客户
  • SubscriptionClient SubscriptionClient
  • EventHubClient EventHubClient

Here is an article about sending data to an EventHub: using the javascript sdk. 这是一篇有关将数据发送到EventHub的文章:使用javascript sdk。 http://developers.de/blogs/damir_dobric/archive/2015/01/26/eventhubs-support-for-azure-servicebus-javascript-sdk.aspx http://developers.de/blogs/damir_dobric/archive/2015/01/26/eventhubs-support-for-azure-servicebus-javascript-sdk.aspx

I'm the (co-)author of https://github.com/noodlefrenzy/node-amqp10 and can verify that there is no RESTful way to consume messages from an Event Hub - you need to use AMQP. 我是https://github.com/noodlefrenzy/node-amqp10的(共同)作者,可以验证是否没有RESTful方式来使用来自事件中心的消息-您需要使用AMQP。 There is a JMS binding for AMQP via Qpid-Proton that you can use. 您可以使用通过Qpid-Proton为AMQP绑定JMS。

This article https://azure.microsoft.com/en-gb/documentation/articles/service-bus-java-how-to-use-jms-api-amqp/ has details for using it with Service Bus, but it should be similar for Event Hubs. 本文https://azure.microsoft.com/zh-CN/documentation/articles/service-bus-java-how-to-use-jms-api-amqp/包含将其与Service Bus一起使用的详细信息,但应该与事件中心类似。 The main difference with Event Hubs is that messages are never "consumed" and come through on several "partitions", so you would need to connect to all of your partitions, and store the offsets as messages come in so you can specify those when you reconnect. 与事件中心的主要区别在于,消息永远不会“消耗”并通过多个“分区”传递,因此您需要连接到所有分区,并在消息进入时存储偏移量,以便您可以在指定时指定偏移量。重新连接。

As per my understanding about EVENTHUB, Rest API has been exposed to send data and there are no rest api available to receive data from event hub. 根据我对EVENTHUB的了解,Rest API已公开以发送数据,并且没有可用的rest api从事件中心接收数据。
I tried implementing Receiver for event hub using 我尝试使用事件中心实现Receiver
1. in Java using https://github.com/hdinsight/eventhubs-client 1.在Java中使用https://github.com/hdinsight/eventhubs-client
2. In nodejs using https://github.com/noodlefrenzy/node-amqp10 2.在nodejs中,使用https://github.com/noodlefrenzy/node-amqp10

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM