@Override protected MappingInformation getMappingForMethod(Method method, Class<?> handlerType) { SqsListener sqsListenerAnnotation = AnnotationUtils.findAnnotation(method, SqsListener.class); if (sqsListenerAnnotation != null && sqsListenerAnnotation.value().length > 0) { if (sqsListenerAnnotation.deletionPolicy() == SqsMessageDeletionPolicy.NEVER && hasNoAcknowledgmentParameter(method.getParameterTypes())) { this.logger.warn("Listener method '" + method.getName() + "' in type '" + method.getDeclaringClass().getName() + "' has deletion policy 'NEVER' but does not have a parameter of type Acknowledgment."); } return new MappingInformation(resolveDestinationNames(sqsListenerAnnotation.value()), sqsListenerAnnotation.deletionPolicy()); } MessageMapping messageMappingAnnotation = AnnotationUtils.findAnnotation(method, MessageMapping.class); if (messageMappingAnnotation != null && messageMappingAnnotation.value().length > 0) { return new MappingInformation(resolveDestinationNames(messageMappingAnnotation.value()), SqsMessageDeletionPolicy.ALWAYS); } return null; }
@Override protected MappingInformation getMatchingMapping(MappingInformation mapping, Message<?> message) { if (mapping.getLogicalResourceIds().contains(getDestination(message))) { return mapping; } else { return null; } }
protected void initialize() { synchronized (this.getLifecycleMonitor()) { if (this.destinationResolver == null) { if (this.resourceIdResolver == null) { this.destinationResolver = new CachingDestinationResolverProxy<>(new DynamicQueueUrlDestinationResolver(this.amazonSqs)); } else { this.destinationResolver = new CachingDestinationResolverProxy<>(new DynamicQueueUrlDestinationResolver(this.amazonSqs, this.resourceIdResolver)); } } for (QueueMessageHandler.MappingInformation mappingInformation : this.messageHandler.getHandlerMethods().keySet()) { for (String queue : mappingInformation.getLogicalResourceIds()) { QueueAttributes queueAttributes = queueAttributes(queue, mappingInformation.getDeletionPolicy()); if (queueAttributes != null) { this.registeredQueues.put(queue, queueAttributes); } } } this.active = true; this.getLifecycleMonitor().notifyAll(); } }
protected void initialize() { synchronized (this.getLifecycleMonitor()) { if (this.destinationResolver == null) { if (this.resourceIdResolver == null) { this.destinationResolver = new CachingDestinationResolverProxy<>(new DynamicQueueUrlDestinationResolver(this.amazonSqs)); } else { this.destinationResolver = new CachingDestinationResolverProxy<>(new DynamicQueueUrlDestinationResolver(this.amazonSqs, this.resourceIdResolver)); } } for (QueueMessageHandler.MappingInformation mappingInformation : this.messageHandler.getHandlerMethods().keySet()) { for (String queue : mappingInformation.getLogicalResourceIds()) { QueueAttributes queueAttributes = queueAttributes(queue, mappingInformation.getDeletionPolicy()); if (queueAttributes != null) { this.registeredQueues.put(queue, queueAttributes); } } } this.active = true; this.getLifecycleMonitor().notifyAll(); } }
@Override protected MappingInformation getMappingForMethod(Method method, Class<?> handlerType) { SqsListener sqsListenerAnnotation = AnnotationUtils.findAnnotation(method, SqsListener.class); if (sqsListenerAnnotation != null && sqsListenerAnnotation.value().length > 0) { if (sqsListenerAnnotation.deletionPolicy() == SqsMessageDeletionPolicy.NEVER && hasNoAcknowledgmentParameter(method.getParameterTypes())) { this.logger.warn("Listener method '" + method.getName() + "' in type '" + method.getDeclaringClass().getName() + "' has deletion policy 'NEVER' but does not have a parameter of type Acknowledgment."); } return new MappingInformation(resolveDestinationNames(sqsListenerAnnotation.value()), sqsListenerAnnotation.deletionPolicy()); } MessageMapping messageMappingAnnotation = AnnotationUtils.findAnnotation(method, MessageMapping.class); if (messageMappingAnnotation != null && messageMappingAnnotation.value().length > 0) { return new MappingInformation(resolveDestinationNames(messageMappingAnnotation.value()), SqsMessageDeletionPolicy.ALWAYS); } return null; }
@Override protected Set<String> getDirectLookupDestinations(MappingInformation mapping) { return mapping.getLogicalResourceIds(); }
@Override public Map<MappingInformation, HandlerMethod> getHandlerMethods() { Set<String> queues = new HashSet<>(Arrays.asList(SqsMessageDrivenChannelAdapter.this.queues)); MappingInformation mappingInformation = new MappingInformation(queues, SqsMessageDrivenChannelAdapter.this.messageDeletionPolicy); return Collections.singletonMap(mappingInformation, null); }
@Override public Map<MappingInformation, HandlerMethod> getHandlerMethods() { Set<String> queues = new HashSet<>(Arrays.asList(SqsMessageDrivenChannelAdapter.this.queues)); MappingInformation mappingInformation = new MappingInformation(queues, SqsMessageDrivenChannelAdapter.this.messageDeletionPolicy); return Collections.singletonMap(mappingInformation, null); }
@Override protected Set<String> getDirectLookupDestinations(MappingInformation mapping) { return mapping.getLogicalResourceIds(); }
@Override protected MappingInformation getMatchingMapping(MappingInformation mapping, Message<?> message) { if (mapping.getLogicalResourceIds().contains(getDestination(message))) { return mapping; } else { return null; } }