Search in sources :

Example 1 with SqsConfiguration

use of org.apache.camel.component.aws.sqs.SqsConfiguration in project syndesis by syndesisio.

the class AWSSQSVerifierExtension method verifyConnectivity.

// *********************************
// Connectivity validation
// *********************************
@Override
protected Result verifyConnectivity(Map<String, Object> parameters) {
    ResultBuilder builder = ResultBuilder.withStatusAndScope(Result.Status.OK, Scope.CONNECTIVITY);
    try {
        SqsConfiguration configuration = setProperties(new SqsConfiguration(), parameters);
        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(), configuration.getSecretKey());
        AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
        AmazonSQS client = AmazonSQSClientBuilder.standard().withCredentials(credentialsProvider).withRegion(Regions.valueOf(configuration.getRegion())).build();
        client.listQueues();
    } catch (SdkClientException e) {
        ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, e.getMessage()).detail("aws_sqs_exception_message", e.getMessage()).detail(VerificationError.ExceptionAttribute.EXCEPTION_CLASS, e.getClass().getName()).detail(VerificationError.ExceptionAttribute.EXCEPTION_INSTANCE, e);
        builder.error(errorBuilder.build());
    } catch (Exception e) {
        builder.error(ResultErrorBuilder.withException(e).build());
    }
    return builder.build();
}
Also used : ResultBuilder(org.apache.camel.component.extension.verifier.ResultBuilder) AWSStaticCredentialsProvider(com.amazonaws.auth.AWSStaticCredentialsProvider) SdkClientException(com.amazonaws.SdkClientException) SqsConfiguration(org.apache.camel.component.aws.sqs.SqsConfiguration) ResultErrorBuilder(org.apache.camel.component.extension.verifier.ResultErrorBuilder) AmazonSQS(com.amazonaws.services.sqs.AmazonSQS) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) SdkClientException(com.amazonaws.SdkClientException)

Example 2 with SqsConfiguration

use of org.apache.camel.component.aws.sqs.SqsConfiguration in project opentelemetry-java-instrumentation by open-telemetry.

the class CamelPropagationUtilTest method shouldNotFailExtractingNullAwsParentForSqsEndpoint.

@Test
public void shouldNotFailExtractingNullAwsParentForSqsEndpoint() {
    // given
    Endpoint endpoint = new SqsEndpoint("", new SqsComponent(), new SqsConfiguration());
    Map<String, Object> exchangeHeaders = Collections.singletonMap("AWSTraceHeader", null);
    // when
    Context parent = CamelPropagationUtil.extractParent(exchangeHeaders, endpoint);
    // then
    Span parentSpan = Span.fromContext(parent);
    SpanContext parentSpanContext = parentSpan.getSpanContext();
    assertThat(parentSpanContext.isValid()).isEqualTo(false);
}
Also used : Context(io.opentelemetry.context.Context) SpanContext(io.opentelemetry.api.trace.SpanContext) SqsComponent(org.apache.camel.component.aws.sqs.SqsComponent) SpanContext(io.opentelemetry.api.trace.SpanContext) HttpEndpoint(org.apache.camel.component.http.HttpEndpoint) SqsEndpoint(org.apache.camel.component.aws.sqs.SqsEndpoint) Endpoint(org.apache.camel.Endpoint) SqsConfiguration(org.apache.camel.component.aws.sqs.SqsConfiguration) SqsEndpoint(org.apache.camel.component.aws.sqs.SqsEndpoint) Span(io.opentelemetry.api.trace.Span) Test(org.junit.jupiter.api.Test)

Example 3 with SqsConfiguration

use of org.apache.camel.component.aws.sqs.SqsConfiguration in project opentelemetry-java-instrumentation by open-telemetry.

the class CamelPropagationUtilTest method shouldExtractAwsParentForSqsEndpoint.

@Test
public void shouldExtractAwsParentForSqsEndpoint() {
    // given
    Endpoint endpoint = new SqsEndpoint("", new SqsComponent(), new SqsConfiguration());
    Map<String, Object> exchangeHeaders = Collections.singletonMap("AWSTraceHeader", "Root=1-5759e988-bd862e3fe1be46a994272793;Parent=53995c3f42cd8ad8;Sampled=1\n");
    // when
    Context parent = CamelPropagationUtil.extractParent(exchangeHeaders, endpoint);
    // then
    Span parentSpan = Span.fromContext(parent);
    SpanContext parentSpanContext = parentSpan.getSpanContext();
    assertThat(parentSpanContext.getTraceId()).isEqualTo("5759e988bd862e3fe1be46a994272793");
    assertThat(parentSpanContext.getSpanId()).isEqualTo("53995c3f42cd8ad8");
}
Also used : Context(io.opentelemetry.context.Context) SpanContext(io.opentelemetry.api.trace.SpanContext) SqsComponent(org.apache.camel.component.aws.sqs.SqsComponent) SpanContext(io.opentelemetry.api.trace.SpanContext) HttpEndpoint(org.apache.camel.component.http.HttpEndpoint) SqsEndpoint(org.apache.camel.component.aws.sqs.SqsEndpoint) Endpoint(org.apache.camel.Endpoint) SqsConfiguration(org.apache.camel.component.aws.sqs.SqsConfiguration) SqsEndpoint(org.apache.camel.component.aws.sqs.SqsEndpoint) Span(io.opentelemetry.api.trace.Span) Test(org.junit.jupiter.api.Test)

Aggregations

SqsConfiguration (org.apache.camel.component.aws.sqs.SqsConfiguration)3 Span (io.opentelemetry.api.trace.Span)2 SpanContext (io.opentelemetry.api.trace.SpanContext)2 Context (io.opentelemetry.context.Context)2 Endpoint (org.apache.camel.Endpoint)2 SqsComponent (org.apache.camel.component.aws.sqs.SqsComponent)2 SqsEndpoint (org.apache.camel.component.aws.sqs.SqsEndpoint)2 HttpEndpoint (org.apache.camel.component.http.HttpEndpoint)2 Test (org.junit.jupiter.api.Test)2 SdkClientException (com.amazonaws.SdkClientException)1 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)1 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 AmazonSQS (com.amazonaws.services.sqs.AmazonSQS)1 ResultBuilder (org.apache.camel.component.extension.verifier.ResultBuilder)1 ResultErrorBuilder (org.apache.camel.component.extension.verifier.ResultErrorBuilder)1