org.springframework.jms.config.SimpleJmsListenerEndpoint Java Examples

The following examples show how to use org.springframework.jms.config.SimpleJmsListenerEndpoint. 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: AbstractJmsAnnotationDrivenTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Test for {@link CustomBean} and an manually endpoint registered
 * with "myCustomEndpointId". The custom endpoint does not provide
 * any factory so it's registered with the default one
 */
public void testCustomConfiguration(ApplicationContext context) {
	JmsListenerContainerTestFactory defaultFactory =
			context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
	JmsListenerContainerTestFactory customFactory =
			context.getBean("customFactory", JmsListenerContainerTestFactory.class);
	assertEquals(1, defaultFactory.getListenerContainers().size());
	assertEquals(1, customFactory.getListenerContainers().size());
	JmsListenerEndpoint endpoint = defaultFactory.getListenerContainers().get(0).getEndpoint();
	assertEquals("Wrong endpoint type", SimpleJmsListenerEndpoint.class, endpoint.getClass());
	assertEquals("Wrong listener set in custom endpoint", context.getBean("simpleMessageListener"),
			((SimpleJmsListenerEndpoint) endpoint).getMessageListener());

	JmsListenerEndpointRegistry customRegistry =
			context.getBean("customRegistry", JmsListenerEndpointRegistry.class);
	assertEquals("Wrong number of containers in the registry", 2,
			customRegistry.getListenerContainerIds().size());
	assertEquals("Wrong number of containers in the registry", 2,
			customRegistry.getListenerContainers().size());
	assertNotNull("Container with custom id on the annotation should be found",
			customRegistry.getListenerContainer("listenerId"));
	assertNotNull("Container created with custom id should be found",
			customRegistry.getListenerContainer("myCustomEndpointId"));
}
 
Example #2
Source File: AbstractJmsAnnotationDrivenTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Test for {@link CustomBean} and an manually endpoint registered
 * with "myCustomEndpointId". The custom endpoint does not provide
 * any factory so it's registered with the default one
 */
public void testCustomConfiguration(ApplicationContext context) {
	JmsListenerContainerTestFactory defaultFactory =
			context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
	JmsListenerContainerTestFactory customFactory =
			context.getBean("customFactory", JmsListenerContainerTestFactory.class);
	assertEquals(1, defaultFactory.getListenerContainers().size());
	assertEquals(1, customFactory.getListenerContainers().size());
	JmsListenerEndpoint endpoint = defaultFactory.getListenerContainers().get(0).getEndpoint();
	assertEquals("Wrong endpoint type", SimpleJmsListenerEndpoint.class, endpoint.getClass());
	assertEquals("Wrong listener set in custom endpoint", context.getBean("simpleMessageListener"),
			((SimpleJmsListenerEndpoint) endpoint).getMessageListener());

	JmsListenerEndpointRegistry customRegistry =
			context.getBean("customRegistry", JmsListenerEndpointRegistry.class);
	assertEquals("Wrong number of containers in the registry", 2,
			customRegistry.getListenerContainerIds().size());
	assertEquals("Wrong number of containers in the registry", 2,
			customRegistry.getListenerContainers().size());
	assertNotNull("Container with custom id on the annotation should be found",
			customRegistry.getListenerContainer("listenerId"));
	assertNotNull("Container created with custom id should be found",
			customRegistry.getListenerContainer("myCustomEndpointId"));
}
 
Example #3
Source File: JMSConfiguration.java    From galeb with Apache License 2.0 6 votes vote down vote up
@Override
public void configureJmsListeners(JmsListenerEndpointRegistrar endpointRegistrar) {
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    endpoint.setId(QUEUE_NAME);
    endpoint.setDestination(QUEUE_NAME);
    endpoint.setConcurrency("5-5");
    endpoint.setMessageListener(message -> {
        try {
            if (message.isBodyAssignableTo(TargetDTO.class)) {
                healthCheckerService.check(message.getBody(TargetDTO.class));
            }
        } catch (JMSException e) {
            JsonEventToLogger eventToLogger = new JsonEventToLogger(this.getClass());
            eventToLogger.put("short_message", "Error processing message from queue");
            eventToLogger.sendError(e);
        }
    });
    endpointRegistrar.registerEndpoint(endpoint);
}
 
