List of usage examples for org.springframework.jms.listener AbstractMessageListenerContainer setMessageSelector
public void setMessageSelector(@Nullable String messageSelector)
From source file:org.bremersee.common.spring.autoconfigure.JmsListenerEndpointImpl.java
private void setupJmsListenerContainer(AbstractMessageListenerContainer listenerContainer) { if (getDestinationProperties() != null) { if (getDestinationProperties().getConcurrency() != null) { listenerContainer.setConcurrency(getDestinationProperties().getConcurrency()); }/*from w w w .j av a2 s . c om*/ if (getDestinationProperties().getDestinationName() != null) { listenerContainer.setDestinationName(getDestinationProperties().getDestinationName()); } listenerContainer.setPubSubDomain(getDestinationProperties().isPubSubDomain()); listenerContainer.setPubSubNoLocal(getDestinationProperties().isPubSubNoLocal()); listenerContainer.setSessionAcknowledgeMode(getDestinationProperties().getSessionAcknowledgeMode()); listenerContainer.setSubscriptionDurable(destinationProperties.isSubscriptionDurable()); if (getDestinationProperties().getSubscriptionName() != null) { listenerContainer.setSubscriptionName(getDestinationProperties().getSubscriptionName()); } listenerContainer.setSubscriptionShared(getDestinationProperties().isSubscriptionShared()); } if (getMessageSelector() != null) { listenerContainer.setMessageSelector(getMessageSelector()); } setupMessageListener(listenerContainer); }
From source file:org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint.java
protected AbstractMessageListenerContainer createListenerContainer() { final AbstractMessageListenerContainer container; if (LISTENER_TYPE_DEFAULT.equals(listenerType)) { container = createDefaultMessageListenerContainer(); } else if (LISTENER_TYPE_SIMPLE.equals(listenerType)) { container = createSimpleMessageListenerContainer(); } else if (LISTENER_TYPE_SERVER.equals(listenerType)) { container = createServerSessionMessageListenerContainer(); } else {/*from ww w .j av a 2s . c o m*/ throw new IllegalStateException(); } container.setAutoStartup(false); container.setClientId(clientId); container.setConnectionFactory(getConnectionFactory()); if (destination != null) { container.setDestination(destination); } else if (destinationName != null) { container.setDestinationName(destinationName); } if (getDestinationResolver() != null) { container.setDestinationResolver(getDestinationResolver()); } if (subscriptionDurable) { if (durableSubscriptionName == null) { // Use unique name generated from this endpoint durableSubscriptionName = getService() + "#" + getEndpoint(); } container.setDurableSubscriptionName(durableSubscriptionName); } container.setExceptionListener(exceptionListener); container.setMessageSelector(messageSelector); container.setPubSubDomain(isPubSubDomain()); container.setSessionAcknowledgeMode(sessionAcknowledgeMode); container.setSubscriptionDurable(subscriptionDurable); return container; }
From source file:org.apache.camel.component.jms.JmsConfiguration.java
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); }/* w ww. j ava 2 s. c o m*/ container.setAutoStartup(autoStartup); if (durableSubscriptionName != null) { container.setDurableSubscriptionName(durableSubscriptionName); container.setSubscriptionDurable(true); } if (durableSubscriptionName != null && clientId == null) { throw new IllegalArgumentException( "ClientId must be configured when subscription is durable for " + endpoint); } if (clientId != null) { container.setClientId(clientId); } if (exceptionListener != null) { container.setExceptionListener(exceptionListener); } 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) { // this includes DefaultMessageListenerContainer102 DefaultMessageListenerContainer listenerContainer = (DefaultMessageListenerContainer) container; if (concurrentConsumers >= 0) { listenerContainer.setConcurrentConsumers(concurrentConsumers); } if (cacheLevel >= 0) { listenerContainer.setCacheLevel(cacheLevel); } else if (cacheLevelName != null) { listenerContainer.setCacheLevelName(cacheLevelName); } else { listenerContainer.setCacheLevel(defaultCacheLevel(endpoint)); } if (idleTaskExecutionLimit >= 0) { listenerContainer.setIdleTaskExecutionLimit(idleTaskExecutionLimit); } if (maxConcurrentConsumers > 0) { if (maxConcurrentConsumers < concurrentConsumers) { throw new IllegalArgumentException("Property maxConcurrentConsumers: " + maxConcurrentConsumers + " must be higher than concurrentConsumers: " + concurrentConsumers); } listenerContainer.setMaxConcurrentConsumers(maxConcurrentConsumers); } if (maxMessagesPerTask >= 0) { listenerContainer.setMaxMessagesPerTask(maxMessagesPerTask); } listenerContainer.setPubSubNoLocal(pubSubNoLocal); if (receiveTimeout >= 0) { listenerContainer.setReceiveTimeout(receiveTimeout); } if (recoveryInterval >= 0) { listenerContainer.setRecoveryInterval(recoveryInterval); } if (taskExecutor != null) { listenerContainer.setTaskExecutor(taskExecutor); } PlatformTransactionManager tm = getTransactionManager(); if (tm != null && transacted) { listenerContainer.setTransactionManager(tm); } else if (transacted) { throw new IllegalArgumentException( "Property transacted is enabled but a transactionManager was not injected!"); } if (transactionName != null) { listenerContainer.setTransactionName(transactionName); } if (transactionTimeout >= 0) { listenerContainer.setTransactionTimeout(transactionTimeout); } if (taskExecutor != null) { listenerContainer.setTaskExecutor(taskExecutor); } else if (taskExecutorSpring2 != null) { // use reflection to invoke to support spring 2 when JAR is compiled with Spring 3.0 IntrospectionSupport.setProperty(listenerContainer, "taskExecutor", endpoint.getTaskExecutorSpring2()); } } else if (container instanceof SimpleMessageListenerContainer) { // this includes SimpleMessageListenerContainer102 SimpleMessageListenerContainer listenerContainer = (SimpleMessageListenerContainer) container; if (concurrentConsumers >= 0) { listenerContainer.setConcurrentConsumers(concurrentConsumers); } listenerContainer.setPubSubNoLocal(pubSubNoLocal); if (taskExecutor != null) { listenerContainer.setTaskExecutor(taskExecutor); } else if (taskExecutorSpring2 != null) { // use reflection to invoke to support spring 2 when JAR is compiled with Spring 3.0 IntrospectionSupport.setProperty(listenerContainer, "taskExecutor", endpoint.getTaskExecutorSpring2()); } } }