Search in sources :

Example 1 with DefaultRocketMQListenerContainer

use of org.apache.rocketmq.spring.starter.core.DefaultRocketMQListenerContainer in project rocketmq-externals by apache.

the class RocketMQAutoConfigurationTests method listenerContainer.

@Test
public void listenerContainer() {
    load(false, "spring.rocketmq.nameServer=127.0.0.1:9876");
    BeanDefinitionBuilder beanBuilder = BeanDefinitionBuilder.rootBeanDefinition(MyListener.class);
    this.context.registerBeanDefinition("myListener", beanBuilder.getBeanDefinition());
    this.context.refresh();
    assertThat(this.context.getBeansOfType(DefaultRocketMQListenerContainer.class)).isNotEmpty();
    assertThat(this.context.containsBean(DefaultRocketMQListenerContainer.class.getName() + "_1")).isTrue();
    DefaultRocketMQListenerContainer listenerContainer = this.context.getBean(DefaultRocketMQListenerContainer.class.getName() + "_1", DefaultRocketMQListenerContainer.class);
    ObjectMapper objectMapper = this.context.getBean("rocketMQMessageObjectMapper", ObjectMapper.class);
    assertThat(listenerContainer.getObjectMapper()).isEqualTo(objectMapper);
    assertThat(listenerContainer.getConsumeMode()).isEqualTo(ConsumeMode.CONCURRENTLY);
    assertThat(listenerContainer.getSelectorType()).isEqualTo(SelectorType.TAG);
    assertThat(listenerContainer.getSelectorExpress()).isEqualTo("*");
    assertThat(listenerContainer.getConsumerGroup()).isEqualTo(TEST_CONSUMER_GROUP);
    assertThat(listenerContainer.getTopic()).isEqualTo(TEST_TOPIC);
    assertThat(listenerContainer.getNameServer()).isEqualTo("127.0.0.1:9876");
    assertThat(listenerContainer.getMessageModel()).isEqualTo(MessageModel.CLUSTERING);
    assertThat(listenerContainer.getConsumeThreadMax()).isEqualTo(1);
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) DefaultRocketMQListenerContainer(org.apache.rocketmq.spring.starter.core.DefaultRocketMQListenerContainer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DefaultRocketMQListenerContainer (org.apache.rocketmq.spring.starter.core.DefaultRocketMQListenerContainer)1 Test (org.junit.Test)1 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)1