Example #4
Source File: EventListenerConfigurer.java    From blackduck-alert with Apache License 2.0 6 votes vote down vote up
@Override
public void configureJmsListeners(final JmsListenerEndpointRegistrar registrar) {
    logger.info("Registering JMS Listeners");
    for (final AlertEventListener listener : alertEventListeners) {
        if (listener != null) {
            final String destinationName = listener.getDestinationName();
            final String listenerId = createListenerId(destinationName);
            logger.info("Registering JMS Listener: {}", listenerId);
            final SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
            endpoint.setId(listenerId);
            endpoint.setDestination(destinationName);
            endpoint.setMessageListener(listener);
            registrar.registerEndpoint(endpoint);
        }
    }
}
 
Example #5
Source File: AbstractJmsAnnotationDrivenTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Test for {@link CustomBean} and an manually endpoint registered
 * with "myCustomEndpointId". The custom endpoint does not provide
 * any factory so it's registered with the default one
 */
public void testCustomConfiguration(ApplicationContext context) {
	JmsListenerContainerTestFactory defaultFactory =
			context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
	JmsListenerContainerTestFactory customFactory =
			context.getBean("customFactory", JmsListenerContainerTestFactory.class);
	assertEquals(1, defaultFactory.getListenerContainers().size());
	assertEquals(1, customFactory.getListenerContainers().size());
	JmsListenerEndpoint endpoint = defaultFactory.getListenerContainers().get(0).getEndpoint();
	assertEquals("Wrong endpoint type", SimpleJmsListenerEndpoint.class, endpoint.getClass());
	assertEquals("Wrong listener set in custom endpoint", context.getBean("simpleMessageListener"),
			((SimpleJmsListenerEndpoint) endpoint).getMessageListener());

	JmsListenerEndpointRegistry customRegistry =
			context.getBean("customRegistry", JmsListenerEndpointRegistry.class);
	assertEquals("Wrong number of containers in the registry", 2,
			customRegistry.getListenerContainerIds().size());
	assertEquals("Wrong number of containers in the registry", 2,
			customRegistry.getListenerContainers().size());
	assertNotNull("Container with custom id on the annotation should be found",
			customRegistry.getListenerContainer("listenerId"));
	assertNotNull("Container created with custom id should be found",
			customRegistry.getListenerContainer("myCustomEndpointId"));
}
 
Example #6
Source File: EnableJmsTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
	registrar.setEndpointRegistry(customRegistry());

	// Also register a custom endpoint
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	endpoint.setId("myCustomEndpointId");
	endpoint.setDestination("myQueue");
	endpoint.setMessageListener(simpleMessageListener());
	registrar.registerEndpoint(endpoint);
}
 
Example #7
Source File: AnnotationDrivenNamespaceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	endpoint.setId("myCustomEndpointId");
	endpoint.setDestination("myQueue");
	endpoint.setMessageListener(messageListener);
	registrar.registerEndpoint(endpoint);
}
 
Example #8
Source File: EnableJmsTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
	registrar.setEndpointRegistry(customRegistry());

	// Also register a custom endpoint
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	endpoint.setId("myCustomEndpointId");
	endpoint.setDestination("myQueue");
	endpoint.setMessageListener(simpleMessageListener());
	registrar.registerEndpoint(endpoint);
}
 
Example #9
Source File: AnnotationDrivenNamespaceTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	endpoint.setId("myCustomEndpointId");
	endpoint.setDestination("myQueue");
	endpoint.setMessageListener(messageListener);
	registrar.registerEndpoint(endpoint);
}
 
