Source:
<code>public static void main(String[] args) { String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};SharedAccessKey={sharedAccessKey};EntityPath={eventHubPath}"; EventHubClient client = new EventHubClientBuilder() .connectionString(connectionString) .build(); EventHubProducer producer = client.createProducer(); <START> List<EventData> dataList = new ArrayList<>(); <END> EventData firstEvent = new EventData("EventData Sample 1".getBytes(UTF_8)); firstEvent.properties().put("EventType", "com.microsoft.samples.hello-event"); firstEvent.properties().put("priority", 1); firstEvent.properties().put("score", 9.0); EventData secEvent = new EventData("EventData Sample 2 ".getBytes(UTF_8)); secEvent.properties().put("EventType", "com.microsoft.samples.goodbye-event"); secEvent.properties().put("priority", "17"); secEvent.properties().put("blob", true); dataList.add(firstEvent); dataList.add(secEvent); final String partitionID = "0"; producer.send(dataList).subscribe( (ignored) -> System.out.println("Event sent to specific partition, ID = " + partitionID), error -> { System.err.println("There was an error sending the event batch: " + error.toString()); if (error instanceof AmqpException) { AmqpException amqpException = (AmqpException) error; System.err.println(String.format("Is send operation retriable? %s. Error condition: %s", amqpException.isTransient(), amqpException.getErrorCondition())); } }, () -> { try { producer.close(); } catch (IOException e) { System.err.println("Error encountered while closing producer: " + e.toString()); } client.close(); }); }</code><technical_language>Flux.just is part of framework</technical_language>

Target:
public static void main(String[] args) { String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};SharedAccessKey={sharedAccessKey};EntityPath={eventHubPath}"; EventHubClient client = new EventHubClientBuilder() .connectionString(connectionString) .buildAsyncClient(); EventHubProducer producer = client.createProducer(); EventData firstEvent = new EventData("EventData Sample 1".getBytes(UTF_8)); firstEvent.properties().put("EventType", "com.microsoft.samples.hello-event"); firstEvent.properties().put("priority", 1); firstEvent.properties().put("score", 9.0); EventData secEvent = new EventData("EventData Sample 2".getBytes(UTF_8)); secEvent.properties().put("EventType", "com.microsoft.samples.goodbye-event"); secEvent.properties().put("priority", "17"); secEvent.properties().put("blob", true); final Flux<EventData> data = Flux.just(firstEvent, secEvent); String firstPartition = client.getPartitionIds().blockFirst(OPERATION_TIMEOUT); producer.send(data).subscribe( (ignored) -> System.out.println("Event sent to specific partition, ID = " + firstPartition), error -> { System.err.println("There was an error sending the event batch: " + error.toString()); if (error instanceof AmqpException) { AmqpException amqpException = (AmqpException) error; System.err.println(String.format("Is send operation retriable? %s. Error condition: %s", amqpException.isTransient(), amqpException.getErrorCondition())); } }, () -> { try { producer.close(); } catch (IOException e) { System.err.println("Error encountered while closing producer: " + e.toString()); } client.close(); }); }