Example usage for com.amazonaws SDKGlobalConfiguration AWS_CBOR_DISABLE_SYSTEM_PROPERTY

List of usage examples for com.amazonaws SDKGlobalConfiguration AWS_CBOR_DISABLE_SYSTEM_PROPERTY

Introduction

In this page you can find the example usage for com.amazonaws SDKGlobalConfiguration AWS_CBOR_DISABLE_SYSTEM_PROPERTY.

Prototype

String AWS_CBOR_DISABLE_SYSTEM_PROPERTY

To view the source code for com.amazonaws SDKGlobalConfiguration AWS_CBOR_DISABLE_SYSTEM_PROPERTY.

Click Source Link

Document

System property to disable CBOR protocol.

Usage

From source file:org.springframework.cloud.stream.binder.kinesis.LocalKinesisResource.java

License:Apache License

@Override
protected void obtainResource() {
    // See https://github.com/mhart/kinesalite#cbor-protocol-issues-with-the-java-sdk
    System.setProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY, "true");

    this.resource = AmazonKinesisAsyncClientBuilder.standard()
            .withClientConfiguration(new ClientConfiguration().withMaxErrorRetry(0).withConnectionTimeout(1000))
            .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
                    "http://localhost:" + this.port, Regions.DEFAULT_REGION.getName()))
            .withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials("", ""))).build();

    // Check connection
    this.resource.listStreams();
}

From source file:org.springframework.cloud.stream.binder.kinesis.LocalKinesisResource.java

License:Apache License

@Override
protected void cleanupResource() {
    ListStreamsRequest listStreamsRequest = new ListStreamsRequest();
    ListStreamsResult listStreamsResult = this.resource.listStreams(listStreamsRequest);

    List<String> streamNames = listStreamsResult.getStreamNames();

    while (listStreamsResult.getHasMoreStreams()) {
        if (streamNames.size() > 0) {
            listStreamsRequest.setExclusiveStartStreamName(streamNames.get(streamNames.size() - 1));
        }/*from w  w w  . j a va 2  s  . com*/
        listStreamsResult = this.resource.listStreams(listStreamsRequest);
        streamNames.addAll(listStreamsResult.getStreamNames());
    }

    for (String stream : streamNames) {
        this.resource.deleteStream(stream);
        while (true) {
            try {
                this.resource.describeStream(stream);
                try {
                    Thread.sleep(100);
                } catch (InterruptedException ex) {
                    Thread.currentThread().interrupt();
                    throw new IllegalStateException(ex);
                }
            } catch (ResourceNotFoundException ex) {
                break;
            }
        }
    }

    System.clearProperty(SDKGlobalConfiguration.AWS_CBOR_DISABLE_SYSTEM_PROPERTY);
    this.resource.shutdown();
}