examples/pubsub-publish-avro-example/src/main/java/com/google/cloud/pso/pubsub/common/ObjectPublisher.java
/**
     * Initializes the class by creating a {@link Publisher} if one does not exist. It utilizes
     * the settings provided by {@link Args} to set the appropriate {@link BatchingSettings} to
     * be used for publishing.
     *
     * @param args Argument encapsulating the values to be used for the {@link BatchingSettings}.
     */
Initializes the class by creating a  Publisher if one does not exist. It utilizes
the settings provided by  Args to set the appropriate  BatchingSettings to
be used for publishing.

@param args Argument encapsulating the values to be used for the  BatchingSettings.
Initializes the class by creating a Publisher if one does not exist . It utilizes the settings provided by Args to set the appropriate BatchingSettings to be used for publishing . @param args Argument encapsulating the values to be used for the BatchingSettings .
private void init(Args args) {
        if (this.publisher != null) {
            return;
        }
        this.awaitedFutures = new AtomicLong();
        ProjectTopicName topicName = ProjectTopicName.parse(args.topic);
        BatchingSettings batchingSettings =
                BatchingSettings.newBuilder()
                        .setElementCountThreshold(args.elementCount)
                        .setDelayThreshold(args.delayThreshold)
                        .setRequestByteThreshold(args.bytesThreshold)
                        .setIsEnabled(true)
                        .build();
        com.google.cloud.pubsub.v1.Publisher.Builder builder =
                com.google.cloud.pubsub.v1.Publisher.newBuilder(topicName)
                        .setBatchingSettings(batchingSettings);
        try {
            this.publisher = builder.build();
        } catch (IOException e) {
            System.out.println("Could not create publisher: " + e);
            System.exit(-1);
        }
    }
private void init ( Args args ) { if ( this . publisher != null ) { return ; } this . awaitedFutures = new AtomicLong ( ) ; ProjectTopicName topicName = ProjectTopicName . parse ( args . topic ) ; BatchingSettings batchingSettings = BatchingSettings . newBuilder ( ) . setElementCountThreshold ( args . elementCount ) . setDelayThreshold ( args . delayThreshold ) . setRequestByteThreshold ( args . bytesThreshold ) . setIsEnabled ( true ) . build ( ) ; com . google . cloud . pubsub . v1 . Publisher . Builder builder = com . google . cloud . pubsub . v1 . Publisher . newBuilder ( topicName ) . setBatchingSettings ( batchingSettings ) ; try { this . publisher = builder . build ( ) ; } catch ( IOException e ) { System . out . println ( "Could not create publisher: " + e ) ; System . exit ( - 1 ) ; } }
Initializes the class by creating a {@link Publisher} if one does not exist.
Initializes the class by creating a { @link Publisher } if one does not exist .
// BatchSettings to be used for publishing the messages.