| Method from org.apache.activemq.ActiveMQConnectionFactory Detail: |
public boolean buildFromMap(Map properties) {
boolean rc = false;
ActiveMQPrefetchPolicy p = new ActiveMQPrefetchPolicy();
if (IntrospectionSupport.setProperties(p, properties, "prefetchPolicy.")) {
setPrefetchPolicy(p);
rc = true;
}
RedeliveryPolicy rp = new RedeliveryPolicy();
if (IntrospectionSupport.setProperties(rp, properties, "redeliveryPolicy.")) {
setRedeliveryPolicy(rp);
rc = true;
}
BlobTransferPolicy blobTransferPolicy = new BlobTransferPolicy();
if (IntrospectionSupport.setProperties(blobTransferPolicy, properties, "blobTransferPolicy.")) {
setBlobTransferPolicy(blobTransferPolicy);
rc = true;
}
rc |= IntrospectionSupport.setProperties(this, properties);
return rc;
}
|
public void buildFromProperties(Properties properties) {
if (properties == null) {
properties = new Properties();
}
String temp = properties.getProperty(Context.PROVIDER_URL);
if (temp == null || temp.length() == 0) {
temp = properties.getProperty("brokerURL");
}
if (temp != null && temp.length() > 0) {
setBrokerURL(temp);
}
Map< String, Object > p = new HashMap(properties);
buildFromMap(p);
}
|
protected void configureConnection(ActiveMQConnection connection) {
connection.setPrefetchPolicy(getPrefetchPolicy());
connection.setDisableTimeStampsByDefault(isDisableTimeStampsByDefault());
connection.setOptimizedMessageDispatch(isOptimizedMessageDispatch());
connection.setCopyMessageOnSend(isCopyMessageOnSend());
connection.setUseCompression(isUseCompression());
connection.setObjectMessageSerializationDefered(isObjectMessageSerializationDefered());
connection.setDispatchAsync(isDispatchAsync());
connection.setUseAsyncSend(isUseAsyncSend());
connection.setAlwaysSyncSend(isAlwaysSyncSend());
connection.setAlwaysSessionAsync(isAlwaysSessionAsync());
connection.setOptimizeAcknowledge(isOptimizeAcknowledge());
connection.setUseRetroactiveConsumer(isUseRetroactiveConsumer());
connection.setRedeliveryPolicy(getRedeliveryPolicy());
connection.setTransformer(getTransformer());
connection.setBlobTransferPolicy(getBlobTransferPolicy().copy());
connection.setWatchTopicAdvisories(isWatchTopicAdvisories());
connection.setProducerWindowSize(getProducerWindowSize());
connection.setWarnAboutUnstartedConnectionTimeout(getWarnAboutUnstartedConnectionTimeout());
connection.setSendTimeout(getSendTimeout());
if (transportListener != null) {
connection.addTransportListener(transportListener);
}
}
|
public ActiveMQConnectionFactory copy() {
try {
return (ActiveMQConnectionFactory)super.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException("This should never happen: " + e, e);
}
}
Returns a copy of the given connection factory |
protected ActiveMQConnection createActiveMQConnection() throws JMSException {
return createActiveMQConnection(userName, password);
}
|
protected ActiveMQConnection createActiveMQConnection(String userName,
String password) throws JMSException {
if (brokerURL == null) {
throw new ConfigurationException("brokerURL not set.");
}
ActiveMQConnection connection = null;
try {
Transport transport = createTransport();
connection = createActiveMQConnection(transport, factoryStats);
connection.setUserName(userName);
connection.setPassword(password);
configureConnection(connection);
transport.start();
if (clientID != null) {
connection.setDefaultClientID(clientID);
}
return connection;
} catch (JMSException e) {
// Clean up!
try {
connection.close();
} catch (Throwable ignore) {
}
throw e;
} catch (Exception e) {
// Clean up!
try {
connection.close();
} catch (Throwable ignore) {
}
throw JMSExceptionSupport.create("Could not connect to broker URL: " + brokerURL + ". Reason: " + e, e);
}
}
|
protected ActiveMQConnection createActiveMQConnection(Transport transport,
JMSStatsImpl stats) throws Exception {
ActiveMQConnection connection = new ActiveMQConnection(transport, getClientIdGenerator(), stats);
return connection;
}
|
public Connection createConnection() throws JMSException {
return createActiveMQConnection();
}
|
public Connection createConnection(String userName,
String password) throws JMSException {
return createActiveMQConnection(userName, password);
}
|
public QueueConnection createQueueConnection() throws JMSException {
return createActiveMQConnection();
}
|
public QueueConnection createQueueConnection(String userName,
String password) throws JMSException {
return createActiveMQConnection(userName, password);
}
|
public TopicConnection createTopicConnection() throws JMSException {
return createActiveMQConnection();
}
|
public TopicConnection createTopicConnection(String userName,
String password) throws JMSException {
return createActiveMQConnection(userName, password);
}
|
protected Transport createTransport() throws JMSException {
try {
return TransportFactory.connect(brokerURL, DEFAULT_CONNECTION_EXECUTOR);
} catch (Exception e) {
throw JMSExceptionSupport.create("Could not create Transport. Reason: " + e, e);
}
}
Creates a Transport based on this object's connection settings. Separated
from createActiveMQConnection to allow for subclasses to override. |
public BlobTransferPolicy getBlobTransferPolicy() {
return blobTransferPolicy;
}
|
public String getBrokerURL() {
return brokerURL == null ? null : brokerURL.toString();
}
|
public String getClientID() {
return clientID;
}
|
public String getClientIDPrefix() {
return clientIDPrefix;
}
|
protected synchronized IdGenerator getClientIdGenerator() {
if (clientIdGenerator == null) {
if (clientIDPrefix != null) {
clientIdGenerator = new IdGenerator(clientIDPrefix);
} else {
clientIdGenerator = new IdGenerator();
}
}
return clientIdGenerator;
}
|
public int getCloseTimeout() {
return closeTimeout;
}
|
public String getPassword() {
return password;
}
|
public ActiveMQPrefetchPolicy getPrefetchPolicy() {
return prefetchPolicy;
}
|
public synchronized int getProducerWindowSize() {
return producerWindowSize;
}
|
public RedeliveryPolicy getRedeliveryPolicy() {
return redeliveryPolicy;
}
|
public int getSendTimeout() {
return sendTimeout;
}
|
public StatsImpl getStats() {
// TODO
return null;
}
|
public MessageTransformer getTransformer() {
return transformer;
}
|
public TransportListener getTransportListener() {
return transportListener;
}
|
public String getUserName() {
return userName;
}
|
public long getWarnAboutUnstartedConnectionTimeout() {
return warnAboutUnstartedConnectionTimeout;
}
|
public boolean isAlwaysSessionAsync() {
return alwaysSessionAsync;
}
|
public boolean isAlwaysSyncSend() {
return this.alwaysSyncSend;
}
|
public boolean isCopyMessageOnSend() {
return copyMessageOnSend;
}
|
public boolean isDisableTimeStampsByDefault() {
return disableTimeStampsByDefault;
}
|
public boolean isDispatchAsync() {
return dispatchAsync;
}
|
public boolean isExclusiveConsumer() {
return exclusiveConsumer;
}
|
public boolean isNestedMapAndListEnabled() {
return nestedMapAndListEnabled;
}
|
public boolean isObjectMessageSerializationDefered() {
return objectMessageSerializationDefered;
}
|
public boolean isOptimizeAcknowledge() {
return optimizeAcknowledge;
}
|
public boolean isOptimizedMessageDispatch() {
return optimizedMessageDispatch;
}
|
public boolean isStatsEnabled() {
return this.factoryStats.isEnabled();
}
|
public boolean isUseAsyncSend() {
return useAsyncSend;
}
|
public boolean isUseCompression() {
return useCompression;
}
|
public boolean isUseRetroactiveConsumer() {
return useRetroactiveConsumer;
}
|
public synchronized boolean isWatchTopicAdvisories() {
return watchTopicAdvisories;
}
|
public void populateProperties(Properties props) {
props.setProperty("dispatchAsync", Boolean.toString(isDispatchAsync()));
if (getBrokerURL() != null) {
props.setProperty(Context.PROVIDER_URL, getBrokerURL());
props.setProperty("brokerURL", getBrokerURL());
}
if (getClientID() != null) {
props.setProperty("clientID", getClientID());
}
IntrospectionSupport.getProperties(getPrefetchPolicy(), props, "prefetchPolicy.");
IntrospectionSupport.getProperties(getRedeliveryPolicy(), props, "redeliveryPolicy.");
IntrospectionSupport.getProperties(getBlobTransferPolicy(), props, "blobTransferPolicy.");
props.setProperty("copyMessageOnSend", Boolean.toString(isCopyMessageOnSend()));
props.setProperty("disableTimeStampsByDefault", Boolean.toString(isDisableTimeStampsByDefault()));
props.setProperty("objectMessageSerializationDefered", Boolean.toString(isObjectMessageSerializationDefered()));
props.setProperty("optimizedMessageDispatch", Boolean.toString(isOptimizedMessageDispatch()));
if (getPassword() != null) {
props.setProperty("password", getPassword());
}
props.setProperty("useAsyncSend", Boolean.toString(isUseAsyncSend()));
props.setProperty("useCompression", Boolean.toString(isUseCompression()));
props.setProperty("useRetroactiveConsumer", Boolean.toString(isUseRetroactiveConsumer()));
props.setProperty("watchTopicAdvisories", Boolean.toString(isWatchTopicAdvisories()));
if (getUserName() != null) {
props.setProperty("userName", getUserName());
}
props.setProperty("closeTimeout", Integer.toString(getCloseTimeout()));
props.setProperty("alwaysSessionAsync", Boolean.toString(isAlwaysSessionAsync()));
props.setProperty("optimizeAcknowledge", Boolean.toString(isOptimizeAcknowledge()));
props.setProperty("statsEnabled", Boolean.toString(isStatsEnabled()));
props.setProperty("alwaysSyncSend", Boolean.toString(isAlwaysSyncSend()));
props.setProperty("producerWindowSize", Integer.toString(getProducerWindowSize()));
props.setProperty("sendTimeout", Integer.toString(getSendTimeout()));
}
|
public void setAlwaysSessionAsync(boolean alwaysSessionAsync) {
this.alwaysSessionAsync = alwaysSessionAsync;
}
If this flag is set then a separate thread is not used for dispatching
messages for each Session in the Connection. However, a separate thread
is always used if there is more than one session, or the session isn't in
auto acknowledge or duplicates ok mode |
public void setAlwaysSyncSend(boolean alwaysSyncSend) {
this.alwaysSyncSend = alwaysSyncSend;
}
Set true if always require messages to be sync sent |
public void setBlobTransferPolicy(BlobTransferPolicy blobTransferPolicy) {
this.blobTransferPolicy = blobTransferPolicy;
}
Sets the policy used to describe how out-of-band BLOBs (Binary Large
OBjects) are transferred from producers to brokers to consumers |
public void setBrokerURL(String brokerURL) {
this.brokerURL = createURI(brokerURL);
// Use all the properties prefixed with 'jms.' to set the connection
// factory
// options.
if (this.brokerURL.getQuery() != null) {
// It might be a standard URI or...
try {
Map map = URISupport.parseQuery(this.brokerURL.getQuery());
if (buildFromMap(IntrospectionSupport.extractProperties(map, "jms."))) {
this.brokerURL = URISupport.createRemainingURI(this.brokerURL, map);
}
} catch (URISyntaxException e) {
}
} else {
// It might be a composite URI.
try {
CompositeData data = URISupport.parseComposite(this.brokerURL);
if (buildFromMap(IntrospectionSupport.extractProperties(data.getParameters(), "jms."))) {
this.brokerURL = data.toURI();
}
} catch (URISyntaxException e) {
}
}
}
|
public void setClientID(String clientID) {
this.clientID = clientID;
}
Sets the JMS clientID to use for the created connection. Note that this
can only be used by one connection at once so generally its a better idea
to set the clientID on a Connection |
public void setClientIDPrefix(String clientIDPrefix) {
this.clientIDPrefix = clientIDPrefix;
}
Sets the prefix used by autogenerated JMS Client ID values which are used
if the JMS client does not explicitly specify on. |
protected void setClientIdGenerator(IdGenerator clientIdGenerator) {
this.clientIdGenerator = clientIdGenerator;
}
|
public void setCloseTimeout(int closeTimeout) {
this.closeTimeout = closeTimeout;
}
Sets the timeout before a close is considered complete. Normally a
close() on a connection waits for confirmation from the broker; this
allows that operation to timeout to save the client hanging if there is
no broker |
public void setCopyMessageOnSend(boolean copyMessageOnSend) {
this.copyMessageOnSend = copyMessageOnSend;
}
Should a JMS message be copied to a new JMS Message object as part of the
send() method in JMS. This is enabled by default to be compliant with the
JMS specification. You can disable it if you do not mutate JMS messages
after they are sent for a performance boost |
public void setDisableTimeStampsByDefault(boolean disableTimeStampsByDefault) {
this.disableTimeStampsByDefault = disableTimeStampsByDefault;
}
Sets whether or not timestamps on messages should be disabled or not. If
you disable them it adds a small performance boost. |
public void setDispatchAsync(boolean asyncDispatch) {
this.dispatchAsync = asyncDispatch;
}
Enables or disables the default setting of whether or not consumers have
their messages dispatched
synchronously or asynchronously by the broker. For non-durable
topics for example we typically dispatch synchronously by default to
minimize context switches which boost performance. However sometimes its
better to go slower to ensure that a single blocked consumer socket does
not block delivery to other consumers. |
public void setExclusiveConsumer(boolean exclusiveConsumer) {
this.exclusiveConsumer = exclusiveConsumer;
}
Enables or disables whether or not queue consumers should be exclusive or
not for example to preserve ordering when not using Message Groups |
public void setNestedMapAndListEnabled(boolean structuredMapsEnabled) {
this.nestedMapAndListEnabled = structuredMapsEnabled;
}
Enables/disables whether or not Message properties and MapMessage entries
support Nested
Structures of Map and List objects |
public void setObjectMessageSerializationDefered(boolean objectMessageSerializationDefered) {
this.objectMessageSerializationDefered = objectMessageSerializationDefered;
}
When an object is set on an ObjectMessage, the JMS spec requires the
object to be serialized by that set method. Enabling this flag causes the
object to not get serialized. The object may subsequently get serialized
if the message needs to be sent over a socket or stored to disk. |
public void setOptimizeAcknowledge(boolean optimizeAcknowledge) {
this.optimizeAcknowledge = optimizeAcknowledge;
}
|
public void setOptimizedMessageDispatch(boolean optimizedMessageDispatch) {
this.optimizedMessageDispatch = optimizedMessageDispatch;
}
If this flag is set then an larger prefetch limit is used - only
applicable for durable topic subscribers. |
public void setPassword(String password) {
this.password = password;
}
Sets the JMS password used for connections created from this factory |
public void setPrefetchPolicy(ActiveMQPrefetchPolicy prefetchPolicy) {
this.prefetchPolicy = prefetchPolicy;
}
|
public synchronized void setProducerWindowSize(int producerWindowSize) {
this.producerWindowSize = producerWindowSize;
}
|
public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy) {
this.redeliveryPolicy = redeliveryPolicy;
}
Sets the global redelivery policy to be used when a message is delivered
but the session is rolled back |
public void setSendTimeout(int sendTimeout) {
this.sendTimeout = sendTimeout;
}
|
public void setStatsEnabled(boolean statsEnabled) {
this.factoryStats.setEnabled(statsEnabled);
}
|
public void setTransformer(MessageTransformer transformer) {
this.transformer = transformer;
}
Sets the transformer used to transform messages before they are sent on
to the JMS bus or when they are received from the bus but before they are
delivered to the JMS client |
public void setTransportListener(TransportListener transportListener) {
this.transportListener = transportListener;
}
Allows a listener to be configured on the ConnectionFactory so that when this factory is used
with frameworks which don't expose the Connection such as Spring JmsTemplate, you can still register
a transport listener. |
public void setUseAsyncSend(boolean useAsyncSend) {
this.useAsyncSend = useAsyncSend;
}
Forces the use of Async Sends which
adds a massive performance boost; but means that the send() method will
return immediately whether the message has been sent or not which could
lead to message loss. |
public void setUseCompression(boolean useCompression) {
this.useCompression = useCompression;
}
Enables the use of compression of the message bodies |
public void setUseRetroactiveConsumer(boolean useRetroactiveConsumer) {
this.useRetroactiveConsumer = useRetroactiveConsumer;
}
Sets whether or not retroactive consumers are enabled. Retroactive
consumers allow non-durable topic subscribers to receive old messages
that were published before the non-durable subscriber started. |
public void setUserName(String userName) {
this.userName = userName;
}
Sets the JMS userName used by connections created by this factory |
public void setWarnAboutUnstartedConnectionTimeout(long warnAboutUnstartedConnectionTimeout) {
this.warnAboutUnstartedConnectionTimeout = warnAboutUnstartedConnectionTimeout;
}
Enables the timeout from a connection creation to when a warning is
generated if the connection is not properly started via
Connection#start() and a message is received by a consumer. It is
a very common gotcha to forget to start
the connection so this option makes the default case to create a
warning if the user forgets. To disable the warning just set the value to <
0 (say -1). |
public synchronized void setWatchTopicAdvisories(boolean watchTopicAdvisories) {
this.watchTopicAdvisories = watchTopicAdvisories;
}
|