From aeca30b10e2401f31f0bff86cc5e767113a2e0ac Mon Sep 17 00:00:00 2001 From: Jaiden Ashmore Date: Sun, 6 Oct 2024 15:32:33 +1000 Subject: [PATCH] prettier changes --- ...tationMessageListenerContainerFactory.java | 102 ++++++++++-------- ...tationMessageListenerContainerFactory.java | 31 +++--- .../annotations/core/basic/QueueListener.java | 4 +- .../core/basic/QueueListenerParser.java | 10 +- ...tationMessageListenerContainerFactory.java | 27 ++--- .../core/fifo/FifoQueueListener.java | 4 +- .../core/fifo/FifoQueueListenerParser.java | 10 +- ...tationMessageListenerContainerFactory.java | 27 ++--- .../prefetch/PrefetchingQueueListener.java | 4 +- .../PrefetchingQueueListenerParser.java | 7 +- .../AutoVisibilityExtender.java | 1 - ...nderMessageProcessingDecoratorFactory.java | 5 +- ...icMessageListenerContainerFactoryTest.java | 6 +- .../core/basic/QueueListenerParserTest.java | 3 +- .../fifo/FifoQueueListenerParserTest.java | 3 +- ...ngMessageListenerContainerFactoryTest.java | 29 +++-- .../PrefetchingQueueListenerParserTest.java | 3 +- ...MessageProcessingDecoratorFactoryTest.java | 2 +- .../MessageProcessingDecoratorFactory.java | 1 - .../DefaultPlaceholderQueueResolver.java | 3 +- .../StaticPlaceholderResolver.java | 2 +- .../DefaultPlaceholderQueueResolverTest.java | 3 +- .../DefaultSqsAsyncClientProviderTest.java | 1 - .../StaticPlaceholderResolverTest.java | 23 ++-- ...DecoratingMessageProcessorFactoryTest.java | 2 +- .../sqs/examples/MessageListeners.java | 9 +- .../examples/spring/aws/Application.java | 2 +- .../schemaregistry/ConsumerApplication.java | 2 +- .../IntegrationTestExampleApplication.java | 2 +- .../jashmore/sqs/examples/Application.java | 2 +- .../sqs/examples/MessageListeners.java | 2 +- .../jashmore/sqs/examples/Application.java | 2 +- .../sqs/examples/MessageListeners.java | 2 +- .../sqs/examples/MessageListeners.java | 2 +- .../xray/XrayExtensionIntegrationTest.java | 2 +- .../spring/SqsListenerXrayConfiguration.java | 2 +- .../SqsListenerXrayConfigurationTest.java | 2 +- ...gDecoratorAsynchronousIntegrationTest.java | 2 +- ...ageProcessingDecoratorIntegrationTest.java | 2 +- ...ingCloudSchemaRegistryIntegrationTest.java | 2 +- ...gumentResolutionSpringIntegrationTest.java | 2 +- ...MessageAttributeSpringIntegrationTest.java | 2 +- ...eSystemAttributeSpringIntegrationTest.java | 2 +- ...MultipleSqsAsyncClientIntegrationTest.java | 2 +- ...eueListenerEnvironmentIntegrationTest.java | 2 +- .../basic/QueueListenerIntegrationTest.java | 2 +- ...stenerMessageDecoratorIntegrationTest.java | 2 +- ...ueueListenerVisibilityIntegrationTest.java | 2 +- ...essingDecoratorFactoryIntegrationTest.java | 4 +- ...ueueListenerResolutionIntegrationTest.java | 2 +- ...erContainerCoordinatorIntegrationTest.java | 4 +- .../config/QueueListenerConfiguration.java | 21 ++-- ...ngMessageListenerContainerCoordinator.java | 28 ++--- .../QueueListenerConfigurationTest.java | 17 ++- ...ssageListenerContainerCoordinatorTest.java | 3 +- .../SpringPlaceholderResolverTest.java | 10 +- .../SpringObjectMapperIntegrationTest.java | 2 +- .../sqs/util/identifier/IdentifierUtils.java | 4 +- .../util/identifier/IdentifierUtilsTest.java | 1 - .../sqs/util/string/StringUtilsTest.java | 1 + 60 files changed, 241 insertions(+), 222 deletions(-) diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/container/AnnotationMessageListenerContainerFactory.java b/annotations/src/main/java/com/jashmore/sqs/annotations/container/AnnotationMessageListenerContainerFactory.java index 04dfa45b..5ae1d44f 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/container/AnnotationMessageListenerContainerFactory.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/container/AnnotationMessageListenerContainerFactory.java @@ -13,15 +13,14 @@ import com.jashmore.sqs.util.annotation.AnnotationUtils; import com.jashmore.sqs.util.identifier.IdentifierUtils; import com.jashmore.sqs.util.string.StringUtils; -import lombok.Builder; -import org.immutables.value.Value; -import software.amazon.awssdk.services.sqs.SqsAsyncClient; - import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Optional; import java.util.function.Function; import java.util.function.Supplier; +import lombok.Builder; +import org.immutables.value.Value; +import software.amazon.awssdk.services.sqs.SqsAsyncClient; /** * {@link MessageListenerContainerFactory} that can be used to build against an annotated method. @@ -29,6 +28,7 @@ * @param annotation that is applied on the method */ public class AnnotationMessageListenerContainerFactory implements MessageListenerContainerFactory { + private final Class annotationClass; private final Function identifierMapper; private final Function sqsClientIdentifier; @@ -52,15 +52,17 @@ public class AnnotationMessageListenerContainerFactory imp * @param argumentResolverService to map the parameters of the method to values in the message * @param containerFactory converts details about the annotation to the final {@link MessageListenerContainer} */ - public AnnotationMessageListenerContainerFactory(final Class annotationClass, - final Function identifierMapper, - final Function sqsClientIdentifierMapper, - final Function queueNameOrUrlMapper, - final QueueResolver queueResolver, - final SqsAsyncClientProvider sqsAsyncClientProvider, - final DecoratingMessageProcessorFactory decoratingMessageProcessorFactory, - final ArgumentResolverService argumentResolverService, - final Function, MessageListenerContainer> containerFactory) { + public AnnotationMessageListenerContainerFactory( + final Class annotationClass, + final Function identifierMapper, + final Function sqsClientIdentifierMapper, + final Function queueNameOrUrlMapper, + final QueueResolver queueResolver, + final SqsAsyncClientProvider sqsAsyncClientProvider, + final DecoratingMessageProcessorFactory decoratingMessageProcessorFactory, + final ArgumentResolverService argumentResolverService, + final Function, MessageListenerContainer> containerFactory + ) { this.annotationClass = annotationClass; this.identifierMapper = identifierMapper; this.sqsClientIdentifier = sqsClientIdentifierMapper; @@ -73,34 +75,43 @@ public AnnotationMessageListenerContainerFactory(final Class annotationClass, } @Override - public Optional buildContainer(final Object bean, final Method method) throws MessageListenerContainerInitialisationException { + public Optional buildContainer(final Object bean, final Method method) + throws MessageListenerContainerInitialisationException { return AnnotationUtils - .findMethodAnnotation(method, this.annotationClass) - .map(annotation -> { - final SqsAsyncClient sqsAsyncClient = getSqsAsyncClient(annotation); - final QueueProperties queueProperties = QueueProperties.builder() - .queueUrl(queueResolver.resolveQueueUrl(sqsAsyncClient, queueNameOrUrlMapper.apply(annotation))) - .build(); - final String identifier = IdentifierUtils.buildIdentifierForMethod(identifierMapper.apply(annotation), bean.getClass(), method); + .findMethodAnnotation(method, this.annotationClass) + .map(annotation -> { + final SqsAsyncClient sqsAsyncClient = getSqsAsyncClient(annotation); + final QueueProperties queueProperties = QueueProperties + .builder() + .queueUrl(queueResolver.resolveQueueUrl(sqsAsyncClient, queueNameOrUrlMapper.apply(annotation))) + .build(); + final String identifier = IdentifierUtils.buildIdentifierForMethod( + identifierMapper.apply(annotation), + bean.getClass(), + method + ); - final Supplier messageProcessorSupplier = () -> - decoratingMessageProcessorFactory.decorateMessageProcessor( - sqsAsyncClient, - identifier, - queueProperties, - bean, - method, - new CoreMessageProcessor(argumentResolverService, queueProperties, sqsAsyncClient, method, bean) - ); + final Supplier messageProcessorSupplier = () -> + decoratingMessageProcessorFactory.decorateMessageProcessor( + sqsAsyncClient, + identifier, + queueProperties, + bean, + method, + new CoreMessageProcessor(argumentResolverService, queueProperties, sqsAsyncClient, method, bean) + ); - return containerFactory.apply(AnnotationDetails.builder() - .identifier(identifier) - .queueProperties(queueProperties) - .sqsAsyncClient(sqsAsyncClient) - .messageProcessorSupplier(messageProcessorSupplier) - .annotation(annotation) - .build()); - }); + return containerFactory.apply( + AnnotationDetails + .builder() + .identifier(identifier) + .queueProperties(queueProperties) + .sqsAsyncClient(sqsAsyncClient) + .messageProcessorSupplier(messageProcessorSupplier) + .annotation(annotation) + .build() + ); + }); } private SqsAsyncClient getSqsAsyncClient(final A annotation) { @@ -108,21 +119,22 @@ private SqsAsyncClient getSqsAsyncClient(final A annotation) { if (!StringUtils.hasText(sqsClient)) { return sqsAsyncClientProvider - .getDefaultClient() - .orElseThrow(() -> new MessageListenerContainerInitialisationException("Expected the default SQS Client but there is none") - ); + .getDefaultClient() + .orElseThrow(() -> new MessageListenerContainerInitialisationException("Expected the default SQS Client but there is none") + ); } return sqsAsyncClientProvider - .getClient(sqsClient) - .orElseThrow(() -> - new MessageListenerContainerInitialisationException("Expected a client with id '" + sqsClient + "' but none were found") - ); + .getClient(sqsClient) + .orElseThrow(() -> + new MessageListenerContainerInitialisationException("Expected a client with id '" + sqsClient + "' but none were found") + ); } @Value @Builder public static class AnnotationDetails { + public String identifier; public SqsAsyncClient sqsAsyncClient; public QueueProperties queueProperties; diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/BasicAnnotationMessageListenerContainerFactory.java b/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/BasicAnnotationMessageListenerContainerFactory.java index f5e0e14e..765d9b68 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/BasicAnnotationMessageListenerContainerFactory.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/BasicAnnotationMessageListenerContainerFactory.java @@ -10,7 +10,6 @@ import com.jashmore.sqs.container.batching.BatchingMessageListenerContainer; import com.jashmore.sqs.container.batching.BatchingMessageListenerContainerProperties; import com.jashmore.sqs.processor.DecoratingMessageProcessorFactory; - import java.lang.reflect.Method; import java.util.Optional; @@ -23,13 +22,14 @@ public class BasicAnnotationMessageListenerContainerFactory implements MessageLi private final AnnotationMessageListenerContainerFactory delegate; public BasicAnnotationMessageListenerContainerFactory( - final ArgumentResolverService argumentResolverService, - final SqsAsyncClientProvider sqsAsyncClientProvider, - final QueueResolver queueResolver, - final QueueListenerParser queueListenerParser, - final DecoratingMessageProcessorFactory decoratingMessageProcessorFactory + final ArgumentResolverService argumentResolverService, + final SqsAsyncClientProvider sqsAsyncClientProvider, + final QueueResolver queueResolver, + final QueueListenerParser queueListenerParser, + final DecoratingMessageProcessorFactory decoratingMessageProcessorFactory ) { - this.delegate = new AnnotationMessageListenerContainerFactory<>( + this.delegate = + new AnnotationMessageListenerContainerFactory<>( QueueListener.class, QueueListener::identifier, QueueListener::sqsClient, @@ -38,21 +38,22 @@ public BasicAnnotationMessageListenerContainerFactory( sqsAsyncClientProvider, decoratingMessageProcessorFactory, argumentResolverService, - (details) -> { + details -> { final BatchingMessageListenerContainerProperties properties = queueListenerParser.parse(details.annotation); return new BatchingMessageListenerContainer( - details.identifier, - details.queueProperties, - details.sqsAsyncClient, - details.messageProcessorSupplier, - properties + details.identifier, + details.queueProperties, + details.sqsAsyncClient, + details.messageProcessorSupplier, + properties ); } - ); + ); } @Override - public Optional buildContainer(final Object bean, final Method method) throws MessageListenerContainerInitialisationException { + public Optional buildContainer(final Object bean, final Method method) + throws MessageListenerContainerInitialisationException { return this.delegate.buildContainer(bean, method); } } diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/QueueListener.java b/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/QueueListener.java index fa8c05fb..3a9517c6 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/QueueListener.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/QueueListener.java @@ -4,15 +4,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.jashmore.sqs.QueueProperties; -import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.aws.AwsConstants; import com.jashmore.sqs.broker.concurrent.ConcurrentMessageBroker; import com.jashmore.sqs.broker.concurrent.ConcurrentMessageBrokerProperties; +import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.container.MessageListenerContainer; +import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.processor.CoreMessageProcessor; import com.jashmore.sqs.retriever.batching.BatchingMessageRetriever; import com.jashmore.sqs.retriever.batching.BatchingMessageRetrieverProperties; -import com.jashmore.sqs.client.SqsAsyncClientProvider; import java.lang.annotation.Retention; import java.lang.annotation.Target; import software.amazon.awssdk.services.sqs.SqsAsyncClient; diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/QueueListenerParser.java b/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/QueueListenerParser.java index 1e978cf1..4b31b77d 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/QueueListenerParser.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/core/basic/QueueListenerParser.java @@ -4,11 +4,10 @@ import com.jashmore.documentation.annotations.Nullable; import com.jashmore.documentation.annotations.Positive; import com.jashmore.documentation.annotations.PositiveOrZero; -import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.aws.AwsConstants; import com.jashmore.sqs.container.batching.BatchingMessageListenerContainerProperties; +import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.util.string.StringUtils; - import java.time.Duration; import java.util.function.Supplier; @@ -153,7 +152,8 @@ protected Supplier batchingPeriodSupplier(final QueueListener annotati if (!StringUtils.hasText(annotation.batchingPeriodInMsString())) { batchingPeriod = Duration.ofMillis(annotation.batchingPeriodInMs()); } else { - batchingPeriod = Duration.ofMillis(Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.batchingPeriodInMsString()))); + batchingPeriod = + Duration.ofMillis(Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.batchingPeriodInMsString()))); } return () -> batchingPeriod; } @@ -192,7 +192,9 @@ protected Supplier messageVisibilityTimeoutSupplier(final QueueListene } } else { messageVisibilityTimeout = - Duration.ofSeconds(Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.messageVisibilityTimeoutInSecondsString()))); + Duration.ofSeconds( + Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.messageVisibilityTimeoutInSecondsString())) + ); } return () -> messageVisibilityTimeout; diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoAnnotationMessageListenerContainerFactory.java b/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoAnnotationMessageListenerContainerFactory.java index 55d290fa..a14bf11c 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoAnnotationMessageListenerContainerFactory.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoAnnotationMessageListenerContainerFactory.java @@ -2,15 +2,14 @@ import com.jashmore.sqs.annotations.container.AnnotationMessageListenerContainerFactory; import com.jashmore.sqs.argument.ArgumentResolverService; +import com.jashmore.sqs.client.QueueResolver; +import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.container.MessageListenerContainer; +import com.jashmore.sqs.container.MessageListenerContainerFactory; import com.jashmore.sqs.container.MessageListenerContainerInitialisationException; import com.jashmore.sqs.container.fifo.FifoMessageListenerContainer; import com.jashmore.sqs.container.fifo.FifoMessageListenerContainerProperties; -import com.jashmore.sqs.client.SqsAsyncClientProvider; -import com.jashmore.sqs.container.MessageListenerContainerFactory; import com.jashmore.sqs.processor.DecoratingMessageProcessorFactory; -import com.jashmore.sqs.client.QueueResolver; - import java.lang.reflect.Method; import java.util.Optional; @@ -36,7 +35,8 @@ public FifoAnnotationMessageListenerContainerFactory( final FifoQueueListenerParser annotationParser, final DecoratingMessageProcessorFactory decoratingMessageProcessorFactory ) { - this.delegate = new AnnotationMessageListenerContainerFactory<>( + this.delegate = + new AnnotationMessageListenerContainerFactory<>( FifoQueueListener.class, FifoQueueListener::identifier, FifoQueueListener::sqsClient, @@ -45,21 +45,22 @@ public FifoAnnotationMessageListenerContainerFactory( sqsAsyncClientProvider, decoratingMessageProcessorFactory, argumentResolverService, - (details) -> { + details -> { final FifoMessageListenerContainerProperties properties = annotationParser.parse(details.annotation); return new FifoMessageListenerContainer( - details.identifier, - details.queueProperties, - details.sqsAsyncClient, - details.messageProcessorSupplier, - properties + details.identifier, + details.queueProperties, + details.sqsAsyncClient, + details.messageProcessorSupplier, + properties ); } - ); + ); } @Override - public Optional buildContainer(Object bean, Method method) throws MessageListenerContainerInitialisationException { + public Optional buildContainer(Object bean, Method method) + throws MessageListenerContainerInitialisationException { return this.delegate.buildContainer(bean, method); } } diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListener.java b/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListener.java index 97789edb..fd546b1c 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListener.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListener.java @@ -4,14 +4,14 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.jashmore.sqs.QueueProperties; -import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.aws.AwsConstants; import com.jashmore.sqs.broker.grouping.GroupingMessageBroker; import com.jashmore.sqs.broker.grouping.GroupingMessageBrokerProperties; +import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.container.MessageListenerContainer; import com.jashmore.sqs.container.fifo.FifoMessageListenerContainerProperties; +import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.retriever.batching.BatchingMessageRetrieverProperties; -import com.jashmore.sqs.client.SqsAsyncClientProvider; import java.lang.annotation.Retention; import java.lang.annotation.Target; import software.amazon.awssdk.services.sqs.SqsAsyncClient; diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListenerParser.java b/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListenerParser.java index 119e42e9..178d0e1b 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListenerParser.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListenerParser.java @@ -1,10 +1,9 @@ package com.jashmore.sqs.annotations.core.fifo; import com.jashmore.documentation.annotations.Nullable; -import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.container.fifo.FifoMessageListenerContainerProperties; +import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.util.string.StringUtils; - import java.time.Duration; import java.util.function.Supplier; @@ -140,7 +139,8 @@ protected Supplier maximumCachedMessageGroupsSupplier(final FifoQueueLi if (!StringUtils.hasText(annotation.maximumCachedMessageGroupsString())) { maximumCachedMessageGroups = annotation.maximumCachedMessageGroups(); } else { - maximumCachedMessageGroups = Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.maximumCachedMessageGroupsString())); + maximumCachedMessageGroups = + Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.maximumCachedMessageGroupsString())); } return () -> maximumCachedMessageGroups; } @@ -178,7 +178,9 @@ protected Supplier messageVisibilityTimeoutSupplier(final FifoQueueLis } } else { messageVisibilityTimeout = - Duration.ofSeconds(Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.messageVisibilityTimeoutInSecondsString()))); + Duration.ofSeconds( + Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.messageVisibilityTimeoutInSecondsString())) + ); } return () -> messageVisibilityTimeout; diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingAnnotationMessageListenerContainerFactory.java b/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingAnnotationMessageListenerContainerFactory.java index bb51a13c..8e3a3f97 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingAnnotationMessageListenerContainerFactory.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingAnnotationMessageListenerContainerFactory.java @@ -2,15 +2,14 @@ import com.jashmore.sqs.annotations.container.AnnotationMessageListenerContainerFactory; import com.jashmore.sqs.argument.ArgumentResolverService; +import com.jashmore.sqs.client.QueueResolver; +import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.container.MessageListenerContainer; +import com.jashmore.sqs.container.MessageListenerContainerFactory; import com.jashmore.sqs.container.MessageListenerContainerInitialisationException; import com.jashmore.sqs.container.prefetching.PrefetchingMessageListenerContainer; import com.jashmore.sqs.container.prefetching.PrefetchingMessageListenerContainerProperties; -import com.jashmore.sqs.client.SqsAsyncClientProvider; -import com.jashmore.sqs.container.MessageListenerContainerFactory; import com.jashmore.sqs.processor.DecoratingMessageProcessorFactory; -import com.jashmore.sqs.client.QueueResolver; - import java.lang.reflect.Method; import java.util.Optional; @@ -29,7 +28,8 @@ public PrefetchingAnnotationMessageListenerContainerFactory( final PrefetchingQueueListenerParser annotationParser, final DecoratingMessageProcessorFactory decoratingMessageProcessorFactory ) { - this.delegate = new AnnotationMessageListenerContainerFactory<>( + this.delegate = + new AnnotationMessageListenerContainerFactory<>( PrefetchingQueueListener.class, PrefetchingQueueListener::identifier, PrefetchingQueueListener::sqsClient, @@ -38,21 +38,22 @@ public PrefetchingAnnotationMessageListenerContainerFactory( sqsAsyncClientProvider, decoratingMessageProcessorFactory, argumentResolverService, - (details) -> { + details -> { final PrefetchingMessageListenerContainerProperties properties = annotationParser.parse(details.annotation); return new PrefetchingMessageListenerContainer( - details.identifier, - details.queueProperties, - details.sqsAsyncClient, - details.messageProcessorSupplier, - properties + details.identifier, + details.queueProperties, + details.sqsAsyncClient, + details.messageProcessorSupplier, + properties ); } - ); + ); } @Override - public Optional buildContainer(Object bean, Method method) throws MessageListenerContainerInitialisationException { + public Optional buildContainer(Object bean, Method method) + throws MessageListenerContainerInitialisationException { return this.delegate.buildContainer(bean, method); } } diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListener.java b/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListener.java index 706a6493..4b1aa7b1 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListener.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListener.java @@ -5,15 +5,15 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.jashmore.sqs.QueueProperties; -import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.broker.concurrent.ConcurrentMessageBroker; import com.jashmore.sqs.broker.concurrent.ConcurrentMessageBrokerProperties; +import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.container.MessageListenerContainer; +import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.processor.CoreMessageProcessor; import com.jashmore.sqs.retriever.batching.BatchingMessageRetrieverProperties; import com.jashmore.sqs.retriever.prefetch.PrefetchingMessageRetriever; import com.jashmore.sqs.retriever.prefetch.PrefetchingMessageRetrieverProperties; -import com.jashmore.sqs.client.SqsAsyncClientProvider; import java.lang.annotation.Retention; import java.lang.annotation.Target; import software.amazon.awssdk.services.sqs.SqsAsyncClient; diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListenerParser.java b/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListenerParser.java index a5ba1c94..55ccd8e5 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListenerParser.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListenerParser.java @@ -3,10 +3,9 @@ import com.jashmore.documentation.annotations.Nullable; import com.jashmore.documentation.annotations.Positive; import com.jashmore.documentation.annotations.PositiveOrZero; -import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.container.prefetching.PrefetchingMessageListenerContainerProperties; +import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.util.string.StringUtils; - import java.time.Duration; import java.util.function.Supplier; @@ -189,7 +188,9 @@ protected Supplier messageVisibilityTimeoutSupplier(final PrefetchingQ } } else { messageVisibilityTimeout = - Duration.ofSeconds(Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.messageVisibilityTimeoutInSecondsString()))); + Duration.ofSeconds( + Integer.parseInt(placeholderResolver.resolvePlaceholders(annotation.messageVisibilityTimeoutInSecondsString())) + ); } return () -> messageVisibilityTimeout; diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtender.java b/annotations/src/main/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtender.java index dd33a4f1..782c9600 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtender.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtender.java @@ -5,7 +5,6 @@ import com.jashmore.sqs.decorator.AutoVisibilityExtenderMessageProcessingDecorator; import com.jashmore.sqs.decorator.AutoVisibilityExtenderMessageProcessingDecoratorProperties; - import java.lang.annotation.Retention; import java.lang.annotation.Target; diff --git a/annotations/src/main/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactory.java b/annotations/src/main/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactory.java index f87009b5..68e488a7 100644 --- a/annotations/src/main/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactory.java +++ b/annotations/src/main/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactory.java @@ -2,19 +2,18 @@ import com.jashmore.documentation.annotations.VisibleForTesting; import com.jashmore.sqs.QueueProperties; -import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.decorator.AutoVisibilityExtenderMessageProcessingDecorator; import com.jashmore.sqs.decorator.AutoVisibilityExtenderMessageProcessingDecoratorProperties; import com.jashmore.sqs.decorator.MessageProcessingDecoratorFactory; import com.jashmore.sqs.decorator.MessageProcessingDecoratorFactoryException; +import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.util.annotation.AnnotationUtils; +import com.jashmore.sqs.util.string.StringUtils; import java.lang.reflect.Method; import java.time.Duration; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; - -import com.jashmore.sqs.util.string.StringUtils; import software.amazon.awssdk.services.sqs.SqsAsyncClient; /** diff --git a/annotations/src/test/java/com/jashmore/sqs/annotations/core/basic/BasicMessageListenerContainerFactoryTest.java b/annotations/src/test/java/com/jashmore/sqs/annotations/core/basic/BasicMessageListenerContainerFactoryTest.java index c38ee094..222c182f 100644 --- a/annotations/src/test/java/com/jashmore/sqs/annotations/core/basic/BasicMessageListenerContainerFactoryTest.java +++ b/annotations/src/test/java/com/jashmore/sqs/annotations/core/basic/BasicMessageListenerContainerFactoryTest.java @@ -8,13 +8,13 @@ import static org.mockito.Mockito.when; import com.jashmore.sqs.argument.ArgumentResolverService; -import com.jashmore.sqs.container.MessageListenerContainer; -import com.jashmore.sqs.container.batching.BatchingMessageListenerContainer; +import com.jashmore.sqs.client.QueueResolver; import com.jashmore.sqs.client.SqsAsyncClientProvider; +import com.jashmore.sqs.container.MessageListenerContainer; import com.jashmore.sqs.container.MessageListenerContainerInitialisationException; +import com.jashmore.sqs.container.batching.BatchingMessageListenerContainer; import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.processor.DecoratingMessageProcessorFactory; -import com.jashmore.sqs.client.QueueResolver; import java.lang.reflect.Method; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; diff --git a/annotations/src/test/java/com/jashmore/sqs/annotations/core/basic/QueueListenerParserTest.java b/annotations/src/test/java/com/jashmore/sqs/annotations/core/basic/QueueListenerParserTest.java index 1b901019..40a99491 100644 --- a/annotations/src/test/java/com/jashmore/sqs/annotations/core/basic/QueueListenerParserTest.java +++ b/annotations/src/test/java/com/jashmore/sqs/annotations/core/basic/QueueListenerParserTest.java @@ -3,9 +3,8 @@ import static org.assertj.core.api.Assertions.assertThat; import com.jashmore.sqs.container.batching.BatchingMessageListenerContainerProperties; -import java.time.Duration; - import com.jashmore.sqs.placeholder.StaticPlaceholderResolver; +import java.time.Duration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/annotations/src/test/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListenerParserTest.java b/annotations/src/test/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListenerParserTest.java index 02255a10..14a79ca1 100644 --- a/annotations/src/test/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListenerParserTest.java +++ b/annotations/src/test/java/com/jashmore/sqs/annotations/core/fifo/FifoQueueListenerParserTest.java @@ -3,9 +3,8 @@ import static org.assertj.core.api.Assertions.assertThat; import com.jashmore.sqs.container.fifo.FifoMessageListenerContainerProperties; -import java.time.Duration; - import com.jashmore.sqs.placeholder.StaticPlaceholderResolver; +import java.time.Duration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/annotations/src/test/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingMessageListenerContainerFactoryTest.java b/annotations/src/test/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingMessageListenerContainerFactoryTest.java index a1f33fe2..a0ea9c78 100644 --- a/annotations/src/test/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingMessageListenerContainerFactoryTest.java +++ b/annotations/src/test/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingMessageListenerContainerFactoryTest.java @@ -8,13 +8,13 @@ import static org.mockito.Mockito.when; import com.jashmore.sqs.argument.ArgumentResolverService; -import com.jashmore.sqs.container.MessageListenerContainer; -import com.jashmore.sqs.container.prefetching.PrefetchingMessageListenerContainer; +import com.jashmore.sqs.client.QueueResolver; import com.jashmore.sqs.client.SqsAsyncClientProvider; +import com.jashmore.sqs.container.MessageListenerContainer; import com.jashmore.sqs.container.MessageListenerContainerInitialisationException; +import com.jashmore.sqs.container.prefetching.PrefetchingMessageListenerContainer; import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.processor.DecoratingMessageProcessorFactory; -import com.jashmore.sqs.client.QueueResolver; import java.lang.reflect.Method; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; @@ -72,7 +72,10 @@ void canBuildMessageListenerContainer() throws NoSuchMethodException { final Method method = PrefetchingMessageListenerContainerFactoryTest.class.getMethod("myMethod"); // act - final Optional messageListenerContainer = prefetchingMessageListenerContainerFactory.buildContainer(bean, method); + final Optional messageListenerContainer = prefetchingMessageListenerContainerFactory.buildContainer( + bean, + method + ); // assert assertThat(messageListenerContainer).containsInstanceOf(PrefetchingMessageListenerContainer.class); @@ -86,11 +89,15 @@ void queueListenerWrapperWithoutIdentifierWillConstructOneByDefault() throws NoS final Method method = PrefetchingMessageListenerContainerFactoryTest.class.getMethod("myMethod"); // act - final Optional messageListenerContainer = prefetchingMessageListenerContainerFactory.buildContainer(bean, method); + final Optional messageListenerContainer = prefetchingMessageListenerContainerFactory.buildContainer( + bean, + method + ); // assert assertThat(messageListenerContainer).isNotEmpty(); - assertThat(messageListenerContainer.get().getIdentifier()).isEqualTo("prefetching-message-listener-container-factory-test-my-method"); + assertThat(messageListenerContainer.get().getIdentifier()) + .isEqualTo("prefetching-message-listener-container-factory-test-my-method"); } @Test @@ -101,7 +108,10 @@ void queueListenerWrapperWithIdentifierWillUseThatForTheMessageListenerContainer final Method method = PrefetchingMessageListenerContainerFactoryTest.class.getMethod("myMethodWithIdentifier"); // act - final Optional messageListenerContainer = prefetchingMessageListenerContainerFactory.buildContainer(bean, method); + final Optional messageListenerContainer = prefetchingMessageListenerContainerFactory.buildContainer( + bean, + method + ); // assert assertThat(messageListenerContainer).isNotEmpty(); @@ -183,7 +193,10 @@ void validStringFieldsWillCorrectlyBuildMessageListener() throws Exception { final Method method = PrefetchingMessageListenerContainerFactoryTest.class.getMethod("methodWithFieldsUsingEnvironmentProperties"); // act - final Optional messageListenerContainer = prefetchingMessageListenerContainerFactory.buildContainer(bean, method); + final Optional messageListenerContainer = prefetchingMessageListenerContainerFactory.buildContainer( + bean, + method + ); // assert assertThat(messageListenerContainer).isNotEmpty(); diff --git a/annotations/src/test/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListenerParserTest.java b/annotations/src/test/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListenerParserTest.java index 4c70752c..88a88d7e 100644 --- a/annotations/src/test/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListenerParserTest.java +++ b/annotations/src/test/java/com/jashmore/sqs/annotations/core/prefetch/PrefetchingQueueListenerParserTest.java @@ -3,9 +3,8 @@ import static org.assertj.core.api.Assertions.assertThat; import com.jashmore.sqs.container.prefetching.PrefetchingMessageListenerContainerProperties; -import java.time.Duration; - import com.jashmore.sqs.placeholder.StaticPlaceholderResolver; +import java.time.Duration; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/annotations/src/test/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactoryTest.java b/annotations/src/test/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactoryTest.java index 0f6b60d9..9650222f 100644 --- a/annotations/src/test/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactoryTest.java +++ b/annotations/src/test/java/com/jashmore/sqs/annotations/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactoryTest.java @@ -8,10 +8,10 @@ import com.jashmore.sqs.QueueProperties; import com.jashmore.sqs.decorator.AutoVisibilityExtenderMessageProcessingDecorator; import com.jashmore.sqs.decorator.AutoVisibilityExtenderMessageProcessingDecoratorProperties; +import com.jashmore.sqs.decorator.MessageProcessingDecoratorFactoryException; import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.processor.DecoratingMessageProcessor; import com.jashmore.sqs.processor.LambdaMessageProcessor; -import com.jashmore.sqs.decorator.MessageProcessingDecoratorFactoryException; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.time.Duration; diff --git a/api/src/main/java/com/jashmore/sqs/decorator/MessageProcessingDecoratorFactory.java b/api/src/main/java/com/jashmore/sqs/decorator/MessageProcessingDecoratorFactory.java index 0ecc919e..d9a2172e 100644 --- a/api/src/main/java/com/jashmore/sqs/decorator/MessageProcessingDecoratorFactory.java +++ b/api/src/main/java/com/jashmore/sqs/decorator/MessageProcessingDecoratorFactory.java @@ -1,7 +1,6 @@ package com.jashmore.sqs.decorator; import com.jashmore.sqs.QueueProperties; - import java.lang.reflect.Method; import java.util.Optional; import software.amazon.awssdk.services.sqs.SqsAsyncClient; diff --git a/core/src/main/java/com/jashmore/sqs/client/DefaultPlaceholderQueueResolver.java b/core/src/main/java/com/jashmore/sqs/client/DefaultPlaceholderQueueResolver.java index 4b4367a6..5f26e2a3 100644 --- a/core/src/main/java/com/jashmore/sqs/client/DefaultPlaceholderQueueResolver.java +++ b/core/src/main/java/com/jashmore/sqs/client/DefaultPlaceholderQueueResolver.java @@ -1,8 +1,7 @@ package com.jashmore.sqs.client; -import java.util.concurrent.ExecutionException; - import com.jashmore.sqs.placeholder.PlaceholderResolver; +import java.util.concurrent.ExecutionException; import software.amazon.awssdk.services.sqs.SqsAsyncClient; /** diff --git a/core/src/main/java/com/jashmore/sqs/placeholder/StaticPlaceholderResolver.java b/core/src/main/java/com/jashmore/sqs/placeholder/StaticPlaceholderResolver.java index 1fe0f90f..6167c4cb 100644 --- a/core/src/main/java/com/jashmore/sqs/placeholder/StaticPlaceholderResolver.java +++ b/core/src/main/java/com/jashmore/sqs/placeholder/StaticPlaceholderResolver.java @@ -1,7 +1,6 @@ package com.jashmore.sqs.placeholder; import com.jashmore.documentation.annotations.Nonnull; - import java.util.HashMap; import java.util.Map; @@ -10,6 +9,7 @@ * replace from a static map of values. This is mostly only useful for testing. */ public class StaticPlaceholderResolver implements PlaceholderResolver { + private final Map placeholderMap; public StaticPlaceholderResolver() { diff --git a/core/src/test/java/com/jashmore/sqs/client/DefaultPlaceholderQueueResolverTest.java b/core/src/test/java/com/jashmore/sqs/client/DefaultPlaceholderQueueResolverTest.java index 2120dd7d..dfb4934a 100644 --- a/core/src/test/java/com/jashmore/sqs/client/DefaultPlaceholderQueueResolverTest.java +++ b/core/src/test/java/com/jashmore/sqs/client/DefaultPlaceholderQueueResolverTest.java @@ -4,11 +4,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; +import com.jashmore.sqs.placeholder.PlaceholderResolver; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; - -import com.jashmore.sqs.placeholder.PlaceholderResolver; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/core/src/test/java/com/jashmore/sqs/client/DefaultSqsAsyncClientProviderTest.java b/core/src/test/java/com/jashmore/sqs/client/DefaultSqsAsyncClientProviderTest.java index 98cbb161..246e45f8 100644 --- a/core/src/test/java/com/jashmore/sqs/client/DefaultSqsAsyncClientProviderTest.java +++ b/core/src/test/java/com/jashmore/sqs/client/DefaultSqsAsyncClientProviderTest.java @@ -6,7 +6,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; diff --git a/core/src/test/java/com/jashmore/sqs/placeholder/StaticPlaceholderResolverTest.java b/core/src/test/java/com/jashmore/sqs/placeholder/StaticPlaceholderResolverTest.java index 2367f43b..78648859 100644 --- a/core/src/test/java/com/jashmore/sqs/placeholder/StaticPlaceholderResolverTest.java +++ b/core/src/test/java/com/jashmore/sqs/placeholder/StaticPlaceholderResolverTest.java @@ -1,36 +1,33 @@ package com.jashmore.sqs.placeholder; -import org.junit.jupiter.api.Test; - import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.Test; + class StaticPlaceholderResolverTest { @Test void canReplacePlaceholdersFromStaticList() { assertThat(new StaticPlaceholderResolver().withMapping("from", "to").resolvePlaceholders("from something")) - .isEqualTo("to something"); + .isEqualTo("to something"); } @Test void resettingPlaceholdersWillClearMapping() { - final StaticPlaceholderResolver placeholderResolver = new StaticPlaceholderResolver() - .withMapping("from", "to"); + final StaticPlaceholderResolver placeholderResolver = new StaticPlaceholderResolver().withMapping("from", "to"); placeholderResolver.reset(); - assertThat(placeholderResolver.resolvePlaceholders("from something")) - .isEqualTo("from something"); + assertThat(placeholderResolver.resolvePlaceholders("from something")).isEqualTo("from something"); } @Test void canChangePlaceholderReplacements() { final StaticPlaceholderResolver placeholderResolver = new StaticPlaceholderResolver() - .withMapping("first", "second") - .withMapping("second", "third word") - .withMapping("third", "fourth"); + .withMapping("first", "second") + .withMapping("second", "third word") + .withMapping("third", "fourth"); - assertThat(placeholderResolver.resolvePlaceholders("first for us")) - .isEqualTo("fourth word for us"); + assertThat(placeholderResolver.resolvePlaceholders("first for us")).isEqualTo("fourth word for us"); } -} \ No newline at end of file +} diff --git a/core/src/test/java/com/jashmore/sqs/spring/processor/DecoratingMessageProcessorFactoryTest.java b/core/src/test/java/com/jashmore/sqs/spring/processor/DecoratingMessageProcessorFactoryTest.java index 0e81e2ed..a013b838 100644 --- a/core/src/test/java/com/jashmore/sqs/spring/processor/DecoratingMessageProcessorFactoryTest.java +++ b/core/src/test/java/com/jashmore/sqs/spring/processor/DecoratingMessageProcessorFactoryTest.java @@ -6,9 +6,9 @@ import com.jashmore.sqs.QueueProperties; import com.jashmore.sqs.decorator.MessageProcessingDecorator; +import com.jashmore.sqs.decorator.MessageProcessingDecoratorFactory; import com.jashmore.sqs.processor.DecoratingMessageProcessorFactory; import com.jashmore.sqs.processor.MessageProcessor; -import com.jashmore.sqs.decorator.MessageProcessingDecoratorFactory; import java.util.Collections; import java.util.Optional; import java.util.concurrent.CompletableFuture; diff --git a/examples/auto-visibility-extender-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java b/examples/auto-visibility-extender-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java index d73af7f8..33bf97cf 100644 --- a/examples/auto-visibility-extender-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java +++ b/examples/auto-visibility-extender-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java @@ -2,16 +2,15 @@ import static com.jashmore.sqs.examples.Application.QUEUE_NAME; -import java.time.Duration; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.annotations.decorator.visibilityextender.AutoVisibilityExtender; import com.jashmore.sqs.argument.attribute.MessageSystemAttribute; import com.jashmore.sqs.argument.messageid.MessageId; import com.jashmore.sqs.processor.argument.Acknowledge; +import java.time.Duration; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import software.amazon.awssdk.services.sqs.model.MessageSystemAttributeName; diff --git a/examples/spring-aws-example/src/main/java/com/jashmore/examples/spring/aws/Application.java b/examples/spring-aws-example/src/main/java/com/jashmore/examples/spring/aws/Application.java index 1db4e81c..5bb5b96d 100644 --- a/examples/spring-aws-example/src/main/java/com/jashmore/examples/spring/aws/Application.java +++ b/examples/spring-aws-example/src/main/java/com/jashmore/examples/spring/aws/Application.java @@ -1,7 +1,7 @@ package com.jashmore.examples.spring.aws; -import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.annotations.core.basic.QueueListener; +import com.jashmore.sqs.argument.payload.Payload; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/examples/spring-cloud-schema-registry-example/spring-cloud-schema-registry-consumer/src/main/java/com/jashmore/sqs/examples/schemaregistry/ConsumerApplication.java b/examples/spring-cloud-schema-registry-example/spring-cloud-schema-registry-consumer/src/main/java/com/jashmore/sqs/examples/schemaregistry/ConsumerApplication.java index d4f42671..2ea34bb8 100644 --- a/examples/spring-cloud-schema-registry-example/spring-cloud-schema-registry-consumer/src/main/java/com/jashmore/sqs/examples/schemaregistry/ConsumerApplication.java +++ b/examples/spring-cloud-schema-registry-example/spring-cloud-schema-registry-consumer/src/main/java/com/jashmore/sqs/examples/schemaregistry/ConsumerApplication.java @@ -1,9 +1,9 @@ package com.jashmore.sqs.examples.schemaregistry; import com.example.Sensor; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.extensions.registry.SpringCloudSchemaRegistryPayload; import com.jashmore.sqs.extensions.registry.avro.EnableSchemaRegistrySqsExtension; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClientImpl; import com.jashmore.sqs.util.SqsQueuesConfig; import lombok.extern.slf4j.Slf4j; diff --git a/examples/spring-integration-test-example/src/main/java/com/jashmore/sqs/examples/integrationtests/IntegrationTestExampleApplication.java b/examples/spring-integration-test-example/src/main/java/com/jashmore/sqs/examples/integrationtests/IntegrationTestExampleApplication.java index fa66f196..ffc750cb 100644 --- a/examples/spring-integration-test-example/src/main/java/com/jashmore/sqs/examples/integrationtests/IntegrationTestExampleApplication.java +++ b/examples/spring-integration-test-example/src/main/java/com/jashmore/sqs/examples/integrationtests/IntegrationTestExampleApplication.java @@ -1,7 +1,7 @@ package com.jashmore.sqs.examples.integrationtests; -import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.annotations.core.basic.QueueListener; +import com.jashmore.sqs.argument.payload.Payload; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; diff --git a/examples/spring-multiple-aws-account-example/src/main/java/com/jashmore/sqs/examples/Application.java b/examples/spring-multiple-aws-account-example/src/main/java/com/jashmore/sqs/examples/Application.java index 04ea2a2a..5f0f9807 100644 --- a/examples/spring-multiple-aws-account-example/src/main/java/com/jashmore/sqs/examples/Application.java +++ b/examples/spring-multiple-aws-account-example/src/main/java/com/jashmore/sqs/examples/Application.java @@ -1,8 +1,8 @@ package com.jashmore.sqs.examples; -import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.client.DefaultSqsAsyncClientProvider; import com.jashmore.sqs.client.SqsAsyncClientProvider; +import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import java.util.HashMap; import java.util.Map; import lombok.extern.slf4j.Slf4j; diff --git a/examples/spring-multiple-aws-account-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java b/examples/spring-multiple-aws-account-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java index 4fa06189..c2cc8a47 100644 --- a/examples/spring-multiple-aws-account-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java +++ b/examples/spring-multiple-aws-account-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java @@ -1,7 +1,7 @@ package com.jashmore.sqs.examples; -import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.annotations.core.basic.QueueListener; +import com.jashmore.sqs.argument.payload.Payload; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; diff --git a/examples/spring-starter-example/src/main/java/com/jashmore/sqs/examples/Application.java b/examples/spring-starter-example/src/main/java/com/jashmore/sqs/examples/Application.java index 60ff6333..93f0dcd0 100644 --- a/examples/spring-starter-example/src/main/java/com/jashmore/sqs/examples/Application.java +++ b/examples/spring-starter-example/src/main/java/com/jashmore/sqs/examples/Application.java @@ -1,8 +1,8 @@ package com.jashmore.sqs.examples; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.annotations.core.prefetch.PrefetchingQueueListener; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClientImpl; import com.jashmore.sqs.util.SqsQueuesConfig; import lombok.extern.slf4j.Slf4j; diff --git a/examples/spring-starter-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java b/examples/spring-starter-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java index 2a5b5832..fea120f8 100644 --- a/examples/spring-starter-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java +++ b/examples/spring-starter-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java @@ -1,8 +1,8 @@ package com.jashmore.sqs.examples; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.annotations.core.prefetch.PrefetchingQueueListener; import com.jashmore.sqs.argument.payload.Payload; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import java.util.concurrent.atomic.AtomicInteger; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; diff --git a/examples/spring-starter-minimal-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java b/examples/spring-starter-minimal-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java index 938ab44c..2c7edcb9 100644 --- a/examples/spring-starter-minimal-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java +++ b/examples/spring-starter-minimal-example/src/main/java/com/jashmore/sqs/examples/MessageListeners.java @@ -1,7 +1,7 @@ package com.jashmore.sqs.examples; -import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.annotations.core.basic.QueueListener; +import com.jashmore.sqs.argument.payload.Payload; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; diff --git a/extensions/aws-xray-extension/spring-boot/src/integrationTest/java/com/jashmore/sqs/extensions/xray/XrayExtensionIntegrationTest.java b/extensions/aws-xray-extension/spring-boot/src/integrationTest/java/com/jashmore/sqs/extensions/xray/XrayExtensionIntegrationTest.java index 55d531b4..83c98529 100644 --- a/extensions/aws-xray-extension/spring-boot/src/integrationTest/java/com/jashmore/sqs/extensions/xray/XrayExtensionIntegrationTest.java +++ b/extensions/aws-xray-extension/spring-boot/src/integrationTest/java/com/jashmore/sqs/extensions/xray/XrayExtensionIntegrationTest.java @@ -7,10 +7,10 @@ import com.amazonaws.xray.AWSXRayRecorderBuilder; import com.amazonaws.xray.config.DaemonConfiguration; import com.amazonaws.xray.emitters.Emitter; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.extensions.xray.spring.SqsListenerXrayConfiguration; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.io.IOException; import java.net.DatagramPacket; diff --git a/extensions/aws-xray-extension/spring-boot/src/main/java/com/jashmore/sqs/extensions/xray/spring/SqsListenerXrayConfiguration.java b/extensions/aws-xray-extension/spring-boot/src/main/java/com/jashmore/sqs/extensions/xray/spring/SqsListenerXrayConfiguration.java index da3eb860..89c942ac 100644 --- a/extensions/aws-xray-extension/spring-boot/src/main/java/com/jashmore/sqs/extensions/xray/spring/SqsListenerXrayConfiguration.java +++ b/extensions/aws-xray-extension/spring-boot/src/main/java/com/jashmore/sqs/extensions/xray/spring/SqsListenerXrayConfiguration.java @@ -3,6 +3,7 @@ import com.amazonaws.xray.AWSXRay; import com.amazonaws.xray.AWSXRayRecorder; import com.jashmore.sqs.client.DefaultSqsAsyncClientProvider; +import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.extensions.xray.client.ClientSegmentMutator; import com.jashmore.sqs.extensions.xray.client.ClientSegmentNamingStrategy; import com.jashmore.sqs.extensions.xray.client.StaticClientSegmentNamingStrategy; @@ -10,7 +11,6 @@ import com.jashmore.sqs.extensions.xray.client.XrayWrappedSqsAsyncClient; import com.jashmore.sqs.extensions.xray.decorator.BasicXrayMessageProcessingDecorator; import com.jashmore.sqs.extensions.xray.decorator.StaticDecoratorSegmentNamingStrategy; -import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; diff --git a/extensions/aws-xray-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/xray/decorator/SqsListenerXrayConfigurationTest.java b/extensions/aws-xray-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/xray/decorator/SqsListenerXrayConfigurationTest.java index b86cba8b..7896f47a 100644 --- a/extensions/aws-xray-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/xray/decorator/SqsListenerXrayConfigurationTest.java +++ b/extensions/aws-xray-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/xray/decorator/SqsListenerXrayConfigurationTest.java @@ -12,10 +12,10 @@ import com.amazonaws.xray.entities.Segment; import com.amazonaws.xray.entities.Subsegment; import com.jashmore.sqs.QueueProperties; +import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.decorator.MessageProcessingContext; import com.jashmore.sqs.extensions.xray.client.XrayWrappedSqsAsyncClient; import com.jashmore.sqs.extensions.xray.spring.SqsListenerXrayConfiguration; -import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; import java.util.HashMap; import org.junit.jupiter.api.AfterEach; diff --git a/extensions/brave-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/brave/BraveMessageProcessingDecoratorAsynchronousIntegrationTest.java b/extensions/brave-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/brave/BraveMessageProcessingDecoratorAsynchronousIntegrationTest.java index 0828c6c2..b25fb5e8 100644 --- a/extensions/brave-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/brave/BraveMessageProcessingDecoratorAsynchronousIntegrationTest.java +++ b/extensions/brave-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/brave/BraveMessageProcessingDecoratorAsynchronousIntegrationTest.java @@ -8,13 +8,13 @@ import brave.propagation.CurrentTraceContext; import brave.propagation.ThreadLocalCurrentTraceContext; import brave.test.TestSpanHandler; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.brave.propogation.SendMessageRemoteSetter; import com.jashmore.sqs.decorator.MessageProcessingContext; import com.jashmore.sqs.decorator.MessageProcessingDecorator; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.extensions.brave.spring.BraveMessageProcessingDecoratorConfiguration; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.HashMap; import java.util.Map; diff --git a/extensions/brave-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/brave/BraveMessageProcessingDecoratorIntegrationTest.java b/extensions/brave-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/brave/BraveMessageProcessingDecoratorIntegrationTest.java index 49742fb8..b2d7dca4 100644 --- a/extensions/brave-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/brave/BraveMessageProcessingDecoratorIntegrationTest.java +++ b/extensions/brave-extension/spring-boot/src/test/java/com/jashmore/sqs/extensions/brave/BraveMessageProcessingDecoratorIntegrationTest.java @@ -6,13 +6,13 @@ import brave.Tracing; import brave.handler.MutableSpan; import brave.test.TestSpanHandler; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.brave.SendMessageTracingExecutionInterceptor; import com.jashmore.sqs.decorator.MessageProcessingContext; import com.jashmore.sqs.decorator.MessageProcessingDecorator; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.extensions.brave.spring.BraveMessageProcessingDecoratorConfiguration; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; diff --git a/extensions/spring-cloud-schema-registry-extension/avro-spring-cloud-schema-registry-extension/src/test/java/it/com/jashmore/sqs/extensions/registry/avro/AvroSpringCloudSchemaRegistryIntegrationTest.java b/extensions/spring-cloud-schema-registry-extension/avro-spring-cloud-schema-registry-extension/src/test/java/it/com/jashmore/sqs/extensions/registry/avro/AvroSpringCloudSchemaRegistryIntegrationTest.java index fca42c20..e6f3acc0 100644 --- a/extensions/spring-cloud-schema-registry-extension/avro-spring-cloud-schema-registry-extension/src/test/java/it/com/jashmore/sqs/extensions/registry/avro/AvroSpringCloudSchemaRegistryIntegrationTest.java +++ b/extensions/spring-cloud-schema-registry-extension/avro-spring-cloud-schema-registry-extension/src/test/java/it/com/jashmore/sqs/extensions/registry/avro/AvroSpringCloudSchemaRegistryIntegrationTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.extensions.registry.InMemorySchemaRegistryClient; import com.jashmore.sqs.extensions.registry.SpringCloudSchemaRegistryPayload; @@ -10,7 +11,6 @@ import com.jashmore.sqs.extensions.registry.model.Author; import com.jashmore.sqs.extensions.registry.model.Book; import com.jashmore.sqs.registry.AvroSchemaRegistrySqsAsyncClient; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageArgumentResolutionSpringIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageArgumentResolutionSpringIntegrationTest.java index 54a922a8..60f5d8ae 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageArgumentResolutionSpringIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageArgumentResolutionSpringIntegrationTest.java @@ -2,9 +2,9 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageAttributeSpringIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageAttributeSpringIntegrationTest.java index ede489b5..9790d209 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageAttributeSpringIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageAttributeSpringIntegrationTest.java @@ -2,11 +2,11 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.argument.attribute.MessageAttribute; import com.jashmore.sqs.argument.attribute.MessageAttributeDataTypes; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.Collections; import java.util.concurrent.CountDownLatch; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageSystemAttributeSpringIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageSystemAttributeSpringIntegrationTest.java index 531c9d2b..4adda364 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageSystemAttributeSpringIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/argument/MessageSystemAttributeSpringIntegrationTest.java @@ -4,11 +4,11 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.argument.attribute.MessageAttributeDataTypes; import com.jashmore.sqs.argument.attribute.MessageSystemAttribute; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.time.OffsetDateTime; import java.util.Collections; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/client/MultipleSqsAsyncClientIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/client/MultipleSqsAsyncClientIntegrationTest.java index f918b6e1..c07711fb 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/client/MultipleSqsAsyncClientIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/client/MultipleSqsAsyncClientIntegrationTest.java @@ -1,8 +1,8 @@ package com.jashmore.sqs.client; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.HashMap; import java.util.Map; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerEnvironmentIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerEnvironmentIntegrationTest.java index e04100a6..23bf38c0 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerEnvironmentIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerEnvironmentIntegrationTest.java @@ -2,10 +2,10 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.TimeUnit; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerIntegrationTest.java index a62f7c7f..d1fb5c29 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerIntegrationTest.java @@ -2,10 +2,10 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerMessageDecoratorIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerMessageDecoratorIntegrationTest.java index cb54ed18..0925b438 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerMessageDecoratorIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerMessageDecoratorIntegrationTest.java @@ -2,11 +2,11 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.decorator.MessageProcessingContext; import com.jashmore.sqs.decorator.MessageProcessingDecorator; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerVisibilityIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerVisibilityIntegrationTest.java index 7ca866c9..835be387 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerVisibilityIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/container/basic/QueueListenerVisibilityIntegrationTest.java @@ -2,10 +2,10 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.ExpectedTestException; import com.jashmore.sqs.util.LocalSqsAsyncClient; import com.jashmore.sqs.util.SqsQueuesConfig; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactoryIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactoryIntegrationTest.java index 1058594e..5d18c748 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactoryIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/decorator/visibilityextender/AutoVisibilityExtenderMessageProcessingDecoratorFactoryIntegrationTest.java @@ -2,11 +2,11 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; +import com.jashmore.sqs.annotations.decorator.visibilityextender.AutoVisibilityExtender; import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; -import com.jashmore.sqs.annotations.decorator.visibilityextender.AutoVisibilityExtender; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.time.Duration; import java.util.concurrent.CountDownLatch; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/proxy/ProxyBeanQueueListenerResolutionIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/proxy/ProxyBeanQueueListenerResolutionIntegrationTest.java index ef33af35..d1086da9 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/proxy/ProxyBeanQueueListenerResolutionIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/proxy/ProxyBeanQueueListenerResolutionIntegrationTest.java @@ -2,10 +2,10 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; diff --git a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/service/SpringMessageListenerContainerCoordinatorIntegrationTest.java b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/service/SpringMessageListenerContainerCoordinatorIntegrationTest.java index 1e950f95..427fd527 100644 --- a/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/service/SpringMessageListenerContainerCoordinatorIntegrationTest.java +++ b/spring/spring-core/src/integrationTest/java/com/jashmore/sqs/service/SpringMessageListenerContainerCoordinatorIntegrationTest.java @@ -2,11 +2,11 @@ import static org.assertj.core.api.Assertions.assertThat; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.argument.payload.Payload; +import com.jashmore.sqs.container.MessageListenerContainerCoordinator; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.container.MessageListenerContainerCoordinator; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; diff --git a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/config/QueueListenerConfiguration.java b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/config/QueueListenerConfiguration.java index 0b3f2ae5..7a6cfde8 100644 --- a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/config/QueueListenerConfiguration.java +++ b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/config/QueueListenerConfiguration.java @@ -8,7 +8,6 @@ import com.jashmore.sqs.annotations.core.prefetch.PrefetchingAnnotationMessageListenerContainerFactory; import com.jashmore.sqs.annotations.core.prefetch.PrefetchingQueueListenerParser; import com.jashmore.sqs.annotations.decorator.visibilityextender.AutoVisibilityExtenderMessageProcessingDecoratorFactory; -import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.argument.ArgumentResolver; import com.jashmore.sqs.argument.ArgumentResolverService; import com.jashmore.sqs.argument.DelegatingArgumentResolverService; @@ -18,24 +17,24 @@ import com.jashmore.sqs.argument.messageid.MessageIdArgumentResolver; import com.jashmore.sqs.argument.payload.PayloadArgumentResolver; import com.jashmore.sqs.argument.payload.mapper.JacksonPayloadMapper; -import com.jashmore.sqs.container.MessageListenerContainer; -import com.jashmore.sqs.decorator.MessageProcessingDecorator; +import com.jashmore.sqs.client.DefaultPlaceholderQueueResolver; import com.jashmore.sqs.client.DefaultSqsAsyncClientProvider; +import com.jashmore.sqs.client.QueueResolver; import com.jashmore.sqs.client.SqsAsyncClientProvider; -import com.jashmore.sqs.spring.container.SpringMessageListenerContainerCoordinator; -import com.jashmore.sqs.spring.container.SpringMessageListenerContainerCoordinatorProperties; +import com.jashmore.sqs.container.MessageListenerContainer; import com.jashmore.sqs.container.MessageListenerContainerCoordinator; import com.jashmore.sqs.container.MessageListenerContainerFactory; -import com.jashmore.sqs.spring.container.StaticSpringMessageListenerContainerCoordinatorProperties; +import com.jashmore.sqs.decorator.MessageProcessingDecorator; import com.jashmore.sqs.decorator.MessageProcessingDecoratorFactory; -import com.jashmore.sqs.spring.jackson.SqsListenerObjectMapperSupplier; +import com.jashmore.sqs.placeholder.PlaceholderResolver; import com.jashmore.sqs.processor.DecoratingMessageProcessorFactory; -import com.jashmore.sqs.client.DefaultPlaceholderQueueResolver; -import com.jashmore.sqs.client.QueueResolver; +import com.jashmore.sqs.spring.container.SpringMessageListenerContainerCoordinator; +import com.jashmore.sqs.spring.container.SpringMessageListenerContainerCoordinatorProperties; +import com.jashmore.sqs.spring.container.StaticSpringMessageListenerContainerCoordinatorProperties; +import com.jashmore.sqs.spring.jackson.SqsListenerObjectMapperSupplier; +import com.jashmore.sqs.spring.placeholder.SpringPlaceholderResolver; import java.util.Collections; import java.util.List; - -import com.jashmore.sqs.spring.placeholder.SpringPlaceholderResolver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; diff --git a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/SpringMessageListenerContainerCoordinator.java b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/SpringMessageListenerContainerCoordinator.java index 628441e8..876e6bec 100644 --- a/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/SpringMessageListenerContainerCoordinator.java +++ b/spring/spring-core/src/main/java/com/jashmore/sqs/spring/container/SpringMessageListenerContainerCoordinator.java @@ -4,6 +4,8 @@ import com.jashmore.documentation.annotations.Nonnull; import com.jashmore.documentation.annotations.ThreadSafe; import com.jashmore.sqs.container.MessageListenerContainer; +import com.jashmore.sqs.container.MessageListenerContainerCoordinator; +import com.jashmore.sqs.container.MessageListenerContainerFactory; import java.lang.reflect.Method; import java.util.Collections; import java.util.HashMap; @@ -17,9 +19,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.function.Supplier; - -import com.jashmore.sqs.container.MessageListenerContainerCoordinator; -import com.jashmore.sqs.container.MessageListenerContainerFactory; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; @@ -217,17 +216,18 @@ private static Map calculateMessageListenerCon final Object bean = applicationContext.getBean(beanName); for (final Method method : bean.getClass().getMethods()) { for (final MessageListenerContainerFactory annotationProcessor : messageListenerContainerFactories) { - annotationProcessor.buildContainer(bean, method) - .ifPresent(messageListenerContainer -> { - if (messageContainers.containsKey(messageListenerContainer.getIdentifier())) { - throw new IllegalStateException( - "Created two MessageListenerContainers with the same identifier: " + - messageListenerContainer.getIdentifier() - ); - } - log.debug("Created MessageListenerContainer with id: {}", messageListenerContainer.getIdentifier()); - messageContainers.put(messageListenerContainer.getIdentifier(), messageListenerContainer); - }); + annotationProcessor + .buildContainer(bean, method) + .ifPresent(messageListenerContainer -> { + if (messageContainers.containsKey(messageListenerContainer.getIdentifier())) { + throw new IllegalStateException( + "Created two MessageListenerContainers with the same identifier: " + + messageListenerContainer.getIdentifier() + ); + } + log.debug("Created MessageListenerContainer with id: {}", messageListenerContainer.getIdentifier()); + messageContainers.put(messageListenerContainer.getIdentifier(), messageListenerContainer); + }); } } } diff --git a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/config/QueueListenerConfigurationTest.java b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/config/QueueListenerConfigurationTest.java index 685943f5..c548de6c 100644 --- a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/config/QueueListenerConfigurationTest.java +++ b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/config/QueueListenerConfigurationTest.java @@ -10,6 +10,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.jashmore.sqs.QueueProperties; import com.jashmore.sqs.annotations.core.basic.BasicAnnotationMessageListenerContainerFactory; +import com.jashmore.sqs.annotations.core.basic.QueueListener; +import com.jashmore.sqs.annotations.core.basic.QueueListenerParser; import com.jashmore.sqs.annotations.core.fifo.FifoAnnotationMessageListenerContainerFactory; import com.jashmore.sqs.annotations.core.fifo.FifoQueueListener; import com.jashmore.sqs.annotations.core.fifo.FifoQueueListenerParser; @@ -24,29 +26,26 @@ import com.jashmore.sqs.argument.message.MessageArgumentResolver; import com.jashmore.sqs.argument.messageid.MessageIdArgumentResolver; import com.jashmore.sqs.argument.payload.PayloadArgumentResolver; +import com.jashmore.sqs.client.SqsAsyncClientProvider; +import com.jashmore.sqs.container.MessageListenerContainerCoordinator; +import com.jashmore.sqs.container.MessageListenerContainerFactory; import com.jashmore.sqs.container.batching.BatchingMessageListenerContainerProperties; import com.jashmore.sqs.container.fifo.FifoMessageListenerContainerProperties; import com.jashmore.sqs.container.prefetching.PrefetchingMessageListenerContainerProperties; import com.jashmore.sqs.decorator.MessageProcessingDecorator; +import com.jashmore.sqs.decorator.MessageProcessingDecoratorFactory; +import com.jashmore.sqs.processor.DecoratingMessageProcessorFactory; import com.jashmore.sqs.processor.MessageProcessor; -import com.jashmore.sqs.client.SqsAsyncClientProvider; import com.jashmore.sqs.spring.container.SpringMessageListenerContainerCoordinator; import com.jashmore.sqs.spring.container.SpringMessageListenerContainerCoordinatorProperties; -import com.jashmore.sqs.container.MessageListenerContainerCoordinator; -import com.jashmore.sqs.container.MessageListenerContainerFactory; -import com.jashmore.sqs.annotations.core.basic.QueueListener; -import com.jashmore.sqs.annotations.core.basic.QueueListenerParser; -import com.jashmore.sqs.decorator.MessageProcessingDecoratorFactory; import com.jashmore.sqs.spring.jackson.SqsListenerObjectMapperSupplier; -import com.jashmore.sqs.processor.DecoratingMessageProcessorFactory; +import com.jashmore.sqs.spring.placeholder.SpringPlaceholderResolver; import java.lang.reflect.Field; import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; - -import com.jashmore.sqs.spring.placeholder.SpringPlaceholderResolver; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; diff --git a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/container/SpringMessageListenerContainerCoordinatorTest.java b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/container/SpringMessageListenerContainerCoordinatorTest.java index 6e264b74..7a6faf5e 100644 --- a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/container/SpringMessageListenerContainerCoordinatorTest.java +++ b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/container/SpringMessageListenerContainerCoordinatorTest.java @@ -14,11 +14,10 @@ import static org.mockito.Mockito.when; import com.jashmore.sqs.container.MessageListenerContainer; +import com.jashmore.sqs.container.MessageListenerContainerFactory; import java.lang.reflect.Method; import java.util.Collections; import java.util.Optional; - -import com.jashmore.sqs.container.MessageListenerContainerFactory; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/placeholder/SpringPlaceholderResolverTest.java b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/placeholder/SpringPlaceholderResolverTest.java index e51fba21..a738d5ad 100644 --- a/spring/spring-core/src/test/java/com/jashmore/sqs/spring/placeholder/SpringPlaceholderResolverTest.java +++ b/spring/spring-core/src/test/java/com/jashmore/sqs/spring/placeholder/SpringPlaceholderResolverTest.java @@ -1,16 +1,18 @@ package com.jashmore.sqs.spring.placeholder; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.mock.env.MockEnvironment; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; - class SpringPlaceholderResolverTest { + MockEnvironment environment; SpringPlaceholderResolver resolver; + @BeforeEach void setUp() { environment = new MockEnvironment(); @@ -27,4 +29,4 @@ void willResolvePlaceholdersFromMapping() { void willThrowExceptionsIfNoMappingFound() { assertThrows(IllegalArgumentException.class, () -> resolver.resolvePlaceholders("something ${key}")); } -} \ No newline at end of file +} diff --git a/spring/spring-starter/src/test/java/com/jashmore/sqs/SpringObjectMapperIntegrationTest.java b/spring/spring-starter/src/test/java/com/jashmore/sqs/SpringObjectMapperIntegrationTest.java index e187c605..d5d2c614 100644 --- a/spring/spring-starter/src/test/java/com/jashmore/sqs/SpringObjectMapperIntegrationTest.java +++ b/spring/spring-starter/src/test/java/com/jashmore/sqs/SpringObjectMapperIntegrationTest.java @@ -5,10 +5,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.argument.payload.Payload; import com.jashmore.sqs.elasticmq.ElasticMqSqsAsyncClient; import com.jashmore.sqs.spring.config.QueueListenerConfiguration; -import com.jashmore.sqs.annotations.core.basic.QueueListener; import com.jashmore.sqs.util.LocalSqsAsyncClient; import java.util.HashMap; import java.util.Map; diff --git a/util/common-utils/src/main/java/com/jashmore/sqs/util/identifier/IdentifierUtils.java b/util/common-utils/src/main/java/com/jashmore/sqs/util/identifier/IdentifierUtils.java index 56cd01fc..abbf2c5f 100644 --- a/util/common-utils/src/main/java/com/jashmore/sqs/util/identifier/IdentifierUtils.java +++ b/util/common-utils/src/main/java/com/jashmore/sqs/util/identifier/IdentifierUtils.java @@ -1,13 +1,13 @@ package com.jashmore.sqs.util.identifier; -import java.lang.reflect.Method; - import com.jashmore.documentation.annotations.Nullable; import com.jashmore.sqs.util.string.StringUtils; +import java.lang.reflect.Method; import lombok.experimental.UtilityClass; @UtilityClass public class IdentifierUtils { + /** * Builds an identifier from a provided identifier if it is not empty, otherwise build an identifier from the class and method. * diff --git a/util/common-utils/src/test/java/com/jashmore/sqs/util/identifier/IdentifierUtilsTest.java b/util/common-utils/src/test/java/com/jashmore/sqs/util/identifier/IdentifierUtilsTest.java index 6619d1a2..17f6b25c 100644 --- a/util/common-utils/src/test/java/com/jashmore/sqs/util/identifier/IdentifierUtilsTest.java +++ b/util/common-utils/src/test/java/com/jashmore/sqs/util/identifier/IdentifierUtilsTest.java @@ -3,7 +3,6 @@ import static org.assertj.core.api.Assertions.assertThat; import java.lang.reflect.Method; - import org.junit.jupiter.api.Test; class IdentifierUtilsTest { diff --git a/util/common-utils/src/test/java/com/jashmore/sqs/util/string/StringUtilsTest.java b/util/common-utils/src/test/java/com/jashmore/sqs/util/string/StringUtilsTest.java index 8e9471e0..320ae2c6 100644 --- a/util/common-utils/src/test/java/com/jashmore/sqs/util/string/StringUtilsTest.java +++ b/util/common-utils/src/test/java/com/jashmore/sqs/util/string/StringUtilsTest.java @@ -43,6 +43,7 @@ void nonUppercaseStartWillCreateMethodCorrectly() { @Nested class HasText { + @Test void willReturnFalseWhenNull() { assertThat(StringUtils.hasText(null)).isFalse();