use of io.micronaut.jms.bind.JMSArgumentBinderRegistry in project micronaut-jms by micronaut-projects.
the class AbstractJMSListenerMethodProcessor method generateAndBindListener.
@SuppressWarnings("unchecked")
private MessageListener generateAndBindListener(Object bean, ExecutableMethod<?, ?> method, ExecutorService executor, boolean acknowledge) {
return message -> executor.submit(() -> {
try {
DefaultExecutableBinder<Message> binder = new DefaultExecutableBinder<>();
BoundExecutable boundExecutable = binder.bind(method, jmsArgumentBinderRegistry, message);
boundExecutable.invoke(bean);
if (acknowledge) {
try {
message.acknowledge();
} catch (JMSException e) {
logger.error("Failed to acknowledge receipt of message with the broker. " + "This message may be falsely retried.", e);
throw new MessageAcknowledgementException(e.getMessage(), e);
}
}
} catch (Exception e) {
logger.error("Failed to process a message: " + message + " " + e.getMessage(), e);
}
});
}
Aggregations