org.springframework.jms.config.JmsListenerContainerFactory Java Examples
The following examples show how to use
org.springframework.jms.config.JmsListenerContainerFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JmsChannelModelProcessor.java From flowable-engine with Apache License 2.0 | 6 votes |
protected JmsListenerContainerFactory<?> resolveContainerFactory(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> containerFactory) { if (containerFactory != null) { return containerFactory; } else if (this.containerFactory != null) { return this.containerFactory; } else if (containerFactoryBeanName != null) { Assert.state(beanFactory != null, "BeanFactory must be set to obtain container factory by bean name"); // Consider changing this if live change of the factory is required... this.containerFactory = beanFactory.getBean(containerFactoryBeanName, JmsListenerContainerFactory.class); return this.containerFactory; } else { throw new IllegalStateException("Could not resolve the " + JmsListenerContainerFactory.class.getSimpleName() + " to use for [" + endpoint + "] no factory was given and no default is set."); } }
Example #2
Source File: JMSConfig.java From ElementVueSpringbootCodeTemplate with Apache License 2.0 | 6 votes |
@Bean public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); // This provides all boot's default to this factory, including the message // converter configurer.configure(factory, connectionFactory); // You could still override some of Boot's default if necessary. // 设置连接数 factory.setConcurrency("3-10"); // 重连间隔时间 factory.setRecoveryInterval(1000L); return factory; }
Example #3
Source File: JmsConfig.java From myth with Apache License 2.0 | 5 votes |
/** * Jms listener container queue jms listener container factory. * * @param activeMQConnectionFactory the active mq connection factory * @return the jms listener container factory */ @Bean(name = "queueListenerContainerFactory") @ConditionalOnProperty(prefix = "spring.activemq", name = "broker-url") public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) { DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); bean.setConnectionFactory(activeMQConnectionFactory); bean.setPubSubDomain(Boolean.FALSE); return bean; }
Example #4
Source File: JMSApplicationConfig.java From POC with Apache License 2.0 | 5 votes |
@Bean public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { final DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); // This provides all boot's default to this factory, including the message // converter configurer.configure(factory, connectionFactory); // You could still override some of Boot's default if necessary. return factory; }
Example #5
Source File: JmsChannelModelProcessor.java From flowable-engine with Apache License 2.0 | 5 votes |
/** * Register a new {@link JmsListenerEndpoint} alongside the * {@link JmsListenerContainerFactory} to use to create the underlying container. * <p>The {@code factory} may be {@code null} if the default factory has to be * used for that endpoint. */ protected void registerEndpoint(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory) { Assert.notNull(endpoint, "Endpoint must not be null"); Assert.hasText(endpoint.getId(), "Endpoint id must be set"); Assert.state(this.endpointRegistry != null, "No JmsListenerEndpointRegistry set"); endpointRegistry.registerListenerContainer(endpoint, resolveContainerFactory(endpoint, factory), true); }
Example #6
Source File: JmsListenerAnnotationBeanPostProcessor.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Process the given {@link JmsListener} annotation on the given method, * registering a corresponding endpoint for the given bean instance. * @param jmsListener the annotation to process * @param mostSpecificMethod the annotated method * @param bean the instance to invoke the method on * @see #createMethodJmsListenerEndpoint() * @see JmsListenerEndpointRegistrar#registerEndpoint */ protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) { Method invocableMethod = MethodIntrospector.selectInvocableMethod(mostSpecificMethod, bean.getClass()); MethodJmsListenerEndpoint endpoint = createMethodJmsListenerEndpoint(); endpoint.setBean(bean); endpoint.setMethod(invocableMethod); endpoint.setMostSpecificMethod(mostSpecificMethod); endpoint.setMessageHandlerMethodFactory(this.messageHandlerMethodFactory); endpoint.setBeanFactory(this.beanFactory); endpoint.setId(getEndpointId(jmsListener)); endpoint.setDestination(resolve(jmsListener.destination())); if (StringUtils.hasText(jmsListener.selector())) { endpoint.setSelector(resolve(jmsListener.selector())); } if (StringUtils.hasText(jmsListener.subscription())) { endpoint.setSubscription(resolve(jmsListener.subscription())); } if (StringUtils.hasText(jmsListener.concurrency())) { endpoint.setConcurrency(resolve(jmsListener.concurrency())); } JmsListenerContainerFactory<?> factory = null; String containerFactoryBeanName = resolve(jmsListener.containerFactory()); if (StringUtils.hasText(containerFactoryBeanName)) { Assert.state(this.beanFactory != null, "BeanFactory must be set to obtain container factory by bean name"); try { factory = this.beanFactory.getBean(containerFactoryBeanName, JmsListenerContainerFactory.class); } catch (NoSuchBeanDefinitionException ex) { throw new BeanInitializationException("Could not register JMS listener endpoint on [" + mostSpecificMethod + "], no " + JmsListenerContainerFactory.class.getSimpleName() + " with id '" + containerFactoryBeanName + "' was found in the application context", ex); } } this.registrar.registerEndpoint(endpoint, factory); }
Example #7
Source File: DittoAzureServiceBusExampleApplication.java From ditto-examples with Eclipse Public License 2.0 | 5 votes |
@Bean public JmsListenerContainerFactory<?> myFactory(final ConnectionFactory connectionFactory, final DefaultJmsListenerContainerFactoryConfigurer configurer) { final DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); // anonymous class factory.setErrorHandler(t -> LOG.error("An error has occurred in the transaction", t)); configurer.configure(factory, connectionFactory); factory.setSessionTransacted(false); return factory; }
Example #8
Source File: JmsArtemisStarterTest.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Bean public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); // This provides all boot's default to this factory, including the message converter configurer.configure(factory, connectionFactory); // You could still override some of Boot's default if necessary. return factory; }
Example #9
Source File: JmsTest.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Bean public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); // This provides all boot's default to this factory, including the message converter configurer.configure(factory, connectionFactory); // You could still override some of Boot's default if necessary. return factory; }
Example #10
Source File: SimpleJmsListenerContainerFactoryExample.java From amqp-10-jms-spring-boot with Apache License 2.0 | 5 votes |
@Bean(name = "QpidJMSContainerFactory") public JmsListenerContainerFactory<?> queue(ConnectionFactory cf) { SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory(); // Configure the factory using the provided JMS ConnectionFactory and apply // application defined configuration to the SimpleJmsListenerContainerFactory factory.setConnectionFactory(cf); factory.setSessionTransacted(false); return factory; }
Example #11
Source File: ActivemqConfiguration.java From jim-framework with Apache License 2.0 | 5 votes |
public JmsListenerContainerFactory<?> jmsListenerBContainerQueue() { DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); ActiveMQConnectionFactory connectionFactory=new ActiveMQConnectionFactory(Constans.CONSUMER_B_BROKER_URL); //connectionFactory bean.setConnectionFactory(connectionFactory); bean.setConcurrency("3-10"); return bean; }
Example #12
Source File: ActivemqConfiguration.java From jim-framework with Apache License 2.0 | 5 votes |
public JmsListenerContainerFactory<?> jmsListenerAContainerQueue() { DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); bean.setConnectionFactory(this.pooledConnectionFactory); bean.setConcurrency("3-10"); return bean; }
Example #13
Source File: JmsListenerAnnotationBeanPostProcessor.java From spring-analysis-note with MIT License | 5 votes |
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof AopInfrastructureBean || bean instanceof JmsListenerContainerFactory || bean instanceof JmsListenerEndpointRegistry) { // Ignore AOP infrastructure such as scoped proxies. return bean; } Class<?> targetClass = AopProxyUtils.ultimateTargetClass(bean); if (!this.nonAnnotatedClasses.contains(targetClass) && AnnotationUtils.isCandidateClass(targetClass, JmsListener.class)) { Map<Method, Set<JmsListener>> annotatedMethods = MethodIntrospector.selectMethods(targetClass, (MethodIntrospector.MetadataLookup<Set<JmsListener>>) method -> { Set<JmsListener> listenerMethods = AnnotatedElementUtils.getMergedRepeatableAnnotations( method, JmsListener.class, JmsListeners.class); return (!listenerMethods.isEmpty() ? listenerMethods : null); }); if (annotatedMethods.isEmpty()) { this.nonAnnotatedClasses.add(targetClass); if (logger.isTraceEnabled()) { logger.trace("No @JmsListener annotations found on bean type: " + targetClass); } } else { // Non-empty set of methods annotatedMethods.forEach((method, listeners) -> listeners.forEach(listener -> processJmsListener(listener, method, bean))); if (logger.isDebugEnabled()) { logger.debug(annotatedMethods.size() + " @JmsListener methods processed on bean '" + beanName + "': " + annotatedMethods); } } } return bean; }
Example #14
Source File: JmsConfig.java From myth with Apache License 2.0 | 5 votes |
/** * Jms listener container queue jms listener container factory. * * @param activeMQConnectionFactory the active mq connection factory * @return the jms listener container factory */ @Bean(name = "queueListenerContainerFactory") @ConditionalOnProperty(prefix = "spring.activemq", name = "broker-url") public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) { DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); bean.setConnectionFactory(activeMQConnectionFactory); bean.setPubSubDomain(Boolean.FALSE); return bean; }
Example #15
Source File: JmsConfig.java From myth with Apache License 2.0 | 5 votes |
/** * Jms listener container queue jms listener container factory. * * @param activeMQConnectionFactory the active mq connection factory * @return the jms listener container factory */ @Bean(name = "queueListenerContainerFactory") @ConditionalOnProperty(prefix = "spring.activemq", name = "broker-url") public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) { DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); bean.setConnectionFactory(activeMQConnectionFactory); bean.setPubSubDomain(Boolean.FALSE); return bean; }
Example #16
Source File: JmsConfig.java From myth with Apache License 2.0 | 5 votes |
@Bean(name = "queueListenerContainerFactory") @ConditionalOnProperty(prefix = "spring.activemq", name = "broker-url") public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) { DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); bean.setConnectionFactory(activeMQConnectionFactory); bean.setPubSubDomain(Boolean.FALSE); return bean; }
Example #17
Source File: JmsConfig.java From myth with Apache License 2.0 | 5 votes |
/** * Jms listener container queue jms listener container factory. * * @param activeMQConnectionFactory the active mq connection factory * @return the jms listener container factory */ @Bean(name = "queueListenerContainerFactory") @ConditionalOnProperty(prefix = "spring.activemq", name = "broker-url") public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) { DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); bean.setConnectionFactory(activeMQConnectionFactory); bean.setPubSubDomain(Boolean.FALSE); return bean; }
Example #18
Source File: JmsConfig.java From myth with Apache License 2.0 | 5 votes |
/** * Jms listener container queue jms listener container factory. * * @param activeMQConnectionFactory the active mq connection factory * @return the jms listener container factory */ @Bean(name = "queueListenerContainerFactory") @ConditionalOnProperty(prefix = "spring.activemq", name = "broker-url") public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) { DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory(); bean.setConnectionFactory(activeMQConnectionFactory); bean.setPubSubDomain(Boolean.FALSE); return bean; }
Example #19
Source File: SecKillEventConfig.java From seckill with Apache License 2.0 | 5 votes |
@Bean JmsListenerContainerFactory<?> containerFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); configurer.configure(factory, connectionFactory); return factory; }
Example #20
Source File: JMSSpringConfiguration.java From promregator with Apache License 2.0 | 5 votes |
@Bean public JmsListenerContainerFactory<?> jmsListenerContainerFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); configurer.configure(factory, connectionFactory); return factory; }
Example #21
Source File: ActiveMQConfig.java From hdw-dubbo with Apache License 2.0 | 5 votes |
@Bean(name = "queueJmsListenerContainerFactory") public JmsListenerContainerFactory<?> queueJmsListenerContainerFactory() { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); factory.setPubSubDomain(false); factory.setConnectionFactory(cachingConnectionFactory()); return factory; }
Example #22
Source File: ActiveMQConfig.java From hdw-dubbo with Apache License 2.0 | 5 votes |
@Bean(name = "topicJmsListenerContainerFactory") public JmsListenerContainerFactory<?> topicJmsListenerContainerFactory() { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); factory.setPubSubDomain(true); factory.setConnectionFactory(cachingConnectionFactory()); return factory; }
Example #23
Source File: JmsListenerAnnotationBeanPostProcessor.java From java-technology-stack with MIT License | 5 votes |
/** * Process the given {@link JmsListener} annotation on the given method, * registering a corresponding endpoint for the given bean instance. * @param jmsListener the annotation to process * @param mostSpecificMethod the annotated method * @param bean the instance to invoke the method on * @see #createMethodJmsListenerEndpoint() * @see JmsListenerEndpointRegistrar#registerEndpoint */ protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) { Method invocableMethod = AopUtils.selectInvocableMethod(mostSpecificMethod, bean.getClass()); MethodJmsListenerEndpoint endpoint = createMethodJmsListenerEndpoint(); endpoint.setBean(bean); endpoint.setMethod(invocableMethod); endpoint.setMostSpecificMethod(mostSpecificMethod); endpoint.setMessageHandlerMethodFactory(this.messageHandlerMethodFactory); endpoint.setEmbeddedValueResolver(this.embeddedValueResolver); endpoint.setBeanFactory(this.beanFactory); endpoint.setId(getEndpointId(jmsListener)); endpoint.setDestination(resolve(jmsListener.destination())); if (StringUtils.hasText(jmsListener.selector())) { endpoint.setSelector(resolve(jmsListener.selector())); } if (StringUtils.hasText(jmsListener.subscription())) { endpoint.setSubscription(resolve(jmsListener.subscription())); } if (StringUtils.hasText(jmsListener.concurrency())) { endpoint.setConcurrency(resolve(jmsListener.concurrency())); } JmsListenerContainerFactory<?> factory = null; String containerFactoryBeanName = resolve(jmsListener.containerFactory()); if (StringUtils.hasText(containerFactoryBeanName)) { Assert.state(this.beanFactory != null, "BeanFactory must be set to obtain container factory by bean name"); try { factory = this.beanFactory.getBean(containerFactoryBeanName, JmsListenerContainerFactory.class); } catch (NoSuchBeanDefinitionException ex) { throw new BeanInitializationException("Could not register JMS listener endpoint on [" + mostSpecificMethod + "], no " + JmsListenerContainerFactory.class.getSimpleName() + " with id '" + containerFactoryBeanName + "' was found in the application context", ex); } } this.registrar.registerEndpoint(endpoint, factory); }
Example #24
Source File: JmsListenerAnnotationBeanPostProcessor.java From java-technology-stack with MIT License | 5 votes |
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof AopInfrastructureBean || bean instanceof JmsListenerContainerFactory || bean instanceof JmsListenerEndpointRegistry) { // Ignore AOP infrastructure such as scoped proxies. return bean; } Class<?> targetClass = AopProxyUtils.ultimateTargetClass(bean); if (!this.nonAnnotatedClasses.contains(targetClass)) { Map<Method, Set<JmsListener>> annotatedMethods = MethodIntrospector.selectMethods(targetClass, (MethodIntrospector.MetadataLookup<Set<JmsListener>>) method -> { Set<JmsListener> listenerMethods = AnnotatedElementUtils.getMergedRepeatableAnnotations( method, JmsListener.class, JmsListeners.class); return (!listenerMethods.isEmpty() ? listenerMethods : null); }); if (annotatedMethods.isEmpty()) { this.nonAnnotatedClasses.add(targetClass); if (logger.isTraceEnabled()) { logger.trace("No @JmsListener annotations found on bean type: " + targetClass); } } else { // Non-empty set of methods annotatedMethods.forEach((method, listeners) -> listeners.forEach(listener -> processJmsListener(listener, method, bean))); if (logger.isDebugEnabled()) { logger.debug(annotatedMethods.size() + " @JmsListener methods processed on bean '" + beanName + "': " + annotatedMethods); } } } return bean; }
Example #25
Source File: JmsListenerAnnotationBeanPostProcessor.java From spring-analysis-note with MIT License | 5 votes |
/** * Process the given {@link JmsListener} annotation on the given method, * registering a corresponding endpoint for the given bean instance. * @param jmsListener the annotation to process * @param mostSpecificMethod the annotated method * @param bean the instance to invoke the method on * @see #createMethodJmsListenerEndpoint() * @see JmsListenerEndpointRegistrar#registerEndpoint */ protected void processJmsListener(JmsListener jmsListener, Method mostSpecificMethod, Object bean) { Method invocableMethod = AopUtils.selectInvocableMethod(mostSpecificMethod, bean.getClass()); MethodJmsListenerEndpoint endpoint = createMethodJmsListenerEndpoint(); endpoint.setBean(bean); endpoint.setMethod(invocableMethod); endpoint.setMostSpecificMethod(mostSpecificMethod); endpoint.setMessageHandlerMethodFactory(this.messageHandlerMethodFactory); endpoint.setEmbeddedValueResolver(this.embeddedValueResolver); endpoint.setBeanFactory(this.beanFactory); endpoint.setId(getEndpointId(jmsListener)); endpoint.setDestination(resolve(jmsListener.destination())); if (StringUtils.hasText(jmsListener.selector())) { endpoint.setSelector(resolve(jmsListener.selector())); } if (StringUtils.hasText(jmsListener.subscription())) { endpoint.setSubscription(resolve(jmsListener.subscription())); } if (StringUtils.hasText(jmsListener.concurrency())) { endpoint.setConcurrency(resolve(jmsListener.concurrency())); } JmsListenerContainerFactory<?> factory = null; String containerFactoryBeanName = resolve(jmsListener.containerFactory()); if (StringUtils.hasText(containerFactoryBeanName)) { Assert.state(this.beanFactory != null, "BeanFactory must be set to obtain container factory by bean name"); try { factory = this.beanFactory.getBean(containerFactoryBeanName, JmsListenerContainerFactory.class); } catch (NoSuchBeanDefinitionException ex) { throw new BeanInitializationException("Could not register JMS listener endpoint on [" + mostSpecificMethod + "], no " + JmsListenerContainerFactory.class.getSimpleName() + " with id '" + containerFactoryBeanName + "' was found in the application context", ex); } } this.registrar.registerEndpoint(endpoint, factory); }
Example #26
Source File: SpringJMSITest.java From java-specialagent with Apache License 2.0 | 4 votes |
@Bean public JmsListenerContainerFactory<?> myFactory(final DefaultJmsListenerContainerFactoryConfigurer configurer) { final DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); configurer.configure(factory, connectionFactory()); return factory; }
Example #27
Source File: JmsMessageBrokerConfiguration.java From piper with Apache License 2.0 | 4 votes |
@Bean public JmsListenerContainerFactory<?> jmsListenerContainerFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); configurer.configure(factory, connectionFactory); return factory; }
Example #28
Source File: JmsChannelModelProcessor.java From flowable-engine with Apache License 2.0 | 4 votes |
public JmsListenerContainerFactory<?> getContainerFactory() { return containerFactory; }
Example #29
Source File: JmsChannelModelProcessor.java From flowable-engine with Apache License 2.0 | 4 votes |
public void setContainerFactory(JmsListenerContainerFactory<?> containerFactory) { this.containerFactory = containerFactory; }