public MaxwellPubsubProducerWorker(MaxwellContext context, String pubsubProjectId, String pubsubTopic, String ddlPubsubTopic, ArrayBlockingQueue<RowMap> queue) throws IOException { super(context); this.projectId = pubsubProjectId; this.topic = TopicName.of(pubsubProjectId, pubsubTopic); this.pubsub = Publisher.newBuilder(this.topic).build(); if ( context.getConfig().outputConfig.outputDDL == true && ddlPubsubTopic != pubsubTopic ) { this.ddlTopic = TopicName.of(pubsubProjectId, ddlPubsubTopic); this.ddlPubsub = Publisher.newBuilder(this.ddlTopic).build(); } else { this.ddlTopic = this.topic; this.ddlPubsub = this.pubsub; } Metrics metrics = context.getMetrics(); this.queue = queue; this.taskState = new StoppableTaskState("MaxwellPubsubProducerWorker"); }
private CPSPublisherTask(StartRequest request) { super(request, "gcloud", MetricsHandler.MetricName.PUBLISH_ACK_LATENCY); try { this.publisher = Publisher.defaultBuilder(TopicName.create(request.getProject(), request.getTopic())) .setBatchingSettings( BatchingSettings.newBuilder() .setElementCountThreshold(950L) .setRequestByteThreshold(9500000L) .setDelayThreshold( Duration.ofMillis(Durations.toMillis(request.getPublishBatchDuration()))) .build()) .build(); } catch (Exception e) { throw new RuntimeException(e); } this.payload = ByteString.copyFromUtf8(LoadTestRunner.createMessage(request.getMessageSize())); this.batchSize = request.getPublishBatchSize(); this.messageSize = request.getMessageSize(); this.id = (new Random()).nextInt(); }
protected Publisher createPublisher(final Topic topic) throws JMSException { final PubSubConnection connection = ((PubSubSession) getSession()).getConnection(); try { return Publisher .newBuilder(TopicName.parse(topic.getTopicName())) .setChannelProvider(connection.getProviderManager()) .setExecutorProvider(connection.getProviderManager()) .setFlowControlSettings(connection.getFlowControlSettings()) .setRetrySettings(connection.getRetrySettings()) .build(); } catch (final IOException e) { LOGGER.log(Level.SEVERE, "Can't create publisher.", e); throw new JMSException(e.getMessage()); } }