Java Code Examples for org.springframework.jms.config.MethodJmsListenerEndpoint

Following code examples demonstrate how to use org.springframework.jms.config.MethodJmsListenerEndpoint from spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.jms.config.MethodJmsListenerEndpoint and various code implementation of this class.
Example 1
Project : spring-framework Source File : CircuitBreakerAwareJmsListenerContainerFactory.java View Source Code on GitHub

    public DefaultMessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint) {
        DefaultMessageListenerContainer listenerContainer = super.createListenerContainer(endpoint);

        if (endpoint instanceof MethodJmsListenerEndpoint && listenerContainer instanceof CircuitBreakerAwareMessageListenerContainer) {
            MethodJmsListenerEndpoint mle = (MethodJmsListenerEndpoint) endpoint;
            CircuitBreakerAwareJmsListener declaredAnnotation = mle.getMethod().getDeclaredAnnotation(CircuitBreakerAwareJmsListener.class);
            if (declaredAnnotation != null) {
                String[] strings = declaredAnnotation.hystrixCommandKeys();
                if (strings != null) {
                    CircuitBreakerAwareMessageListenerContainer container = (CircuitBreakerAwareMessageListenerContainer) listenerContainer;
                    container.setHystrixCommandKeys(Arrays.asList(strings));
                    container.setPermitsPerSecond(declaredAnnotation.permitsPerSecond());
                }
            }
        }
        return listenerContainer;
    }
			
Example 2
Project : spring-framework Source File : JmsListenerAnnotationBeanPostProcessorTests.java View Source Code on GitHub

	public void simpleMessageListener() {
		ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
				Config.class, SimpleMessageListenerTestBean.class);

		JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class);
		assertEquals("One container should have been registered", 1, factory.getListenerContainers().size());
		MessageListenerTestContainer container = factory.getListenerContainers().get(0);

		JmsListenerEndpoint endpoint = container.getEndpoint();
		assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass());
		MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint;
		assertNotNull(methodEndpoint.getBean());
		assertNotNull(methodEndpoint.getMethod());

		SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
		methodEndpoint.setupListenerContainer(listenerContainer);
		assertNotNull(listenerContainer.getMessageListener());

		assertTrue("Should have been started " + container, container.isStarted());
		assertTrue("Should have been stopped " + container, container.isStopped());
	}
			
Example 3
Project : spring-framework Source File : TracingJmsListenerEndpointRegistry.java View Source Code on GitHub

  private JmsListenerEndpoint replaceMethodJmsListenerEndpoint(MethodJmsListenerEndpoint original) {
    MethodJmsListenerEndpoint replacement = new TracingMethodJmsListenerEndpoint();

    replacement.setBean(original.getBean());
    replacement.setMethod(original.getMethod());
    replacement.setMostSpecificMethod(original.getMostSpecificMethod());
    MessageHandlerMethodFactory messageHandlerMethodFactory = registrar
        .getMessageHandlerMethodFactory();
    if (messageHandlerMethodFactory == null) {
      messageHandlerMethodFactory = createDefaultJmsHandlerMethodFactory();
    }
    replacement.setMessageHandlerMethodFactory(messageHandlerMethodFactory);
    replacement.setBeanFactory(beanFactory);
    replacement.setId(original.getId());
    replacement.setDestination(original.getDestination());
    replacement.setSelector(original.getSelector());
    replacement.setSubscription(original.getSubscription());
    replacement.setConcurrency(original.getConcurrency());

    return replacement;
  }