2019-06-28 5.0.0-preview.1
Version 5.0.0-preview.1 is a preview of our efforts to create a client library that is user friendly and
idiomatic to the Javascript ecosystem. The reasons for most of the changes in this update can be found in the
Azure SDK Design Guidelines for TypeScript.
For more information, please visit https://aka.ms/azure-sdk-preview1-js
Breaking changes
- Creating an instance of
EventHubClient
is now done using construtor overloads instead of static helpers.- If you previously used the
createFromTokenProvider
static helper to provide your own custom token provider,
you will now need to update the provider to follow the newTokenCredential
interface instead. - If you previously used the
@azure/ms-rest-nodeauth
library to provide AAD credentials, you will now need to use the new
@azure/identity
library instead.
- If you previously used the
- The send methods are moved from the
EventHubClient
class to the newEventHubProducer
class.- Use the
createProducer()
function on theEventHubClient
to create an instance of aEventHubProducer
. A producer can be bound to a partition at the time of creation such that all events sent from it land in the given partition. - Each producer represents a dedicated AMQP sender link to Azure Event Hubs.
- The
EventData
type used for the data being sent only supports abody
for the content being sent and aproperties
bag to hold any custom metadata you want to send. The properties corresponding to a received event are removed from this type and a separate typeReceivedEventData
is used for received events.
- Use the
- The receive methods are moved from the
EventHubClient
class to the newEventHubConsumer
class.- Use the
createConsumer()
function on theEventHubClient
to create an instance of aEventHubConsumer
. - Each consumer represents a dedicated AMQP receiver link to Azure Event Hubs based
on the flavor of receive function being used i.ereceiveBatch()
that receives events in a batch vsreceive()
that provides
a streaming receiver. - The static methods
EventPosition.fromStart()
andEventPosition.fromEnd()
are renamed toEventPosition.earliest()
andEventPosition.latest()
respectively.
- Use the
- Inspecting Event Hub
- The methods
getHubRuntimeInformation()
andgetPartitionInformation()
on theEventHubClient
are renamed to
getProperties()
andgetPartitionProperties()
respectively. Please refer to the return types of these functions to ensure
you are using the right property names.
- The methods
New features
- You can now configure retry options that are used to govern retry attempts when a retryable error occurs. These can be
set when creating theEventHubClient
,EventHubProducer
andEventHubConsumer
- You can now pass an abort signal to any of the async operations. This signal can be used to cancel such operations. Use
the package@azure/abort-controller
to create such abort signals. - An async iterator is now available to receive events after you create an instance of
EventHubConsumer
. Use the function
getEventIterator()
on the consumer to get aAsyncIterableIterator
which you can then use in a for loop or use it'snext()
function to receive events.
Next Steps
- Refer to the API reference documentation to get
an overview of the entire API surface. - Refer to our samples to understand the usage of the new APIs.