Example #10
Source File: ReceiverConfig.java    From spring-jms with MIT License 5 votes vote down vote up
@Bean
public DefaultMessageListenerContainer orderMessageListenerContainer() {
  SimpleJmsListenerEndpoint endpoint =
      new SimpleJmsListenerEndpoint();
  endpoint.setMessageListener(new StatusMessageListener("DMLC"));
  endpoint.setDestination(status1Destination);

  return orderDefaultJmsListenerContainerFactory()
      .createListenerContainer(endpoint);
}
 
Example #11
Source File: ReceiverConfig.java    From spring-jms with MIT License 5 votes vote down vote up
@Bean
public SimpleMessageListenerContainer statusMessageListenerContainer() {
  SimpleJmsListenerEndpoint endpoint =
      new SimpleJmsListenerEndpoint();
  endpoint.setMessageListener(new StatusMessageListener("SMLC"));
  endpoint.setDestination(status2Destination);

  return orderSimpleJmsListenerContainerFactory()
      .createListenerContainer(endpoint);
}
 
Example #12
Source File: EnableJmsTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
	registrar.setEndpointRegistry(customRegistry());

	// Also register a custom endpoint
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	endpoint.setId("myCustomEndpointId");
	endpoint.setDestination("myQueue");
	endpoint.setMessageListener(simpleMessageListener());
	registrar.registerEndpoint(endpoint);
}
 
Example #13
Source File: AnnotationDrivenNamespaceTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	endpoint.setId("myCustomEndpointId");
	endpoint.setDestination("myQueue");
	endpoint.setMessageListener(messageListener);
	registrar.registerEndpoint(endpoint);
}
 
Example #14
Source File: JmsMessageBrokerConfiguration.java    From piper with Apache License 2.0 5 votes vote down vote up
private void registerListenerEndpoint(JmsListenerEndpointRegistrar aRegistrar, String aQueueName, int aConcurrency, Object aDelegate, String aMethodName) {
  logger.info("Registring JMS Listener: {} -> {}:{}", aQueueName, aDelegate.getClass().getName(), aMethodName);
  
  MessageListenerAdapter messageListener = new NoReplyMessageListenerAdapter(aDelegate);
  messageListener.setMessageConverter(jacksonJmsMessageConverter(objectMapper));
  messageListener.setDefaultListenerMethod(aMethodName);

  SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
  endpoint.setId(aQueueName+"Endpoint");
  endpoint.setDestination(aQueueName);
  endpoint.setMessageListener(messageListener);

  aRegistrar.registerEndpoint(endpoint,createContainerFactory(aConcurrency));
}
 
Example #15
Source File: JmsChannelModelProcessor.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected JmsListenerEndpoint createJmsListenerEndpoint(JmsInboundChannelModel jmsChannelModel, String tenantId, EventRegistry eventRegistry) {
    
    String endpointId = getEndpointId(jmsChannelModel, tenantId);

    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();

    endpoint.setId(endpointId);
    endpoint.setDestination(resolve(jmsChannelModel.getDestination()));

    String selector = jmsChannelModel.getSelector();
    if (StringUtils.hasText(selector)) {
        endpoint.setSelector(resolve(selector));
    }

    String subscription = jmsChannelModel.getSubscription();
    if (StringUtils.hasText(subscription)) {
        endpoint.setSubscription(resolve(subscription));
    }

    String concurrency = jmsChannelModel.getConcurrency();
    if (StringUtils.hasText(concurrency)) {
        endpoint.setConcurrency(resolve(concurrency));
    }

    endpoint.setMessageListener(createMessageListener(eventRegistry, jmsChannelModel));
    return endpoint;
}
 
Example #16
Source File: JmsTracingConfigurationTest.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Override
public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	endpoint.setId("myCustomEndpointId");
	endpoint.setDestination("myQueue");
	endpoint.setMessageListener(simpleMessageListener(this.current));
	registrar.registerEndpoint(endpoint);
}