Search in sources :

Example 1 with SimpleMessageListenerContainer

use of org.springframework.jms.listener.SimpleMessageListenerContainer in project camel by apache.

the class JmsConfiguration method configureMessageListenerContainer.

protected void configureMessageListenerContainer(AbstractMessageListenerContainer container, JmsEndpoint endpoint) throws Exception {
    container.setConnectionFactory(getListenerConnectionFactory());
    if (endpoint instanceof DestinationEndpoint) {
        container.setDestinationResolver(createDestinationResolver((DestinationEndpoint) endpoint));
    } else if (destinationResolver != null) {
        container.setDestinationResolver(destinationResolver);
    }
    container.setAutoStartup(autoStartup);
    if (durableSubscriptionName != null) {
        container.setDurableSubscriptionName(durableSubscriptionName);
        container.setSubscriptionDurable(true);
    }
    if (clientId != null) {
        container.setClientId(clientId);
    }
    if (exceptionListener != null) {
        container.setExceptionListener(exceptionListener);
    }
    if (errorHandler != null) {
        container.setErrorHandler(errorHandler);
    } else {
        ErrorHandler handler = new DefaultSpringErrorHandler(endpoint.getCamelContext(), EndpointMessageListener.class, getErrorHandlerLoggingLevel(), isErrorHandlerLogStackTrace());
        container.setErrorHandler(handler);
    }
    container.setAcceptMessagesWhileStopping(acceptMessagesWhileStopping);
    container.setExposeListenerSession(exposeListenerSession);
    container.setSessionTransacted(transacted);
    if (transacted) {
        container.setSessionAcknowledgeMode(Session.SESSION_TRANSACTED);
    } else {
        if (acknowledgementMode >= 0) {
            container.setSessionAcknowledgeMode(acknowledgementMode);
        } else if (acknowledgementModeName != null) {
            container.setSessionAcknowledgeModeName(acknowledgementModeName);
        }
    }
    if (endpoint.getSelector() != null && endpoint.getSelector().length() != 0) {
        container.setMessageSelector(endpoint.getSelector());
    }
    if (container instanceof DefaultMessageListenerContainer) {
        DefaultMessageListenerContainer listenerContainer = (DefaultMessageListenerContainer) container;
        configureDefaultMessageListenerContainer(endpoint, listenerContainer);
    } else if (container instanceof SimpleMessageListenerContainer) {
        SimpleMessageListenerContainer listenerContainer = (SimpleMessageListenerContainer) container;
        configureSimpleMessageListenerContainer(listenerContainer);
    }
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) ErrorHandler(org.springframework.util.ErrorHandler) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer)

Example 2 with SimpleMessageListenerContainer

use of org.springframework.jms.listener.SimpleMessageListenerContainer in project av-service by dvoraka.

the class JmsFileClientConfig method messageListenerContainer.

@Bean
public SimpleMessageListenerContainer messageListenerContainer(ConnectionFactory connectionFactory, MessageListener messageListener) {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(connectionFactory);
    container.setDestinationName(resultDestination);
    container.setMessageListener(messageListener);
    return container;
}
Also used : SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Bean(org.springframework.context.annotation.Bean)

Example 3 with SimpleMessageListenerContainer

use of org.springframework.jms.listener.SimpleMessageListenerContainer in project tutorials by eugenp.

the class JmsServer method listener.

@Bean
SimpleMessageListenerContainer listener(ConnectionFactory factory, JmsInvokerServiceExporter exporter) {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(factory);
    container.setDestinationName("remotingQueue");
    container.setConcurrentConsumers(1);
    container.setMessageListener(exporter);
    return container;
}
Also used : SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Bean(org.springframework.context.annotation.Bean)

Example 4 with SimpleMessageListenerContainer

use of org.springframework.jms.listener.SimpleMessageListenerContainer in project spring-integration by spring-projects.

the class JmsChannelFactoryBean method createContainer.

