コード例 #1
0
  @Test
  public void jcaExclusiveProperties() {
    DefaultJcaListenerContainerFactory factory = new DefaultJcaListenerContainerFactory();
    factory.setDestinationResolver(destinationResolver);
    factory.setActivationSpecFactory(new StubJmsActivationSpecFactory());

    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    endpoint.setMessageListener(new MessageListenerAdapter());
    thrown.expect(IllegalStateException.class);
    factory.createListenerContainer(endpoint);
  }
コード例 #2
0
  @Test
  public void backOffOverridesRecoveryInterval() {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    BackOff backOff = new FixedBackOff();
    factory.setBackOff(backOff);
    factory.setRecoveryInterval(2000L);

    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    endpoint.setDestination("myQueue");
    DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);

    assertSame(backOff, new DirectFieldAccessor(container).getPropertyValue("backOff"));
  }
コード例 #3
0
  @Test
  public void createSimpleContainer() {
    SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
    setDefaultJmsConfig(factory);
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();

    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    endpoint.setDestination("myQueue");

    SimpleMessageListenerContainer container = factory.createListenerContainer(endpoint);

    assertDefaultJmsConfig(container);
    assertEquals(messageListener, container.getMessageListener());
    assertEquals("myQueue", container.getDestinationName());
  }
コード例 #4
0
  @Test
  public void createJcaContainerFullConfig() {
    DefaultJcaListenerContainerFactory factory = new DefaultJcaListenerContainerFactory();
    setDefaultJcaConfig(factory);
    factory.setConcurrency("10");

    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    endpoint.setDestination("myQueue");
    JmsMessageEndpointManager container = factory.createListenerContainer(endpoint);

    assertDefaultJcaConfig(container);
    assertEquals(10, container.getActivationSpecConfig().getMaxConcurrency());
    assertEquals(messageListener, container.getMessageListener());
    assertEquals("myQueue", container.getActivationSpecConfig().getDestinationName());
  }
コード例 #5
0
  @Test
  public void createJmsContainerFullConfig() {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    setDefaultJmsConfig(factory);
    factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
    factory.setConcurrency("3-10");
    factory.setMaxMessagesPerTask(5);

    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    MessageListener messageListener = new MessageListenerAdapter();
    endpoint.setMessageListener(messageListener);
    endpoint.setDestination("myQueue");
    DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);

    assertDefaultJmsConfig(container);
    assertEquals(DefaultMessageListenerContainer.CACHE_CONSUMER, container.getCacheLevel());
    assertEquals(3, container.getConcurrentConsumers());
    assertEquals(10, container.getMaxConcurrentConsumers());
    assertEquals(5, container.getMaxMessagesPerTask());

    assertEquals(messageListener, container.getMessageListener());
    assertEquals("myQueue", container.getDestinationName());
  }