Interface PartitionSender

    • Method Detail

      • getPartitionId

        String getPartitionId()
        The partition id that will receive events from this sender.
        Returns:
        the partition id the PartitionSender is connected to.
      • send

        CompletableFuture<Void> send​(Iterable<EventData> eventDatas)
        Send EventData to a specific EventHub partition. The targeted partition is pre-determined when this PartitionSender was created.

        There are 3 ways to send to EventHubs, to understand this particular type of Send refer to the overload send(EventData), which is the same type of Send and is used to send single EventData.

        Sending a batch of EventData's is useful in the following cases:

         i.   Efficient send - sending a batch of EventData maximizes the overall throughput by optimally using the number of sessions created to EventHubs' service.
         ii.  Send multiple EventData's in a Transaction. To achieve ACID properties, the Gateway Service will forward all EventData's in the batch to a single EventHubs' partition.
         

        Sample code (sample uses sync version of the api but concept are identical):

         Gson gson = new GsonBuilder().create();
         EventHubClient client = EventHubClient.createSync("__connection__");
         PartitionSender senderToPartitionOne = client.createPartitionSenderSync("1");
        
         while (true)
         {
             LinkedList<EventData> events = new LinkedList<EventData>();
             for (int count = 1; count < 11; count++)
             {
                 PayloadEvent payload = new PayloadEvent(count);
                 byte[] payloadBytes = gson.toJson(payload).getBytes(Charset.defaultCharset());
                 EventData sendEvent = EventData.create(payloadBytes);
                 sendEvent.getProperties().put("from", "javaClient");
                 events.add(sendEvent);
             }
        
             senderToPartitionOne.sendSync(events);
             System.out.println(String.format("Sent Batch... Size: %s", events.size()));
         }
         
        Parameters:
        eventDatas - batch of events to send to EventHub
        Returns:
        a CompletableFuture that can be completed when the send operations is done..
      • send

        CompletableFuture<Void> send​(EventDataBatch eventDatas)
        Send EventDataBatch to a specific EventHub partition. The targeted partition is pre-determined when this PartitionSender was created. A partitionKey cannot be set when using EventDataBatch with a PartitionSender.

        There are 3 ways to send to EventHubs, to understand this particular type of Send refer to the overload send(EventData), which is the same type of Send and is used to send single EventData.

        Sending a batch of EventData's is useful in the following cases:

         i.   Efficient send - sending a batch of EventData maximizes the overall throughput by optimally using the number of sessions created to EventHubs' service.
         ii.  Send multiple EventData's in a Transaction. To achieve ACID properties, the Gateway Service will forward all EventData's in the batch to a single EventHubs' partition.
         
        Parameters:
        eventDatas - EventDataBatch to send to EventHub
        Returns:
        a CompletableFuture that can be completed when the send operation is done..
        See Also:
        send(Iterable), EventDataBatch