简体   繁体   中英

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

I am new to the Azure EventHub. I wanted to write a simple prototype which can send and receive messages from AzureEventHub via its rest api.

Could you please help me by providing code snippet demonstrating how to use rest api exposed in EventHub for message producing and consuming.

Sorry, im not sure if there is any java examples around be here are a few links that might help:

Here is a little article that explains how you can generate a SasKey (Shared Access Signature). you to send this key along with every request. 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

It provides following artefacts:

  • QueueClient
  • Topic Client
  • SubscriptionClient
  • EventHubClient

Here is an article about sending data to an EventHub: using the javascript sdk. 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. There is a JMS binding for AMQP via Qpid-Proton that you can use.

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. 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.
I tried implementing Receiver for event hub using
1. in Java using https://github.com/hdinsight/eventhubs-client
2. In nodejs using https://github.com/noodlefrenzy/node-amqp10

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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