public static void main(String[] args) {
        // The connection string value can be obtained by:
        // 1. Going to your Event Hubs namespace in Azure Portal.
        // 2. Creating an Event Hub instance.
        // 3. Creating a "Shared access policy" for your Event Hub instance.
        // 4. Copying the connection string from the policy's properties.
        String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}";
        EventHubProducerAsyncClient producer = new EventHubClientBuilder()
            .connectionString(connectionString)
            .buildAsyncProducer();
        // Create an event to send.
        EventData data = new EventData("Hello world!".getBytes(UTF_8));
        // Send that event. This call returns a Mono<Void>, which we subscribe to. It completes successfully when the
        // event has been delivered to the Event Hub. It completes with an error if an exception occurred while sending
        // the event.
        // SendOptions are not specified, so events sent are load balanced between all available partitions in the
        // Event Hub instance.
        producer.send(data).subscribe(
            (ignored) -> System.out.println("Event sent."),
            error -> {
                System.err.println("There was an error sending the event: " + 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()));
                }
            }, () -> {
                // Disposing of our producer and client.
                producer.close();
            });
    }
public static void main(String[] args) {
       
       
       
       
       
        String connectionString = "Endpoint={endpoint};SharedAccessKeyName={sharedAccessKeyName};SharedAccessKey={sharedAccessKey};EntityPath={eventHubName}";
        EventHubProducerAsyncClient producer = new EventHubClientBuilder()
            .connectionString(connectionString)
            .buildAsyncProducer();
       
        EventData data = new EventData("Hello world!".getBytes(UTF_8));
       
       
       
       
       
        producer.send(data).subscribe(
            (ignored) -> System.out.println("Event sent."),
            error -> {
                System.err.println("There was an error sending the event: " + 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()));
                }
            }, () -> {
               
                producer.close();
            });
    }
public static void main(string[] args) { string connectionstring = "endpoint={endpoint};sharedaccesskeyname={sharedaccesskeyname};sharedaccesskey={sharedaccesskey};entitypath={eventhubname}"; eventhubproducerasyncclient producer = new eventhubclientbuilder() .connectionstring(connectionstring) .buildasyncproducer(); eventdata data = new eventdata("hello world!".getbytes(utf_8)); producer.send(data).subscribe( (ignored) -> system.out.println("event sent."), error -> { system.err.println("there was an error sending the event: " + 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())); } }, () -> { producer.close(); }); }