in simulator/src/main/java/com/google/cloud/PubSubConsumer.java [49:76]
public PubSubConsumer(String orderTopic, String marketDepthTopic, String region)
throws IOException {
FlowControlSettings flowControlSettings =
FlowControlSettings.newBuilder()
// Block more messages from being published when the limit is reached.
.setLimitExceededBehavior(LimitExceededBehavior.Block)
.setMaxOutstandingRequestBytes(10 * 1024 * 1024L) // 10 MiB
.setMaxOutstandingElementCount(10 * 1000L) // 100 messages
.build();
BatchingSettings settings = BatchingSettings.newBuilder()
.setElementCountThreshold(10 * 1000L) // default: 100
.setRequestByteThreshold(10 * 1024L) // default: 1000 bytes
.setDelayThreshold(Duration.ofMillis(50)) // default: 1ms
.setFlowControlSettings(flowControlSettings)
.build();
String endpoint = (region == null ? "" : region + "-")
+ "pubsub.googleapis.com:443";
orderPublisher = Publisher.newBuilder(TopicName.parse(orderTopic))
.setBatchingSettings(settings)
.setEndpoint(endpoint)
.build();
marketDepthPublisher = Publisher.newBuilder(TopicName.parse(marketDepthTopic))
.setBatchingSettings(settings)
.setEndpoint(endpoint)
.build();
}