This commit is contained in:
Claus Ibsen 2016-01-17 10:20:37 +01:00
parent 24a9fa79f4
commit d5101d46a7
2 changed files with 28 additions and 9 deletions

View File

@ -35,6 +35,7 @@ import org.apache.camel.util.URISupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.connection.SingleConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
import javax.jms.Connection;
@ -92,18 +93,28 @@ public class ActiveMQComponent extends JmsComponent implements EndpointCompleter
setConfiguration(configuration);
}
/**
* Sets the broker URL to use to connect to ActiveMQ using the
* <a href="http://activemq.apache.org/configuring-transports.html">ActiveMQ URI format</a>
*/
public void setBrokerURL(String brokerURL) {
if (getConfiguration() instanceof ActiveMQConfiguration) {
((ActiveMQConfiguration)getConfiguration()).setBrokerURL(brokerURL);
}
}
/**
* Sets the username to be used to login to ActiveMQ
*/
public void setUserName(String userName) {
if (getConfiguration() instanceof ActiveMQConfiguration) {
((ActiveMQConfiguration)getConfiguration()).setUserName(userName);
}
}
/**
* Sets the password/passcode used to login to ActiveMQ
*/
public void setPassword(String password) {
if (getConfiguration() instanceof ActiveMQConfiguration) {
((ActiveMQConfiguration)getConfiguration()).setPassword(password);
@ -117,19 +128,33 @@ public class ActiveMQComponent extends JmsComponent implements EndpointCompleter
/**
* If enabled this will cause all Queues in the ActiveMQ broker to be eagerly populated into the CamelContext
* so that they can be easily browsed by any Camel tooling. This option is disabled by default.
*
* @param exposeAllQueues
*/
public void setExposeAllQueues(boolean exposeAllQueues) {
this.exposeAllQueues = exposeAllQueues;
}
/**
* Enables or disables whether a PooledConnectionFactory will be used so that when
* messages are sent to ActiveMQ from outside of a message consuming thread, pooling will be used rather
* than the default with the Spring {@link JmsTemplate} which will create a new connection, session, producer
* for each message then close them all down again.
* <p/>
* The default value is true. Note that this requires an extra dependency on commons-pool2.
*/
public void setUsePooledConnection(boolean usePooledConnection) {
if (getConfiguration() instanceof ActiveMQConfiguration) {
((ActiveMQConfiguration)getConfiguration()).setUsePooledConnection(usePooledConnection);
}
}
/**
* Enables or disables whether a Spring {@link SingleConnectionFactory} will be used so that when
* messages are sent to ActiveMQ from outside of a message consuming thread, pooling will be used rather
* than the default with the Spring {@link JmsTemplate} which will create a new connection, session, producer
* for each message then close them all down again.
* <p/>
* The default value is false and a pooled connection is used by default.
*/
public void setUseSingleConnection(boolean useSingleConnection) {
if (getConfiguration() instanceof ActiveMQConfiguration) {
((ActiveMQConfiguration)getConfiguration()).setUseSingleConnection(useSingleConnection);

View File

@ -17,7 +17,6 @@
package org.apache.activemq.camel.component;
import java.lang.reflect.Constructor;
import javax.jms.ConnectionFactory;
import org.apache.activemq.Service;
@ -32,12 +31,12 @@ import org.springframework.transaction.PlatformTransactionManager;
*
*/
public class ActiveMQConfiguration extends JmsConfiguration {
private ActiveMQComponent activeMQComponent;
private String brokerURL = ActiveMQConnectionFactory.DEFAULT_BROKER_URL;
private boolean useSingleConnection = false;
private boolean usePooledConnection = true;
private String userName;
private String password;
private ActiveMQComponent activeMQComponent;
public ActiveMQConfiguration() {
}
@ -66,7 +65,6 @@ public class ActiveMQConfiguration extends JmsConfiguration {
/**
* Sets the username to be used to login to ActiveMQ
* @param userName
*/
public void setUserName(String userName) {
this.userName = userName;
@ -78,8 +76,6 @@ public class ActiveMQConfiguration extends JmsConfiguration {
/**
* Sets the password/passcode used to login to ActiveMQ
*
* @param password
*/
public void setPassword(String password) {
this.password = password;
@ -92,8 +88,6 @@ public class ActiveMQConfiguration extends JmsConfiguration {
* for each message then close them all down again.
* <p/>
* The default value is false and a pooled connection is used by default.
*
* @param useSingleConnection
*/
public void setUseSingleConnection(boolean useSingleConnection) {
this.useSingleConnection = useSingleConnection;