use of software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest in project flink by apache.
the class KinesisProxyV2Test method testSubscribeToShard.
@Test
public void testSubscribeToShard() {
KinesisAsyncClient kinesis = mock(KinesisAsyncClient.class);
KinesisProxyV2 proxy = new KinesisProxyV2(kinesis, mock(SdkAsyncHttpClient.class), createConfiguration(), mock(FullJitterBackoff.class));
SubscribeToShardRequest request = SubscribeToShardRequest.builder().build();
SubscribeToShardResponseHandler responseHandler = SubscribeToShardResponseHandler.builder().subscriber(event -> {
}).build();
proxy.subscribeToShard(request, responseHandler);
verify(kinesis).subscribeToShard(eq(request), eq(responseHandler));
}
use of software.amazon.awssdk.services.kinesis.model.SubscribeToShardRequest 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.model.SubscribeToShardRequest 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.model.SubscribeToShardRequest 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.model.SubscribeToShardRequest 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