private AbstractMessageListenerContainer createContainer() throws Exception {
    if (this.containerType == null) {
        this.containerType = DefaultMessageListenerContainer.class;
    }
    AbstractMessageListenerContainer container = this.containerType.newInstance();
    container.setAcceptMessagesWhileStopping(this.acceptMessagesWhileStopping);
    container.setAutoStartup(this.autoStartup);
    container.setClientId(this.clientId);
    container.setConnectionFactory(this.connectionFactory);
    if (this.destination != null) {
        container.setDestination(this.destination);
    }
    if (this.destinationName != null) {
        container.setDestinationName(this.destinationName);
    }
    if (this.destinationResolver != null) {
        container.setDestinationResolver(this.destinationResolver);
    }
    container.setDurableSubscriptionName(this.durableSubscriptionName);
    container.setErrorHandler(this.errorHandler);
    container.setExceptionListener(this.exceptionListener);
    if (this.exposeListenerSession != null) {
        container.setExposeListenerSession(this.exposeListenerSession);
    }
    container.setMessageSelector(this.messageSelector);
    if (this.phase != null) {
        container.setPhase(this.phase);
    }
    if (this.pubSubDomain != null) {
        container.setPubSubDomain(this.pubSubDomain);
    }
    container.setSessionAcknowledgeMode(this.sessionAcknowledgeMode);
    container.setSessionTransacted(this.sessionTransacted);
    container.setSubscriptionDurable(this.subscriptionDurable);
    container.setSubscriptionShared(this.subscriptionShared);
    if (container instanceof DefaultMessageListenerContainer) {
        DefaultMessageListenerContainer dmlc = (DefaultMessageListenerContainer) container;
        if (this.cacheLevelName != null) {
            dmlc.setCacheLevelName(this.cacheLevelName);
        }
        if (this.cacheLevel != null) {
            dmlc.setCacheLevel(this.cacheLevel);
        }
        if (StringUtils.hasText(this.concurrency)) {
            dmlc.setConcurrency(this.concurrency);
        }
        if (this.concurrentConsumers != null) {
            dmlc.setConcurrentConsumers(this.concurrentConsumers);
        }
        if (this.maxConcurrentConsumers != null) {
            dmlc.setMaxConcurrentConsumers(this.maxConcurrentConsumers);
        }
        if (this.idleTaskExecutionLimit != null) {
            dmlc.setIdleTaskExecutionLimit(this.idleTaskExecutionLimit);
        }
        if (this.maxMessagesPerTask != null) {
            dmlc.setMaxMessagesPerTask(this.maxMessagesPerTask);
        }
        dmlc.setPubSubNoLocal(this.pubSubNoLocal);
        if (this.receiveTimeout != null) {
            dmlc.setReceiveTimeout(this.receiveTimeout);
        }
        if (this.recoveryInterval != null) {
            dmlc.setRecoveryInterval(this.recoveryInterval);
        }
        dmlc.setTaskExecutor(this.taskExecutor);
        dmlc.setTransactionManager(this.transactionManager);
        if (this.transactionName != null) {
            dmlc.setTransactionName(this.transactionName);
        }
        if (this.transactionTimeout != null) {
            dmlc.setTransactionTimeout(this.transactionTimeout);
        }
    } else if (container instanceof SimpleMessageListenerContainer) {
        SimpleMessageListenerContainer smlc = (SimpleMessageListenerContainer) container;
        if (StringUtils.hasText(this.concurrency)) {
            smlc.setConcurrency(this.concurrency);
        }
        if (this.concurrentConsumers != null) {
            smlc.setConcurrentConsumers(this.concurrentConsumers);
        }
        smlc.setPubSubNoLocal(this.pubSubNoLocal);
        smlc.setTaskExecutor(this.taskExecutor);
    }
    return container;
}
Also used : DefaultMessageListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) AbstractMessageListenerContainer(org.springframework.jms.listener.AbstractMessageListenerContainer)

Example 5 with SimpleMessageListenerContainer

use of org.springframework.jms.listener.SimpleMessageListenerContainer in project spring-integration by spring-projects.

the class JmsChannelParserTests method withSimpleContainer.

@Test
public void withSimpleContainer() {
    SimpleMessageListenerContainer container = TestUtils.getPropertyValue(withSimpleContainer, "container", SimpleMessageListenerContainer.class);
    assertEquals("simple.container.queue", container.getDestinationName());
}
Also used : SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) Test(org.junit.Test)

Aggregations

SimpleMessageListenerContainer (org.springframework.jms.listener.SimpleMessageListenerContainer)19 Test (org.junit.jupiter.api.Test)9 MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)7 Bean (org.springframework.context.annotation.Bean)5 MessageListener (jakarta.jms.MessageListener)2 Test (org.junit.Test)2 JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)2 MethodJmsListenerEndpoint (org.springframework.jms.config.MethodJmsListenerEndpoint)2 AbstractMessageListenerContainer (org.springframework.jms.listener.AbstractMessageListenerContainer)2 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)2 MessageListenerAdapter (org.springframework.jms.listener.adapter.MessageListenerAdapter)2 Session (jakarta.jms.Session)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 StubTextMessage (org.springframework.jms.StubTextMessage)1 AbstractJmsListenerEndpoint (org.springframework.jms.config.AbstractJmsListenerEndpoint)1 JmsListenerEndpoint (org.springframework.jms.config.JmsListenerEndpoint)1 MessageListenerTestContainer (org.springframework.jms.config.MessageListenerTestContainer)1 QosSettings (org.springframework.jms.support.QosSettings)1