use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project aws-doc-sdk-examples by awsdocs.
the class KinesisStreamEx method main.
public static void main(String[] args) {
// snippet-start:[kinesis.java2.stream_example.setup]
Region region = Region.US_EAST_1;
KinesisAsyncClient client = KinesisAsyncClient.builder().region(region).build();
SubscribeToShardRequest request = SubscribeToShardRequest.builder().consumerARN(CONSUMER_ARN).shardId("arn:aws:kinesis:us-east-1:111122223333:stream/StockTradeStream").startingPosition(s -> s.type(ShardIteratorType.LATEST)).build();
// snippet-end:[kinesis.java2.stream_example.setup]
SubscribeToShardResponseHandler responseHandler = SubscribeToShardResponseHandler.builder().onError(t -> System.err.println("Error during stream - " + t.getMessage())).subscriber(MySubscriber::new).build();
client.subscribeToShard(request, responseHandler);
client.close();
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project aws-doc-sdk-examples by awsdocs.
the class KinesisStreamEx method responseHandlerBuilderVisitorBuilder.
// snippet-end:[kinesis.java2.stream_example.publish_transformer]
/**
* Creates a SubscribeToShardResponseHandler.Visitor using the builder which lets you register an event handler for
* all events you're interested in rather than implementing the interface.
*/
// snippet-start:[kinesis.java2.stream_example.visitor]
private static CompletableFuture<Void> responseHandlerBuilderVisitorBuilder(KinesisAsyncClient client, SubscribeToShardRequest request) {
SubscribeToShardResponseHandler.Visitor visitor = SubscribeToShardResponseHandler.Visitor.builder().onSubscribeToShardEvent(e -> System.out.println("Received subscribe to shard event " + e)).build();
SubscribeToShardResponseHandler responseHandler = SubscribeToShardResponseHandler.builder().onError(t -> System.err.println("Error during stream - " + t.getMessage())).subscriber(visitor).build();
return client.subscribeToShard(request, responseHandler);
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project aws-doc-sdk-examples by awsdocs.
the class KinesisStreamRxJavaEx method main.
public static void main(String[] args) {
KinesisAsyncClient client = KinesisAsyncClient.create();
SubscribeToShardRequest request = SubscribeToShardRequest.builder().consumerARN(CONSUMER_ARN).shardId("shardId-000000000000").startingPosition(StartingPosition.builder().type(ShardIteratorType.LATEST).build()).build();
responseHandlerBuilder_RxJava(client, request).join();
client.close();
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project aws-doc-sdk-examples by awsdocs.
the class ClientConfiguration method main.
public static void main(String[] args) {
// If configured with an httpClientBuilder, the SDK will manage the lifecycle of the HTTP client
// and it will be shutdown when the client is shut down.
// snippet-start:[kinesis.java2.client_configuration.client]
KinesisAsyncClient client = KinesisAsyncClient.builder().httpClientBuilder(NettyNioAsyncHttpClient.builder().maxConcurrency(100).maxPendingConnectionAcquires(10_000)).build();
// snippet-end:[kinesis.java2.client_configuration.client]
// When passing in the httpClient directly, the lifecycle must be managed by the caller and the HTTP client
// will not be shut down when the client is shut down.
// snippet-start:[kinesis.java2.client_configuration.httpclient]
SdkAsyncHttpClient httpClient = NettyNioAsyncHttpClient.builder().maxConcurrency(100).maxPendingConnectionAcquires(10_000).build();
KinesisAsyncClient kinesisClient = KinesisAsyncClient.builder().httpClient(httpClient).build();
httpClient.close();
// snippet-end:[kinesis.java2.client_configuration.httpclient]
}
use of software.amazon.awssdk.services.kinesis.KinesisAsyncClient in project aws-doc-sdk-examples by awsdocs.
the class KinesisStreamReactorEx method main.
public static void main(String[] args) {
KinesisAsyncClient client = KinesisAsyncClient.create();
SubscribeToShardRequest request = SubscribeToShardRequest.builder().consumerARN(CONSUMER_ARN).shardId("shardId-000000000000").startingPosition(StartingPosition.builder().type(ShardIteratorType.LATEST).build()).build();
responseHandlerBuilder_Reactor(client, request).join();
client.close();
}
Aggregations