use of io.micronaut.jms.annotations.JMSConnectionFactory in project micronaut-jms by micronaut-projects.
the class JMSConnectionFactoryBeanProcessor method process.
@Override
public void process(BeanDefinition<?> beanDefinition, BeanContext context) {
final Object candidate = context.getBean(beanDefinition);
Assert.isTrue(candidate instanceof ConnectionFactory, () -> "@JMSConnectionFactory can only be applied to a bean of type javax.jms.ConnectionFactory. " + "Provided class was " + candidate.getClass().getName());
final ConnectionFactory connectionFactory = (ConnectionFactory) candidate;
final String name = beanDefinition.stringValue(JMSConnectionFactory.class).orElseThrow(() -> new ConfigurationException("@JMSConnectionFactory must specify a name for the bean."));
context.registerSingleton(JMSConnectionPool.class, new JMSConnectionPool(connectionFactory, properties.getInitialPoolSize(), properties.getMaxPoolSize()), Qualifiers.byName(name));
logger.debug("created JMSConnectionPool bean '{}' for ConnectionFactory {}", name, connectionFactory.getClass().getName());
}
Aggregations