@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2007 the original author or authors .
* Copyright 2002 - 201 0 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -18,6 +18,8 @@ package org.springframework.jms.listener.endpoint;
@@ -18,6 +18,8 @@ package org.springframework.jms.listener.endpoint;
import javax.jms.Session ;
import org.springframework.core.Constants ;
/ * *
* Common configuration object for activating a JMS message endpoint .
* Gets converted into a provider - specific JCA 1 . 5 ActivationSpec
@ -34,6 +36,10 @@ import javax.jms.Session;
@@ -34,6 +36,10 @@ import javax.jms.Session;
* /
public class JmsActivationSpecConfig {
/** Constants instance for javax.jms.Session */
private static final Constants sessionConstants = new Constants ( Session . class ) ;
private String destinationName ;
private boolean pubSubDomain = false ;
@ -101,26 +107,96 @@ public class JmsActivationSpecConfig {
@@ -101,26 +107,96 @@ public class JmsActivationSpecConfig {
return this . messageSelector ;
}
/ * *
* Set the JMS acknowledgement mode by the name of the corresponding constant
* in the JMS { @link Session } interface , e . g . "CLIENT_ACKNOWLEDGE" .
* < p > Note that JCA resource adapters generally only support auto and dups - ok
* ( see Spring ' s { @link StandardJmsActivationSpecFactory } ) . ActiveMQ also
* supports "SESSION_TRANSACTED" in the form of RA - managed transactions
* ( automatically translated by Spring ' s { @link DefaultJmsActivationSpecFactory } .
* @param constantName the name of the { @link Session } acknowledge mode constant
* @see javax . jms . Session # AUTO_ACKNOWLEDGE
* @see javax . jms . Session # CLIENT_ACKNOWLEDGE
* @see javax . jms . Session # DUPS_OK_ACKNOWLEDGE
* @see javax . jms . Session # SESSION_TRANSACTED
* @see StandardJmsActivationSpecFactory
* @see DefaultJmsActivationSpecFactory
* /
public void setAcknowledgeModeName ( String constantName ) {
setAcknowledgeMode ( sessionConstants . asNumber ( constantName ) . intValue ( ) ) ;
}
/ * *
* Set the JMS acknowledgement mode to use .
* @see javax . jms . Session # AUTO_ACKNOWLEDGE
* @see javax . jms . Session # CLIENT_ACKNOWLEDGE
* @see javax . jms . Session # DUPS_OK_ACKNOWLEDGE
* @see javax . jms . Session # SESSION_TRANSACTED
* /
public void setAcknowledgeMode ( int acknowledgeMode ) {
this . acknowledgeMode = acknowledgeMode ;
}
/ * *
* Return the JMS acknowledgement mode to use .
* /
public int getAcknowledgeMode ( ) {
return this . acknowledgeMode ;
}
/ * *
* Specify concurrency limits via a "lower-upper" String , e . g . "5-10" , or a simple
* upper limit String , e . g . "10" .
* < p > JCA listener containers will always scale from zero to the given upper limit .
* A specified lower limit will effectively be ignored .
* < p > This property is primarily supported for configuration compatibility with
* { @link org . springframework . jms . listener . DefaultMessageListenerContainer } .
* For this activation config , generally use { @link # setMaxConcurrency } instead .
* /
public void setConcurrency ( String concurrency ) {
try {
int separatorIndex = concurrency . indexOf ( '-' ) ;
if ( separatorIndex ! = - 1 ) {
setMaxConcurrency ( Integer . parseInt ( concurrency . substring ( separatorIndex + 1 , concurrency . length ( ) ) ) ) ;
}
else {
setMaxConcurrency ( Integer . parseInt ( concurrency ) ) ;
}
}
catch ( NumberFormatException ex ) {
throw new IllegalArgumentException ( "Invalid concurrency value [" + concurrency + "]: only " +
"single maximum integer (e.g. \"5\") and minimum-maximum combo (e.g. \"3-5\") supported. " +
"Note that JmsActivationSpecConfig will effectively ignore the minimum value and " +
"scale from zero up to the number of consumers according to the maximum value." ) ;
}
}
/ * *
* Specify the maximum number of consumers / sessions to use , effectively
* controlling the number of concurrent invocations on the target listener .
* /
public void setMaxConcurrency ( int maxConcurrency ) {
this . maxConcurrency = maxConcurrency ;
}
/ * *
* Return the maximum number of consumers / sessions to use .
* /
public int getMaxConcurrency ( ) {
return this . maxConcurrency ;
}
/ * *
* Specify the maximum number of messages to load into a session
* ( a kind of batch size ) .
* /
public void setPrefetchSize ( int prefetchSize ) {
this . prefetchSize = prefetchSize ;
}
/ * *
* Return the maximum number of messages to load into a session .
* /
public int getPrefetchSize ( ) {
return this . prefetchSize ;
}