use of javax.jms.Session.CLIENT_ACKNOWLEDGE in project micronaut-jms by micronaut-projects.
the class AbstractJMSListenerMethodProcessor method registerListener.
private void registerListener(ExecutableMethod<?, ?> method, String connectionFactoryName, BeanDefinition<?> beanDefinition, AnnotationValue<T> destinationAnnotation, JMSDestinationType type) {
validateArguments(method);
final Class<?> targetClass = Stream.of(method.getArguments()).filter(arg -> arg.isDeclaredAnnotationPresent(MessageBody.class) || arg.isDeclaredAnnotationPresent(io.micronaut.jms.annotations.Message.class)).findAny().map(Argument::getClass).get();
final String destination = destinationAnnotation.getRequiredValue(String.class);
final int acknowledgeMode = destinationAnnotation.getRequiredValue("acknowledgeMode", Integer.class);
final boolean transacted = destinationAnnotation.getRequiredValue("transacted", Boolean.class);
final JMSListenerContainerFactory listenerFactory = beanContext.findBean(JMSListenerContainerFactory.class).orElseThrow(() -> new IllegalStateException("No JMSListenerFactory configured"));
final JMSConnectionPool connectionPool = beanContext.getBean(JMSConnectionPool.class, Qualifiers.byName(connectionFactoryName));
final Object bean = beanContext.findBean(beanDefinition.getBeanType()).get();
final ExecutorService executor = getExecutorService(destinationAnnotation);
MessageListener listener = generateAndBindListener(bean, method, executor, CLIENT_ACKNOWLEDGE == acknowledgeMode);
listenerFactory.registerListener(connectionPool, destination, listener, targetClass, transacted, acknowledgeMode, type);
}
Aggregations