Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/samples/interactiveLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function main(): Promise<void> {
const client = EventHubClient.createFromAadTokenCredentials(evenHubsEndpoint, eventHubsName, credentials);
/*
Refer to other samples, and place your code here
to send/receive messages
to send/receive events
*/
await client.close();
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/samples/loginWithAzureAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function main(): Promise<void> {
const client = EventHubClient.createFromAadTokenCredentials(evenHubsEndpoint, eventHubsName, credentials);
/*
Refer to other samples, and place your code here
to send/receive messages
to send/receive events
*/
await client.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT Licence.

This sample demonstrates how the receiveBatch() function can be used to receive Event Hubs
messages in a loop.
This sample demonstrates how the receiveBatch() function can be used to receive events in a loop.

If your Event Hubs instance doesn't have any messages, then please run "sendMesages.ts" sample
If your Event Hubs instance doesn't have any events, then please run "sendEvents.ts" sample
to populate Event Hubs before running this sample.
*/

Expand All @@ -22,15 +21,16 @@ async function main(): Promise<void> {
const batchSize = 1;

for (let i = 0; i < 10; i++) {
const messages = await client.receiveBatch(partitionIds[0], batchSize, 5, {
eventPosition: eventPosition
const events = await client.receiveBatch(partitionIds[0], batchSize, 5, {
eventPosition: eventPosition,
consumerGroup: "$Default"
});
if (!messages.length) {
console.log("No more messages to receive");
if (!events.length) {
console.log("No more events to receive");
break;
}
eventPosition = EventPosition.fromSequenceNumber(messages[messages.length - 1].sequenceNumber!);
console.log(`Received messages #${i}: ${messages.map(msg => msg.body)}`);
eventPosition = EventPosition.fromSequenceNumber(events[events.length - 1].sequenceNumber!);
console.log(`Received events #${i}: ${events.map(event => event.body)}`);
}
await client.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT Licence.

This sample demonstrates how the receive() function can be used to receive Event Hubs messages
in a stream.
This sample demonstrates how the receive() function can be used to receive events in a stream.

If your Event Hubs instance doesn't have any messages, then please run "sendMesages.ts" sample
If your Event Hubs instance doesn't have any events, then please run "sendEvents.ts" sample
to populate Event Hubs before running this sample.
*/

Expand All @@ -20,17 +19,18 @@ async function main(): Promise<void> {
const partitionIds = await client.getPartitionIds();

const onMessageHandler: OnMessage = async (brokeredMessage: EventData) => {
console.log(`Received message: ${brokeredMessage.body}`);
console.log(`Received event: ${brokeredMessage.body}`);
};
const onErrorHandler: OnError = (err: MessagingError | Error) => {
console.log("Error occurred: ", err);
};

const rcvHandler = client.receive(partitionIds[0], onMessageHandler, onErrorHandler, {
eventPosition: EventPosition.fromStart()
eventPosition: EventPosition.fromStart(),
consumerGroup: "$Default"
});

// Waiting long enough before closing the receiver to receive messages
// Waiting long enough before closing the receiver to receive event
await delay(5000);
await rcvHandler.stop();
await client.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT Licence.

This sample demonstrates how the send() function can be used to send messages to Event Hubs.
This sample demonstrates how the send() function can be used to send events to Event Hubs.

See https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-about
to learn about Event Hubs.
Expand Down Expand Up @@ -33,14 +33,14 @@ async function main(): Promise<void> {

for (let index = 0; index < listOfScientists.length; index++) {
const scientist = listOfScientists[index];
const data: EventData = {
const eventData: EventData = {
body: `${scientist.firstName} ${scientist.name}`
};
// NOTE: For receiving events from Azure Stream Analytics, please send Events to an EventHub
// where the body is a JSON object/array.
// const data = { body: { "message": `${scientist.firstName} ${scientist.name}` } };
console.log(`Sending message: ${data.body}`);
await client.send(data, partitionIds[0]);
// const eventData = { body: { "message": `${scientist.firstName} ${scientist.name}` } };
console.log(`Sending event: ${eventData.body}`);
await client.send(eventData, partitionIds[0]);
}

await client.close();
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/samples/servicePrincipalLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function main(): Promise<void> {
const client = EventHubClient.createFromAadTokenCredentials(evenHubsEndpoint, eventHubsName, credentials);
/*
Refer to other samples, and place your code here
to send/receive messages
to send/receive events
*/
await client.close();
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/event-hubs/samples/useProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function main(): Promise<void> {
});
/*
Refer to other samples, and place your code here
to send/receive messages
to send/receive events
*/
await client.close();
}
Expand Down