Question
You want to send a message to an Event Hubs hub named services in a namespace named measureup. You have the following code:
using Azure.Messaging.EventHubs;
using Azure.Messaging.EventHubs.Producer;
using System.Text;
EventHubProducerClient producerClient =
new EventHubProducerClient("<CONNECTION_STRING>", "<HUB_NAME>");
You need to set the CONNECTION_STRING and HUB_NAME parameter.
Which value should you use?
Option 1
CONNECTION_STRING = Endpoint=sb://measureup.servicebus.windows.net/;EntityPath=services;
HUB_NAME = services
Option 2
CONNECTION_STRING = https://measureup.azurewebsites.net/services
HUB_NAME = measureupOption 3
CONNECTION_STRING = Endpoint=https://measureup.azurewebsites.net?EntityPath=services;
HUB_NAME = servicesOption 4
CONNECTION_STRING = sb://measureup.servicebus.windows.net/services
HUB_NAME = measureup
Question
You have the following code (line numbers are included for reference only):
01 class Program
02 {
03 static async Task Main()
04 {
05 EventHubProducerClient producerClient = new EventHubProducerClient("<CONNECTION_STRING>", "<HUB_NAME>");
06 try
07 {
08 var message = "This is a single event";
09 EventData singleEvent = new EventData(Encoding.UTF8.GetBytes(message));
10 ________________________________
11 Console.WriteLine("A single event has been published.");
12 }
13 }
14 }
You need to submit the message to the Event Hub.
Which code segment should you add at line 10?
Options
await producerClient.SendAsync(Encoding.UTF8.GetBytes(message));await producerClient.SendAsync(new[] { singleEvent });await producerClient.SendAsync(singleEvent); await producerClient.SendAsync(new EventData(message));
No comments:
Post a Comment