[jboss-cvs] JBoss Messaging SVN: r6646 - in trunk: src/main/org/jboss/messaging/core/client and 42 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 1 13:43:26 EDT 2009
Author: timfox
Date: 2009-05-01 13:43:25 -0400 (Fri, 01 May 2009)
New Revision: 6646
Modified:
trunk/src/config/ra.xml
trunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java
trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptorFactory.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnectorFactory.java
trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
trunk/src/main/org/jboss/messaging/core/remoting/spi/AcceptorFactory.java
trunk/src/main/org/jboss/messaging/core/remoting/spi/ConnectorFactory.java
trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/jboss/messaging/integration/bootstrap/JBMBootstrapServer.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptorFactory.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnectorFactory.java
trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
trunk/src/main/org/jboss/messaging/ra/JBMBytesMessage.java
trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactory.java
trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactoryImpl.java
trunk/src/main/org/jboss/messaging/ra/JBMConnectionManager.java
trunk/src/main/org/jboss/messaging/ra/JBMConnectionMetaData.java
trunk/src/main/org/jboss/messaging/ra/JBMConnectionRequestInfo.java
trunk/src/main/org/jboss/messaging/ra/JBMCredential.java
trunk/src/main/org/jboss/messaging/ra/JBMLocalTransaction.java
trunk/src/main/org/jboss/messaging/ra/JBMMCFProperties.java
trunk/src/main/org/jboss/messaging/ra/JBMManagedConnection.java
trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java
trunk/src/main/org/jboss/messaging/ra/JBMMapMessage.java
trunk/src/main/org/jboss/messaging/ra/JBMMessage.java
trunk/src/main/org/jboss/messaging/ra/JBMMessageConsumer.java
trunk/src/main/org/jboss/messaging/ra/JBMMessageListener.java
trunk/src/main/org/jboss/messaging/ra/JBMMessageProducer.java
trunk/src/main/org/jboss/messaging/ra/JBMMetaData.java
trunk/src/main/org/jboss/messaging/ra/JBMObjectMessage.java
trunk/src/main/org/jboss/messaging/ra/JBMQueueReceiver.java
trunk/src/main/org/jboss/messaging/ra/JBMQueueSender.java
trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java
trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
trunk/src/main/org/jboss/messaging/ra/JBMSession.java
trunk/src/main/org/jboss/messaging/ra/JBMSessionFactory.java
trunk/src/main/org/jboss/messaging/ra/JBMSessionFactoryImpl.java
trunk/src/main/org/jboss/messaging/ra/JBMStreamMessage.java
trunk/src/main/org/jboss/messaging/ra/JBMTextMessage.java
trunk/src/main/org/jboss/messaging/ra/JBMTopicPublisher.java
trunk/src/main/org/jboss/messaging/ra/JBMTopicSubscriber.java
trunk/src/main/org/jboss/messaging/ra/JBMXAResource.java
trunk/src/main/org/jboss/messaging/ra/Util.java
trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java
trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivationSpec.java
trunk/src/main/org/jboss/messaging/ra/inflow/JBMMessageHandler.java
trunk/src/main/org/jboss/messaging/utils/JBMThreadFactory.java
trunk/src/main/org/jboss/messaging/utils/OrderedExecutorFactory.java
trunk/src/schemas/jbm-jms.xsd
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientAckBatchSizeTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionFactoryTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionSendAcknowledgementHandlerTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionStopStartTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/ConsumerWindowSizeTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/client/TemporaryQueueTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/CrashClient.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/ClusterTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ClusterWithBackupFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/PagingFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareQueueControlWrapperTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTestBase.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSQueueControlWrapperTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/connection/ExceptionListenerTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSQueueControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSUtil.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/NullInitialContext.java
trunk/tests/src/org/jboss/messaging/tests/integration/largemessage/mock/MockConnector.java
trunk/tests/src/org/jboss/messaging/tests/integration/largemessage/mock/MockConnectorFactory.java
trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
trunk/tests/src/org/jboss/messaging/tests/stress/remote/PingStressTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory1.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory2.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory3.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory1.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory2.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory3.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory4.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java
Log:
pool refactoring + session factory refactoring
Modified: trunk/src/config/ra.xml
===================================================================
--- trunk/src/config/ra.xml 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/config/ra.xml 2009-05-01 17:43:25 UTC (rev 6646)
@@ -157,8 +157,8 @@
<config-property-value></config-property-value>
</config-property>
<config-property>
- <description>The send window size</description>
- <config-property-name>SendWindowSize</config-property-name>
+ <description>The producer window size</description>
+ <config-property-name>ProducerWindowSize</config-property-name>
<config-property-type>java.lang.Integer</config-property-type>
<config-property-value></config-property-value>
</config-property>
Modified: trunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientSessionFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,7 +22,11 @@
package org.jboss.messaging.core.client;
+import java.util.List;
+
+import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.utils.Pair;
/**
* A ClientSessionFactory
@@ -42,56 +46,118 @@
int ackBatchSize) throws MessagingException;
ClientSession createSession(boolean xa, boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge) throws MessagingException;
+
+ List<Pair<TransportConfiguration, TransportConfiguration>> getStaticConnectors();
+
+ void setStaticConnectors(List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors);
+
+ long getPingPeriod();
- void setConsumerWindowSize(int size);
+ void setPingPeriod(long pingPeriod);
- int getConsumerWindowSize();
+ long getConnectionTTL();
- void setProducerWindowSize(int size);
+ void setConnectionTTL(long connectionTTL);
- int getProducerWindowSize();
+ long getCallTimeout();
- void setConsumerMaxRate(int rate);
+ void setCallTimeout(long callTimeout);
- int getConsumerMaxRate();
+ int getMaxConnections();
- void setProducerMaxRate(int rate);
+ void setMaxConnections(int maxConnections);
- int getProducerMaxRate();
-
int getMinLargeMessageSize();
-
+
void setMinLargeMessageSize(int minLargeMessageSize);
- boolean isBlockOnPersistentSend();
+ int getConsumerWindowSize();
- void setBlockOnPersistentSend(boolean blocking);
+ void setConsumerWindowSize(int consumerWindowSize);
- boolean isBlockOnNonPersistentSend();
+ int getConsumerMaxRate();
- void setBlockOnNonPersistentSend(boolean blocking);
+ void setConsumerMaxRate(int consumerMaxRate);
+ int getProducerWindowSize();
+
+ void setProducerWindowSize(int producerWindowSize);
+
+ int getProducerMaxRate();
+
+ void setProducerMaxRate(int producerMaxRate);
+
boolean isBlockOnAcknowledge();
- void setBlockOnAcknowledge(boolean blocking);
+ void setBlockOnAcknowledge(boolean blockOnAcknowledge);
+ boolean isBlockOnPersistentSend();
+
+ void setBlockOnPersistentSend(boolean blockOnPersistentSend);
+
+ boolean isBlockOnNonPersistentSend();
+
+ void setBlockOnNonPersistentSend(boolean blockOnNonPersistentSend);
+
boolean isAutoGroup();
void setAutoGroup(boolean autoGroup);
+ boolean isPreAcknowledge();
+
+ void setPreAcknowledge(boolean preAcknowledge);
+
int getAckBatchSize();
void setAckBatchSize(int ackBatchSize);
- boolean isPreAcknowledge();
+ long getInitialWaitTimeout();
- void setPreAcknowledge(boolean preAcknowledge);
+ void setInitialWaitTimeout(long initialWaitTimeout);
- long getPingPeriod();
+ boolean isUseGlobalPools();
- long getCallTimeout();
+ void setUseGlobalPools(boolean useGlobalPools);
- int getMaxConnections();
+ int getScheduledThreadPoolMaxSize();
+ void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize);
+
+ int getThreadPoolMaxSize();
+
+ void setThreadPoolMaxSize(int threadPoolMaxSize);
+
+ long getRetryInterval();
+
+ void setRetryInterval(long retryInterval);
+
+ double getRetryIntervalMultiplier();
+
+ void setRetryIntervalMultiplier(double retryIntervalMultiplier);
+
+ int getReconnectAttempts();
+
+ void setReconnectAttempts(int reconnectAttempts);
+
+ boolean isFailoverOnServerShutdown();
+
+ void setFailoverOnServerShutdown(boolean failoverOnServerShutdown);
+
+ String getLoadBalancingPolicyClassName();
+
+ void setLoadBalancingPolicyClassName(String loadBalancingPolicyClassName);
+
+ String getDiscoveryAddress();
+
+ void setDiscoveryAddress(String discoveryAddress);
+
+ int getDiscoveryPort();
+
+ void setDiscoveryPort(int discoveryPort);
+
+ long getDiscoveryRefreshTimeout();
+
+ void setDiscoveryRefreshTimeout(long discoveryRefreshTimeout);
+
void close();
}
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionFactoryImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -12,12 +12,18 @@
package org.jboss.messaging.core.client.impl;
import java.net.InetAddress;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
import org.jboss.messaging.core.client.ClientSession;
import org.jboss.messaging.core.client.ConnectionLoadBalancingPolicy;
@@ -26,9 +32,9 @@
import org.jboss.messaging.core.cluster.DiscoveryListener;
import org.jboss.messaging.core.cluster.impl.DiscoveryGroupImpl;
import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.utils.JBMThreadFactory;
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.UUIDGenerator;
@@ -51,7 +57,7 @@
public static final String DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME = "org.jboss.messaging.core.client.impl.RoundRobinConnectionLoadBalancingPolicy";
- public static final long DEFAULT_PING_PERIOD = 5000;
+ public static final long DEFAULT_PING_PERIOD = 1000000;
// 5 minutes - normally this should be much higher than ping period, this allows clients to re-attach on live
// or backup without fear of session having already been closed when connection times out.
@@ -86,6 +92,8 @@
public static final long DEFAULT_DISCOVERY_INITIAL_WAIT = 10000;
+ public static final long DEFAULT_DISCOVERY_REFRESH_TIMEOUT = 10000;
+
public static final long DEFAULT_RETRY_INTERVAL = 2000;
public static final double DEFAULT_RETRY_INTERVAL_MULTIPLIER = 1d;
@@ -94,639 +102,624 @@
public static final boolean DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN = false;
+ public static final boolean DEFAULT_USE_GLOBAL_POOLS = true;
+
+ public static final int DEFAULT_THREAD_POOL_MAX_SIZE = -1;
+
+ public static final int DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE = 1;
+
// Attributes
// -----------------------------------------------------------------------------------
private final Map<Pair<TransportConfiguration, TransportConfiguration>, ConnectionManager> connectionManagerMap = new LinkedHashMap<Pair<TransportConfiguration, TransportConfiguration>, ConnectionManager>();
+ private volatile boolean receivedBroadcast = false;
+
+ private ExecutorService threadPool;
+
+ private ScheduledExecutorService scheduledThreadPool;
+
+ private DiscoveryGroup discoveryGroup;
+
+ private ConnectionLoadBalancingPolicy loadBalancingPolicy;
+
private ConnectionManager[] connectionManagerArray;
- private final long pingPeriod;
+ private boolean readOnly;
- private final long connectionTTL;
+ // Settable attributes:
- private final long callTimeout;
+ private List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors;
- private final int maxConnections;
+ private String discoveryAddress;
- // Some of these attributes are mutable and can be updated by different threads so
- // must be volatile
+ private int discoveryPort;
- private volatile int minLargeMessageSize;
+ private long discoveryRefreshTimeout;
- private volatile int consumerWindowSize;
+ private long pingPeriod;
- private volatile int consumerMaxRate;
+ private long connectionTTL;
- private volatile int producerWindowSize;
+ private long callTimeout;
- private volatile int producerMaxRate;
+ private int maxConnections;
- private volatile boolean blockOnAcknowledge;
+ private int minLargeMessageSize;
- private volatile boolean blockOnPersistentSend;
+ private int consumerWindowSize;
- private volatile boolean blockOnNonPersistentSend;
+ private int consumerMaxRate;
- private volatile boolean autoGroup;
+ private int producerWindowSize;
+ private int producerMaxRate;
+
+ private boolean blockOnAcknowledge;
+
+ private boolean blockOnPersistentSend;
+
+ private boolean blockOnNonPersistentSend;
+
+ private boolean autoGroup;
+
private boolean preAcknowledge;
- private volatile int ackBatchSize;
+ private String loadBalancingPolicyClassName;
- private final ConnectionLoadBalancingPolicy loadBalancingPolicy;
+ private int ackBatchSize;
- private final DiscoveryGroup discoveryGroup;
+ private long initialWaitTimeout;
- private volatile boolean receivedBroadcast = false;
+ private boolean useGlobalPools;
- private final long initialWaitTimeout;
+ private int scheduledThreadPoolMaxSize;
- // Reconnect params
+ private int threadPoolMaxSize;
- private final long retryInterval;
+ private long retryInterval;
- private final double retryIntervalMultiplier; // For exponential backoff
+ private double retryIntervalMultiplier;
- private final int reconnectAttempts;
+ private int reconnectAttempts;
- private final boolean failoverOnServerShutdown;
+ private boolean failoverOnServerShutdown;
- // Static
- // ---------------------------------------------------------------------------------------
+ private static ExecutorService globalThreadPool;
- // Constructors
- // ---------------------------------------------------------------------------------
+ private static ScheduledExecutorService globalScheduledThreadPool;
- public ClientSessionFactoryImpl(final String discoveryGroupAddress, final int discoveryGroupPort) throws Exception
+ private static synchronized ExecutorService getGlobalThreadPool()
{
- this(discoveryGroupAddress,
- discoveryGroupPort,
- ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
- DEFAULT_DISCOVERY_INITIAL_WAIT);
+ if (globalThreadPool == null)
+ {
+ ThreadFactory factory = new JBMThreadFactory("JBM-client-global-threads", true);
+
+ globalThreadPool = Executors.newCachedThreadPool(factory);
+ }
+
+ return globalThreadPool;
}
- public ClientSessionFactoryImpl(final String discoveryGroupAddress,
- final int discoveryGroupPort,
- final long discoveryRefreshTimeout,
- final long initialWaitTimeout) throws Exception
+ private static synchronized ScheduledExecutorService getGlobalScheduledThreadPool()
{
- InetAddress groupAddress = InetAddress.getByName(discoveryGroupAddress);
+ if (globalScheduledThreadPool == null)
+ {
+ ThreadFactory factory = new JBMThreadFactory("JBM-client-global-scheduled-threads", true);
- discoveryGroup = new DiscoveryGroupImpl(UUIDGenerator.getInstance().generateStringUUID(),
- discoveryGroupAddress,
- groupAddress,
- discoveryGroupPort,
- discoveryRefreshTimeout);
+ globalScheduledThreadPool = Executors.newScheduledThreadPool(DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE, factory);
+ }
- discoveryGroup.registerListener(this);
+ return globalScheduledThreadPool;
+ }
- discoveryGroup.start();
+ private void setThreadPools()
+ {
+ if (useGlobalPools)
+ {
+ threadPool = getGlobalThreadPool();
- this.initialWaitTimeout = initialWaitTimeout;
- this.loadBalancingPolicy = instantiateLoadBalancingPolicy(DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME);
- this.pingPeriod = DEFAULT_PING_PERIOD;
- this.connectionTTL = DEFAULT_CONNECTION_TTL;
- this.callTimeout = DEFAULT_CALL_TIMEOUT;
- this.consumerWindowSize = DEFAULT_CONSUMER_WINDOW_SIZE;
- this.consumerMaxRate = DEFAULT_CONSUMER_MAX_RATE;
- this.producerWindowSize = DEFAULT_PRODUCER_WINDOW_SIZE;
- this.producerMaxRate = DEFAULT_PRODUCER_MAX_RATE;
- this.blockOnAcknowledge = DEFAULT_BLOCK_ON_ACKNOWLEDGE;
- this.blockOnNonPersistentSend = DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
- this.blockOnPersistentSend = DEFAULT_BLOCK_ON_PERSISTENT_SEND;
- this.minLargeMessageSize = DEFAULT_MIN_LARGE_MESSAGE_SIZE;
- this.autoGroup = DEFAULT_AUTO_GROUP;
- this.maxConnections = DEFAULT_MAX_CONNECTIONS;
- this.ackBatchSize = DEFAULT_ACK_BATCH_SIZE;
- this.preAcknowledge = DEFAULT_PRE_ACKNOWLEDGE;
- this.retryInterval = DEFAULT_RETRY_INTERVAL;
- this.retryIntervalMultiplier = DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.reconnectAttempts = DEFAULT_RECONNECT_ATTEMPTS;
- this.failoverOnServerShutdown = DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
+ scheduledThreadPool = getGlobalScheduledThreadPool();
+ }
+ else
+ {
+ ThreadFactory factory = new JBMThreadFactory("JBM-client-factory-threads-" + System.identityHashCode(this),
+ true);
+
+ if (threadPoolMaxSize == -1)
+ {
+ threadPool = Executors.newCachedThreadPool(factory);
+ }
+ else
+ {
+ threadPool = Executors.newFixedThreadPool(threadPoolMaxSize, factory);
+ }
+
+ factory = new JBMThreadFactory("JBM-client-factory-pinger-threads-" + System.identityHashCode(this), true);
+
+ scheduledThreadPool = Executors.newScheduledThreadPool(scheduledThreadPoolMaxSize, factory);
+ }
}
- public ClientSessionFactoryImpl(final String discoveryGroupAddress,
- final int discoveryGroupPort,
- final long discoveryRefreshTimeout,
- final long initialWaitTimeout,
- final String connectionloadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int producerWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final int ackBatchSize,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown) throws MessagingException
- {
- try
+ private void initialise() throws Exception
+ {
+ setThreadPools();
+
+ instantiateLoadBalancingPolicy();
+
+ if (discoveryAddress != null)
{
- InetAddress groupAddress = InetAddress.getByName(discoveryGroupAddress);
+ InetAddress groupAddress = InetAddress.getByName(discoveryAddress);
discoveryGroup = new DiscoveryGroupImpl(UUIDGenerator.getInstance().generateStringUUID(),
- discoveryGroupAddress,
+ discoveryAddress,
groupAddress,
- discoveryGroupPort,
+ discoveryPort,
discoveryRefreshTimeout);
discoveryGroup.registerListener(this);
discoveryGroup.start();
}
- catch (Exception e)
+ else if (staticConnectors != null)
{
- // TODO - handle exceptions better
- throw new MessagingException(MessagingException.NOT_CONNECTED, e.toString());
+ for (Pair<TransportConfiguration, TransportConfiguration> pair : staticConnectors)
+ {
+ ConnectionManager cm = new ConnectionManagerImpl(pair.a,
+ pair.b,
+ failoverOnServerShutdown,
+ maxConnections,
+ callTimeout,
+ pingPeriod,
+ connectionTTL,
+ retryInterval,
+ retryIntervalMultiplier,
+ reconnectAttempts,
+ threadPool,
+ scheduledThreadPool);
+
+ connectionManagerMap.put(pair, cm);
+ }
+
+ updateConnectionManagerArray();
}
-
- this.initialWaitTimeout = initialWaitTimeout;
- this.loadBalancingPolicy = instantiateLoadBalancingPolicy(connectionloadBalancingPolicyClassName);
- this.pingPeriod = pingPeriod;
- this.connectionTTL = connectionTTL;
- this.callTimeout = callTimeout;
- this.consumerWindowSize = consumerWindowSize;
- this.consumerMaxRate = consumerMaxRate;
- this.producerWindowSize = producerWindowSize;
- this.producerMaxRate = producerMaxRate;
- this.blockOnAcknowledge = blockOnAcknowledge;
- this.blockOnNonPersistentSend = blockOnNonPersistentSend;
- this.blockOnPersistentSend = blockOnPersistentSend;
- this.minLargeMessageSize = minLargeMessageSize;
- this.autoGroup = autoGroup;
- this.maxConnections = maxConnections;
- this.ackBatchSize = ackBatchSize;
- this.preAcknowledge = preAcknowledge;
- this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.reconnectAttempts = reconnectAttempts;
- this.failoverOnServerShutdown = failoverOnServerShutdown;
+ else
+ {
+ throw new IllegalStateException("Before using a session factory you must either set discovery address and port or " + "provide some static transport configuration");
+ }
}
- public ClientSessionFactoryImpl(final List<Pair<TransportConfiguration, TransportConfiguration>> connectors,
- final String connectionloadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int sendWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final int ackBatchSize,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown)
+ // Static
+ // ---------------------------------------------------------------------------------------
+
+ // Constructors
+ // ---------------------------------------------------------------------------------
+
+ public ClientSessionFactoryImpl()
{
- this.loadBalancingPolicy = instantiateLoadBalancingPolicy(connectionloadBalancingPolicyClassName);
- this.pingPeriod = pingPeriod;
- this.connectionTTL = connectionTTL;
- this.callTimeout = callTimeout;
- this.consumerWindowSize = consumerWindowSize;
- this.consumerMaxRate = consumerMaxRate;
- this.producerWindowSize = sendWindowSize;
- this.producerMaxRate = producerMaxRate;
- this.blockOnAcknowledge = blockOnAcknowledge;
- this.blockOnNonPersistentSend = blockOnNonPersistentSend;
- this.blockOnPersistentSend = blockOnPersistentSend;
- this.minLargeMessageSize = minLargeMessageSize;
- this.autoGroup = autoGroup;
- this.maxConnections = maxConnections;
- this.ackBatchSize = ackBatchSize;
- this.preAcknowledge = preAcknowledge;
- this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.reconnectAttempts = reconnectAttempts;
- this.failoverOnServerShutdown = failoverOnServerShutdown;
+ discoveryRefreshTimeout = DEFAULT_DISCOVERY_REFRESH_TIMEOUT;
- this.initialWaitTimeout = -1;
+ pingPeriod = DEFAULT_PING_PERIOD;
- for (Pair<TransportConfiguration, TransportConfiguration> pair : connectors)
- {
- ConnectionManager cm = new ConnectionManagerImpl(pair.a,
- pair.b,
- failoverOnServerShutdown,
- maxConnections,
- callTimeout,
- pingPeriod,
- connectionTTL,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts);
+ connectionTTL = DEFAULT_CONNECTION_TTL;
- connectionManagerMap.put(pair, cm);
- }
+ callTimeout = DEFAULT_CALL_TIMEOUT;
- updateConnectionManagerArray();
+ maxConnections = DEFAULT_MAX_CONNECTIONS;
- this.discoveryGroup = null;
+ minLargeMessageSize = DEFAULT_MIN_LARGE_MESSAGE_SIZE;
+
+ consumerWindowSize = DEFAULT_CONSUMER_WINDOW_SIZE;
+
+ consumerMaxRate = DEFAULT_CONSUMER_MAX_RATE;
+
+ producerWindowSize = DEFAULT_PRODUCER_WINDOW_SIZE;
+
+ producerMaxRate = DEFAULT_PRODUCER_MAX_RATE;
+
+ blockOnAcknowledge = DEFAULT_BLOCK_ON_ACKNOWLEDGE;
+
+ blockOnPersistentSend = DEFAULT_BLOCK_ON_PERSISTENT_SEND;
+
+ blockOnNonPersistentSend = DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
+
+ autoGroup = DEFAULT_AUTO_GROUP;
+
+ preAcknowledge = DEFAULT_PRE_ACKNOWLEDGE;
+
+ ackBatchSize = DEFAULT_ACK_BATCH_SIZE;
+
+ loadBalancingPolicyClassName = DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
+
+ initialWaitTimeout = DEFAULT_DISCOVERY_INITIAL_WAIT;
+
+ useGlobalPools = DEFAULT_USE_GLOBAL_POOLS;
+
+ scheduledThreadPoolMaxSize = DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
+
+ threadPoolMaxSize = DEFAULT_THREAD_POOL_MAX_SIZE;
+
+ retryInterval = DEFAULT_RETRY_INTERVAL;
+
+ retryIntervalMultiplier = DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+
+ reconnectAttempts = DEFAULT_RECONNECT_ATTEMPTS;
+
+ failoverOnServerShutdown = DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
}
- public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig,
- final TransportConfiguration backupConnectorConfig,
- final boolean failoverOnServerShutdown,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts)
+ public ClientSessionFactoryImpl(final String discoveryAddress, final int discoveryPort)
{
- this.loadBalancingPolicy = new FirstElementConnectionLoadBalancingPolicy();
- this.pingPeriod = DEFAULT_PING_PERIOD;
- this.connectionTTL = DEFAULT_CONNECTION_TTL;
- this.callTimeout = DEFAULT_CALL_TIMEOUT;
- this.consumerWindowSize = DEFAULT_CONSUMER_WINDOW_SIZE;
- this.consumerMaxRate = DEFAULT_CONSUMER_MAX_RATE;
- this.producerWindowSize = DEFAULT_PRODUCER_WINDOW_SIZE;
- this.producerMaxRate = DEFAULT_PRODUCER_MAX_RATE;
- this.blockOnAcknowledge = DEFAULT_BLOCK_ON_ACKNOWLEDGE;
- this.blockOnNonPersistentSend = DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
- this.blockOnPersistentSend = DEFAULT_BLOCK_ON_PERSISTENT_SEND;
- this.minLargeMessageSize = DEFAULT_MIN_LARGE_MESSAGE_SIZE;
- this.autoGroup = DEFAULT_AUTO_GROUP;
- this.maxConnections = DEFAULT_MAX_CONNECTIONS;
- this.ackBatchSize = DEFAULT_ACK_BATCH_SIZE;
- this.preAcknowledge = DEFAULT_PRE_ACKNOWLEDGE;
- this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.reconnectAttempts = reconnectAttempts;
- this.failoverOnServerShutdown = failoverOnServerShutdown;
+ this();
- this.initialWaitTimeout = -1;
+ this.discoveryAddress = discoveryAddress;
- Pair<TransportConfiguration, TransportConfiguration> pair = new Pair<TransportConfiguration, TransportConfiguration>(connectorConfig,
- backupConnectorConfig);
+ this.discoveryPort = discoveryPort;
+ }
- ConnectionManager cm = new ConnectionManagerImpl(pair.a,
- pair.b,
- failoverOnServerShutdown,
- maxConnections,
- callTimeout,
- pingPeriod,
- connectionTTL,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts);
+ public ClientSessionFactoryImpl(final List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors)
+ {
+ this();
- connectionManagerMap.put(pair, cm);
+ this.staticConnectors = staticConnectors;
+ }
- updateConnectionManagerArray();
+ public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig,
+ final TransportConfiguration backupConnectorConfig)
+ {
+ this();
+
+ staticConnectors = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
- discoveryGroup = null;
+ staticConnectors.add(new Pair<TransportConfiguration, TransportConfiguration>(connectorConfig, backupConnectorConfig));
}
- public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts)
+ public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig)
{
- this.loadBalancingPolicy = new FirstElementConnectionLoadBalancingPolicy();
- this.pingPeriod = DEFAULT_PING_PERIOD;
- this.connectionTTL = DEFAULT_CONNECTION_TTL;
- this.callTimeout = DEFAULT_CALL_TIMEOUT;
- this.consumerWindowSize = DEFAULT_CONSUMER_WINDOW_SIZE;
- this.consumerMaxRate = DEFAULT_CONSUMER_MAX_RATE;
- this.producerWindowSize = DEFAULT_PRODUCER_WINDOW_SIZE;
- this.producerMaxRate = DEFAULT_PRODUCER_MAX_RATE;
- this.blockOnAcknowledge = DEFAULT_BLOCK_ON_ACKNOWLEDGE;
- this.blockOnNonPersistentSend = DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
- this.blockOnPersistentSend = DEFAULT_BLOCK_ON_PERSISTENT_SEND;
- this.minLargeMessageSize = DEFAULT_MIN_LARGE_MESSAGE_SIZE;
- this.autoGroup = DEFAULT_AUTO_GROUP;
- this.maxConnections = DEFAULT_MAX_CONNECTIONS;
- this.ackBatchSize = DEFAULT_ACK_BATCH_SIZE;
- this.preAcknowledge = DEFAULT_PRE_ACKNOWLEDGE;
- this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.reconnectAttempts = reconnectAttempts;
- this.failoverOnServerShutdown = DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
+ this(connectorConfig, null);
+ }
- this.initialWaitTimeout = -1;
+ // ClientSessionFactory implementation------------------------------------------------------------
- Pair<TransportConfiguration, TransportConfiguration> pair = new Pair<TransportConfiguration, TransportConfiguration>(connectorConfig,
- null);
+ public synchronized List<Pair<TransportConfiguration, TransportConfiguration>> getStaticConnectors()
+ {
+ return staticConnectors;
+ }
- ConnectionManager cm = new ConnectionManagerImpl(pair.a,
- pair.b,
- failoverOnServerShutdown,
- maxConnections,
- callTimeout,
- pingPeriod,
- connectionTTL,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts);
+ public synchronized void setStaticConnectors(List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors)
+ {
+ checkWrite();
- connectionManagerMap.put(pair, cm);
+ this.staticConnectors = staticConnectors;
+ }
- updateConnectionManagerArray();
+ public synchronized long getPingPeriod()
+ {
+ return pingPeriod;
+ }
- discoveryGroup = null;
+ public synchronized void setPingPeriod(long pingPeriod)
+ {
+ checkWrite();
+ this.pingPeriod = pingPeriod;
}
- public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig,
- final TransportConfiguration backupConfig)
+ public synchronized long getConnectionTTL()
{
- this.loadBalancingPolicy = new FirstElementConnectionLoadBalancingPolicy();
- this.pingPeriod = DEFAULT_PING_PERIOD;
- this.callTimeout = DEFAULT_CALL_TIMEOUT;
- this.connectionTTL = DEFAULT_CONNECTION_TTL;
- this.consumerWindowSize = DEFAULT_CONSUMER_WINDOW_SIZE;
- this.consumerMaxRate = DEFAULT_CONSUMER_MAX_RATE;
- this.producerWindowSize = DEFAULT_PRODUCER_WINDOW_SIZE;
- this.producerMaxRate = DEFAULT_PRODUCER_MAX_RATE;
- this.blockOnAcknowledge = DEFAULT_BLOCK_ON_ACKNOWLEDGE;
- this.blockOnNonPersistentSend = DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
- this.blockOnPersistentSend = DEFAULT_BLOCK_ON_PERSISTENT_SEND;
- this.minLargeMessageSize = DEFAULT_MIN_LARGE_MESSAGE_SIZE;
- this.autoGroup = DEFAULT_AUTO_GROUP;
- this.maxConnections = DEFAULT_MAX_CONNECTIONS;
- this.ackBatchSize = DEFAULT_ACK_BATCH_SIZE;
- this.preAcknowledge = DEFAULT_PRE_ACKNOWLEDGE;
- this.retryInterval = DEFAULT_RETRY_INTERVAL;
- this.retryIntervalMultiplier = DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.reconnectAttempts = DEFAULT_RECONNECT_ATTEMPTS;
- this.failoverOnServerShutdown = DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
+ return connectionTTL;
+ }
- this.initialWaitTimeout = -1;
+ public synchronized void setConnectionTTL(long connectionTTL)
+ {
+ checkWrite();
+ this.connectionTTL = connectionTTL;
+ }
- Pair<TransportConfiguration, TransportConfiguration> pair = new Pair<TransportConfiguration, TransportConfiguration>(connectorConfig,
- backupConfig);
+ public synchronized long getCallTimeout()
+ {
+ return callTimeout;
+ }
- ConnectionManager cm = new ConnectionManagerImpl(pair.a,
- pair.b,
- failoverOnServerShutdown,
- maxConnections,
- callTimeout,
- pingPeriod,
- connectionTTL,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts);
+ public synchronized void setCallTimeout(long callTimeout)
+ {
+ checkWrite();
+ this.callTimeout = callTimeout;
+ }
- connectionManagerMap.put(pair, cm);
+ public synchronized int getMaxConnections()
+ {
+ return maxConnections;
+ }
- updateConnectionManagerArray();
+ public synchronized void setMaxConnections(int maxConnections)
+ {
+ checkWrite();
+ this.maxConnections = maxConnections;
+ }
- discoveryGroup = null;
+ public synchronized int getMinLargeMessageSize()
+ {
+ return minLargeMessageSize;
}
- public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig,
- final TransportConfiguration backupConfig,
- final boolean failoverOnServerShutdown,
- final String connectionloadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int sendWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final int ackBatchSize,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts)
+ public synchronized void setMinLargeMessageSize(int minLargeMessageSize)
{
- this.loadBalancingPolicy = instantiateLoadBalancingPolicy(connectionloadBalancingPolicyClassName);
- this.pingPeriod = pingPeriod;
- this.connectionTTL = connectionTTL;
- this.callTimeout = callTimeout;
+ checkWrite();
+ this.minLargeMessageSize = minLargeMessageSize;
+ }
+
+ public synchronized int getConsumerWindowSize()
+ {
+ return consumerWindowSize;
+ }
+
+ public synchronized void setConsumerWindowSize(int consumerWindowSize)
+ {
+ checkWrite();
this.consumerWindowSize = consumerWindowSize;
+ }
+
+ public synchronized int getConsumerMaxRate()
+ {
+ return consumerMaxRate;
+ }
+
+ public synchronized void setConsumerMaxRate(int consumerMaxRate)
+ {
+ checkWrite();
this.consumerMaxRate = consumerMaxRate;
- this.producerWindowSize = sendWindowSize;
+ }
+
+ public synchronized int getProducerWindowSize()
+ {
+ return producerWindowSize;
+ }
+
+ public synchronized void setProducerWindowSize(int producerWindowSize)
+ {
+ checkWrite();
+ this.producerWindowSize = producerWindowSize;
+ }
+
+ public synchronized int getProducerMaxRate()
+ {
+ return producerMaxRate;
+ }
+
+ public synchronized void setProducerMaxRate(int producerMaxRate)
+ {
+ checkWrite();
this.producerMaxRate = producerMaxRate;
+ }
+
+ public synchronized boolean isBlockOnAcknowledge()
+ {
+ return blockOnAcknowledge;
+ }
+
+ public synchronized void setBlockOnAcknowledge(boolean blockOnAcknowledge)
+ {
+ checkWrite();
this.blockOnAcknowledge = blockOnAcknowledge;
- this.blockOnNonPersistentSend = blockOnNonPersistentSend;
+ }
+
+ public synchronized boolean isBlockOnPersistentSend()
+ {
+ return blockOnPersistentSend;
+ }
+
+ public synchronized void setBlockOnPersistentSend(boolean blockOnPersistentSend)
+ {
+ checkWrite();
this.blockOnPersistentSend = blockOnPersistentSend;
- this.minLargeMessageSize = minLargeMessageSize;
- this.autoGroup = autoGroup;
- this.maxConnections = maxConnections;
- this.ackBatchSize = ackBatchSize;
- this.preAcknowledge = preAcknowledge;
- this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.reconnectAttempts = reconnectAttempts;
- this.failoverOnServerShutdown = failoverOnServerShutdown;
+ }
- this.initialWaitTimeout = -1;
+ public synchronized boolean isBlockOnNonPersistentSend()
+ {
+ return blockOnNonPersistentSend;
+ }
- Pair<TransportConfiguration, TransportConfiguration> pair = new Pair<TransportConfiguration, TransportConfiguration>(connectorConfig,
- backupConfig);
- ConnectionManager cm = new ConnectionManagerImpl(pair.a,
- pair.b,
- failoverOnServerShutdown,
- maxConnections,
- callTimeout,
- pingPeriod,
- connectionTTL,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts);
+ public synchronized void setBlockOnNonPersistentSend(boolean blockOnNonPersistentSend)
+ {
+ checkWrite();
+ this.blockOnNonPersistentSend = blockOnNonPersistentSend;
+ }
- connectionManagerMap.put(pair, cm);
+ public synchronized boolean isAutoGroup()
+ {
+ return autoGroup;
+ }
- updateConnectionManagerArray();
+ public synchronized void setAutoGroup(boolean autoGroup)
+ {
+ checkWrite();
+ this.autoGroup = autoGroup;
+ }
- discoveryGroup = null;
+ public synchronized boolean isPreAcknowledge()
+ {
+ return preAcknowledge;
}
- /**
- * Create a ClientSessionFactoryImpl specify transport type and using defaults
- */
- public ClientSessionFactoryImpl(final TransportConfiguration connectorConfig)
+ public synchronized void setPreAcknowledge(boolean preAcknowledge)
{
- this(connectorConfig,
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
+ checkWrite();
+ this.preAcknowledge = preAcknowledge;
}
- // ClientSessionFactory implementation------------------------------------------------------------
+ public synchronized int getAckBatchSize()
+ {
+ return ackBatchSize;
+ }
- public ClientSession createSession(final String username,
- final String password,
- final boolean xa,
- final boolean autoCommitSends,
- final boolean autoCommitAcks,
- final boolean preAcknowledge,
- final int ackBatchSize) throws MessagingException
+ public synchronized void setAckBatchSize(int ackBatchSize)
{
- return createSessionInternal(username,
- password,
- xa,
- autoCommitSends,
- autoCommitAcks,
- preAcknowledge,
- ackBatchSize);
+ checkWrite();
+ this.ackBatchSize = ackBatchSize;
}
- public ClientSession createSession(final boolean xa, final boolean autoCommitSends, final boolean autoCommitAcks) throws MessagingException
+ public synchronized long getInitialWaitTimeout()
{
- return createSessionInternal(null, null, xa, autoCommitSends, autoCommitAcks, preAcknowledge, this.ackBatchSize);
+ return initialWaitTimeout;
}
- public ClientSession createSession(final boolean xa,
- final boolean autoCommitSends,
- final boolean autoCommitAcks,
- final boolean preAcknowledge) throws MessagingException
+ public synchronized void setInitialWaitTimeout(long initialWaitTimeout)
{
- return createSessionInternal(null, null, xa, autoCommitSends, autoCommitAcks, preAcknowledge, this.ackBatchSize);
+ checkWrite();
+ this.initialWaitTimeout = initialWaitTimeout;
}
- public int getConsumerWindowSize()
+ public synchronized boolean isUseGlobalPools()
{
- return consumerWindowSize;
+ return useGlobalPools;
}
- public void setConsumerWindowSize(final int size)
+ public synchronized void setUseGlobalPools(boolean useGlobalPools)
{
- consumerWindowSize = size;
+ checkWrite();
+ this.useGlobalPools = useGlobalPools;
}
- public int getProducerWindowSize()
+ public synchronized int getScheduledThreadPoolMaxSize()
{
- return producerWindowSize;
+ return scheduledThreadPoolMaxSize;
}
- public void setProducerWindowSize(final int size)
+ public synchronized void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize)
{
- producerWindowSize = size;
+ checkWrite();
+ this.scheduledThreadPoolMaxSize = scheduledThreadPoolMaxSize;
}
- public int getProducerMaxRate()
+ public synchronized int getThreadPoolMaxSize()
{
- return producerMaxRate;
+ return threadPoolMaxSize;
}
- public void setProducerMaxRate(final int rate)
+ public synchronized void setThreadPoolMaxSize(int threadPoolMaxSize)
{
- producerMaxRate = rate;
+ checkWrite();
+ this.threadPoolMaxSize = threadPoolMaxSize;
}
- public int getConsumerMaxRate()
+ public synchronized long getRetryInterval()
{
- return consumerMaxRate;
+ return retryInterval;
}
- public void setConsumerMaxRate(final int rate)
+ public synchronized void setRetryInterval(long retryInterval)
{
- consumerMaxRate = rate;
+ checkWrite();
+ this.retryInterval = retryInterval;
}
- public boolean isBlockOnPersistentSend()
+ public synchronized double getRetryIntervalMultiplier()
{
- return blockOnPersistentSend;
+ return retryIntervalMultiplier;
}
- public void setBlockOnPersistentSend(final boolean blocking)
+ public synchronized void setRetryIntervalMultiplier(double retryIntervalMultiplier)
{
- blockOnPersistentSend = blocking;
+ checkWrite();
+ this.retryIntervalMultiplier = retryIntervalMultiplier;
}
- public boolean isBlockOnNonPersistentSend()
+ public synchronized int getReconnectAttempts()
{
- return blockOnNonPersistentSend;
+ return reconnectAttempts;
}
- public void setBlockOnNonPersistentSend(final boolean blocking)
+ public synchronized void setReconnectAttempts(int reconnectAttempts)
{
- blockOnNonPersistentSend = blocking;
+ checkWrite();
+ this.reconnectAttempts = reconnectAttempts;
}
- public boolean isBlockOnAcknowledge()
+ public synchronized boolean isFailoverOnServerShutdown()
{
- return blockOnAcknowledge;
+ return failoverOnServerShutdown;
}
- public void setBlockOnAcknowledge(final boolean blocking)
+ public synchronized void setFailoverOnServerShutdown(boolean failoverOnServerShutdown)
{
- blockOnAcknowledge = blocking;
+ checkWrite();
+ this.failoverOnServerShutdown = failoverOnServerShutdown;
}
- public boolean isAutoGroup()
+ public synchronized String getLoadBalancingPolicyClassName()
{
- return autoGroup;
+ return loadBalancingPolicyClassName;
}
- public void setAutoGroup(boolean autoGroup)
+ public synchronized void setLoadBalancingPolicyClassName(String loadBalancingPolicyClassName)
{
- this.autoGroup = autoGroup;
+ checkWrite();
+ this.loadBalancingPolicyClassName = loadBalancingPolicyClassName;
}
- public int getAckBatchSize()
+ public synchronized String getDiscoveryAddress()
{
- return ackBatchSize;
+ return discoveryAddress;
}
- public void setAckBatchSize(int ackBatchSize)
+ public synchronized void setDiscoveryAddress(String discoveryAddress)
{
- this.ackBatchSize = ackBatchSize;
+ checkWrite();
+ this.discoveryAddress = discoveryAddress;
}
- public boolean isPreAcknowledge()
+ public synchronized int getDiscoveryPort()
{
- return preAcknowledge;
+ return discoveryPort;
}
- public void setPreAcknowledge(boolean preAcknowledge)
+ public synchronized void setDiscoveryPort(int discoveryPort)
{
- this.preAcknowledge = preAcknowledge;
+ checkWrite();
+ this.discoveryPort = discoveryPort;
}
- public long getPingPeriod()
+ public synchronized long getDiscoveryRefreshTimeout()
{
- return pingPeriod;
+ return discoveryRefreshTimeout;
}
- public long getCallTimeout()
+ public synchronized void setDiscoveryRefreshTimeout(long discoveryRefreshTimeout)
{
- return callTimeout;
+ checkWrite();
+ this.discoveryRefreshTimeout = discoveryRefreshTimeout;
}
- public int getMaxConnections()
+ public ClientSession createSession(final String username,
+ final String password,
+ final boolean xa,
+ final boolean autoCommitSends,
+ final boolean autoCommitAcks,
+ final boolean preAcknowledge,
+ final int ackBatchSize) throws MessagingException
{
- return maxConnections;
+ return createSessionInternal(username,
+ password,
+ xa,
+ autoCommitSends,
+ autoCommitAcks,
+ preAcknowledge,
+ ackBatchSize);
}
- /**
- * @return the minLargeMessageSize
- */
- public int getMinLargeMessageSize()
+ public ClientSession createSession(final boolean xa,
+ final boolean autoCommitSends,
+ final boolean autoCommitAcks) throws MessagingException
{
- return minLargeMessageSize;
+ return createSessionInternal(null, null, xa, autoCommitSends, autoCommitAcks, preAcknowledge, this.ackBatchSize);
}
- /**
- * @param minLargeMessageSize the minLargeMessageSize to set
- */
- public void setMinLargeMessageSize(int minLargeMessageSize)
+ public ClientSession createSession(final boolean xa,
+ final boolean autoCommitSends,
+ final boolean autoCommitAcks,
+ final boolean preAcknowledge) throws MessagingException
{
- this.minLargeMessageSize = minLargeMessageSize;
+ return createSessionInternal(null, null, xa, autoCommitSends, autoCommitAcks, preAcknowledge, this.ackBatchSize);
}
public int numSessions()
@@ -773,6 +766,35 @@
}
connectionManagerMap.clear();
+
+ if (!useGlobalPools)
+ {
+ threadPool.shutdown();
+
+ try
+ {
+ if (!threadPool.awaitTermination(10000, TimeUnit.MILLISECONDS))
+ {
+ log.warn("Timed out waiting for pool to terminate");
+ }
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+
+ scheduledThreadPool.shutdown();
+
+ try
+ {
+ if (!scheduledThreadPool.awaitTermination(10000, TimeUnit.MILLISECONDS))
+ {
+ log.warn("Timed out waiting for scheduled pool to terminate");
+ }
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+ }
}
// DiscoveryListener implementation --------------------------------------------------------
@@ -780,7 +802,7 @@
public synchronized void connectorsChanged()
{
receivedBroadcast = true;
-
+
Map<String, DiscoveryEntry> newConnectors = discoveryGroup.getDiscoveryEntryMap();
Set<Pair<TransportConfiguration, TransportConfiguration>> connectorSet = new HashSet<Pair<TransportConfiguration, TransportConfiguration>>();
@@ -809,7 +831,7 @@
if (!connectionManagerMap.containsKey(connectorPair))
{
// Create a new ConnectionManager
-
+
ConnectionManager connectionManager = new ConnectionManagerImpl(connectorPair.a,
connectorPair.b,
failoverOnServerShutdown,
@@ -819,9 +841,11 @@
connectionTTL,
retryInterval,
retryIntervalMultiplier,
- reconnectAttempts);
+ reconnectAttempts,
+ threadPool,
+ scheduledThreadPool);
- connectionManagerMap.put(connectorPair, connectionManager);
+ connectionManagerMap.put(connectorPair, connectionManager);
}
}
@@ -840,6 +864,14 @@
// Private --------------------------------------------------------------------------------
+ private void checkWrite()
+ {
+ if (readOnly)
+ {
+ throw new IllegalStateException("Cannot set attribute on SessionFactory after it has been used");
+ }
+ }
+
private ClientSession createSessionInternal(final String username,
final String password,
final boolean xa,
@@ -848,6 +880,20 @@
final boolean preAcknowledge,
final int ackBatchSize) throws MessagingException
{
+ if (!readOnly)
+ {
+ try
+ {
+ initialise();
+ }
+ catch (Exception e)
+ {
+ throw new MessagingException(MessagingException.INTERNAL_ERROR, "Failed to initialise session factory", e);
+ }
+
+ readOnly = true;
+ }
+
if (discoveryGroup != null && !receivedBroadcast)
{
boolean ok = discoveryGroup.waitForBroadcast(initialWaitTimeout);
@@ -861,7 +907,6 @@
synchronized (this)
{
-
int pos = loadBalancingPolicy.select(connectionManagerArray.length);
ConnectionManager connectionManager = connectionManagerArray[pos];
@@ -878,28 +923,32 @@
autoGroup,
producerWindowSize,
consumerWindowSize,
+ producerMaxRate,
consumerMaxRate,
- producerMaxRate,
blockOnNonPersistentSend,
blockOnPersistentSend);
}
}
- private ConnectionLoadBalancingPolicy instantiateLoadBalancingPolicy(final String className)
+ private void instantiateLoadBalancingPolicy()
{
+ if (loadBalancingPolicyClassName == null)
+ {
+ throw new IllegalStateException("Please specify a load balancing policy class name on the session factory");
+ }
+
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- ConnectionLoadBalancingPolicy lbPolicy;
try
{
- Class<?> clazz = loader.loadClass(className);
- lbPolicy = (ConnectionLoadBalancingPolicy)clazz.newInstance();
+ Class<?> clazz = loader.loadClass(loadBalancingPolicyClassName);
+ loadBalancingPolicy = (ConnectionLoadBalancingPolicy)clazz.newInstance();
}
catch (Exception e)
{
- throw new IllegalArgumentException("Unable to instantiate load balancing policy \"" + className + "\"", e);
+ throw new IllegalArgumentException("Unable to instantiate load balancing policy \"" + loadBalancingPolicyClassName +
+ "\"",
+ e);
}
-
- return lbPolicy;
}
private void updateConnectionManagerArray()
@@ -908,5 +957,4 @@
connectionManagerMap.values().toArray(connectionManagerArray);
}
-
}
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientSessionImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -30,7 +30,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
@@ -83,7 +82,6 @@
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.utils.ConcurrentHashSet;
import org.jboss.messaging.utils.IDGenerator;
-import org.jboss.messaging.utils.OrderedExecutorFactory;
import org.jboss.messaging.utils.SimpleIDGenerator;
import org.jboss.messaging.utils.SimpleString;
import org.jboss.messaging.utils.TokenBucketLimiterImpl;
@@ -114,8 +112,6 @@
public static final int INITIAL_MESSAGE_BODY_SIZE = 1024;
- private static final org.jboss.messaging.utils.ExecutorFactory executorFactory = new OrderedExecutorFactory(Executors.newCachedThreadPool(new org.jboss.messaging.utils.JBMThreadFactory("jbm-client-session-threads")));
-
// Attributes ----------------------------------------------------------------------------
private final ConnectionManager connectionManager;
@@ -192,7 +188,8 @@
final int minLargeMessageSize,
final RemotingConnection remotingConnection,
final int version,
- final Channel channel) throws MessagingException
+ final Channel channel,
+ final Executor executor) throws MessagingException
{
this.connectionManager = connectionManager;
@@ -200,7 +197,7 @@
this.remotingConnection = remotingConnection;
- executor = executorFactory.getExecutor();
+ this.executor = executor;
this.xa = xa;
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManager.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -46,10 +46,10 @@
final int minLargeMessageSize,
final boolean blockOnAcknowledge,
final boolean autoGroup,
- final int sendWindowSize,
+ final int producerWindowSize,
final int consumerWindowSize,
+ final int producerMaxRate,
final int consumerMaxRate,
- final int producerMaxRate,
final boolean blockOnNonPersistentSend,
final boolean blockOnPersistentSend) throws MessagingException;
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ConnectionManagerImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -34,7 +34,8 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.locks.Lock;
import org.jboss.messaging.core.client.ClientSession;
@@ -56,6 +57,8 @@
import org.jboss.messaging.core.remoting.spi.ConnectorFactory;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.core.version.Version;
+import org.jboss.messaging.utils.ExecutorFactory;
+import org.jboss.messaging.utils.OrderedExecutorFactory;
import org.jboss.messaging.utils.UUIDGenerator;
import org.jboss.messaging.utils.VersionLoader;
@@ -110,26 +113,12 @@
private final Object failoverLock = new Object();
- private static ScheduledThreadPoolExecutor pingExecutor;
+ private final ExecutorFactory orderedExecutorFactory;
+
+ private final ExecutorService threadPool;
+
+ private final ScheduledExecutorService scheduledThreadPool;
- static
- {
- recreatePingExecutor();
- }
-
- public static void recreatePingExecutor()
- {
- if (pingExecutor != null)
- {
- pingExecutor.shutdown();
- }
-
- // TODO - allow this to be configurable
- pingExecutor = new ScheduledThreadPoolExecutor(5,
- new org.jboss.messaging.utils.JBMThreadFactory("jbm-pinger-threads"));
-
- }
-
private final Map<Object, ConnectionEntry> connections = Collections.synchronizedMap(new LinkedHashMap<Object, ConnectionEntry>());
private int refCount;
@@ -178,7 +167,9 @@
final long connectionTTL,
final long retryInterval,
final double retryIntervalMultiplier,
- final int reconnectAttempts)
+ final int reconnectAttempts,
+ final ExecutorService threadPool,
+ final ScheduledExecutorService scheduledThreadPool)
{
this.connectorConfig = connectorConfig;
@@ -216,9 +207,15 @@
this.retryIntervalMultiplier = retryIntervalMultiplier;
this.reconnectAttempts = reconnectAttempts;
+
+ this.scheduledThreadPool = scheduledThreadPool;
+
+ this.threadPool = threadPool;
+
+ this.orderedExecutorFactory = new OrderedExecutorFactory(threadPool);
}
- // ConnectionLifeCycleListener implementation --------------------
+ // ConnectionLifeCycleListener implementation --------------------------------------------------
public void connectionCreated(final Connection connection)
{
@@ -233,7 +230,7 @@
{
failConnection(connectionID, me);
}
-
+
// ConnectionManager implementation ------------------------------------------------------------------
public ClientSession createSession(final String username,
@@ -246,10 +243,10 @@
final int minLargeMessageSize,
final boolean blockOnAcknowledge,
final boolean autoGroup,
- final int sendWindowSize,
+ final int producerWindowSize,
final int consumerWindowSize,
- final int consumerMaxRate,
final int producerMaxRate,
+ final int consumerMaxRate,
final boolean blockOnNonPersistentSend,
final boolean blockOnPersistentSend) throws MessagingException
{
@@ -308,7 +305,7 @@
autoCommitSends,
autoCommitAcks,
preAcknowledge,
- sendWindowSize);
+ producerWindowSize);
Packet pResponse = channel1.sendBlocking(request);
@@ -327,7 +324,7 @@
{
CreateSessionResponseMessage response = (CreateSessionResponseMessage)pResponse;
- Channel sessionChannel = connection.getChannel(sessionChannelID, sendWindowSize, sendWindowSize != -1);
+ Channel sessionChannel = connection.getChannel(sessionChannelID, producerWindowSize, producerWindowSize != -1);
ClientSessionInternal session = new ClientSessionImpl(this,
name,
@@ -346,7 +343,8 @@
minLargeMessageSize,
connection,
response.getServerVersion(),
- sessionChannel);
+ sessionChannel,
+ orderedExecutorFactory.getExecutor());
sessions.put(session, connection);
@@ -507,7 +505,7 @@
boolean attemptFailover = (backupConnectorFactory) != null && (failoverOnServerShutdown || me.getCode() != MessagingException.SERVER_DISCONNECTED);
boolean done = false;
-
+
if (attemptFailover || reconnectAttempts != 0)
{
lockAllChannel1s();
@@ -815,18 +813,16 @@
if (connections.size() < maxConnections)
{
// Create a new one
-
- DelegatingBufferHandler handler = new DelegatingBufferHandler();
-
- Connector connector = null;
-
+
Connection tc = null;
try
{
if (connector == null)
- {
- connector = connectorFactory.createConnector(transportParams, handler, this);
+ {
+ DelegatingBufferHandler handler = new DelegatingBufferHandler();
+
+ connector = connectorFactory.createConnector(transportParams, handler, this, threadPool);
if (connector != null)
{
@@ -891,12 +887,10 @@
return null;
}
- conn = new RemotingConnectionImpl(tc, callTimeout, pingPeriod, connectionTTL, pingExecutor, null);
+ conn = new RemotingConnectionImpl(tc, callTimeout, pingPeriod, connectionTTL, scheduledThreadPool, threadPool, null);
conn.addFailureListener(new DelegatingFailureListener(conn.getID()));
- handler.conn = conn;
-
conn.startPinger();
connections.put(conn.getID(), new ConnectionEntry(conn, connector));
@@ -1034,12 +1028,15 @@
}
private class DelegatingBufferHandler extends AbstractBufferHandler
- {
- RemotingConnection conn;
-
+ {
public void bufferReceived(final Object connectionID, final MessagingBuffer buffer)
{
- conn.bufferReceived(connectionID, buffer);
+ ConnectionEntry entry = connections.get(connectionID);
+
+ if (entry != null)
+ {
+ entry.connection.bufferReceived(connectionID, buffer);
+ }
}
}
Modified: trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -48,15 +48,15 @@
public static final boolean DEFAULT_BACKUP = false;
public static final boolean DEFAULT_ENABLE_FILE_DEPLOYMENT = false;
-
+
public static final boolean DEFAULT_ENABLE_PERSISTENCE = true;
public static final long DEFAULT_FILE_DEPLOYER_SCAN_PERIOD = 5000;
public static final long DEFAULT_QUEUE_ACTIVATION_TIMEOUT = 30000;
- public static final int DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE = 10;
-
+ public static final int DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE = 5;
+
public static final int DEFAULT_THREAD_POOL_MAX_SIZE = -1;
public static final long DEFAULT_SECURITY_INVALIDATION_INTERVAL = 10000;
@@ -106,9 +106,9 @@
public static final boolean DEFAULT_MESSAGE_COUNTER_ENABLED = false;
public static final long DEFAULT_MESSAGE_COUNTER_SAMPLE_PERIOD = 10000;
-
+
public static final int DEFAULT_MESSAGE_COUNTER_MAX_DAY_HISTORY = 10;
-
+
public static final long DEFAULT_TRANSACTION_TIMEOUT = 60000;
public static final long DEFAULT_TRANSACTION_TIMEOUT_SCAN_PERIOD = 1000;
@@ -150,7 +150,7 @@
protected boolean backup = DEFAULT_BACKUP;
protected boolean enableFileDeployment = DEFAULT_ENABLE_FILE_DEPLOYMENT;
-
+
protected boolean enablePersistence = DEFAULT_ENABLE_PERSISTENCE;
protected long fileDeploymentScanPeriod = DEFAULT_FILE_DEPLOYER_SCAN_PERIOD;
@@ -160,7 +160,7 @@
protected long queueActivationTimeout = DEFAULT_QUEUE_ACTIVATION_TIMEOUT;
protected int scheduledThreadPoolMaxSize = DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
-
+
protected int threadPoolMaxSize = DEFAULT_THREAD_POOL_MAX_SIZE;
protected long securityInvalidationInterval = DEFAULT_SECURITY_INVALIDATION_INTERVAL;
@@ -242,7 +242,7 @@
protected long messageCounterSamplePeriod = DEFAULT_MESSAGE_COUNTER_SAMPLE_PERIOD;
protected int messageCounterMaxDayHistory = DEFAULT_MESSAGE_COUNTER_MAX_DAY_HISTORY;
-
+
protected long transactionTimeout = DEFAULT_TRANSACTION_TIMEOUT;
protected long transactionTimeoutScanPeriod = DEFAULT_TRANSACTION_TIMEOUT_SCAN_PERIOD;
@@ -296,17 +296,17 @@
{
enableFileDeployment = enable;
}
-
+
public boolean isEnablePersistence()
{
return this.enablePersistence;
}
-
+
public void setEnablePersistence(boolean enable)
{
this.enablePersistence = enable;
}
-
+
public long getFileDeployerScanPeriod()
{
return fileDeploymentScanPeriod;
@@ -357,7 +357,7 @@
{
scheduledThreadPoolMaxSize = maxSize;
}
-
+
public int getThreadPoolMaxSize()
{
return threadPoolMaxSize;
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -563,7 +563,7 @@
messageCounterManager.clear();
- replicationInvoker.stop();
+ // replicationInvoker.stop();
started = false;
}
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -499,18 +499,7 @@
if (running)
{
running = false;
-
- org.jboss.messaging.utils.Future future = new Future();
-
- executor.execute(future);
-
- boolean ok = future.await(10000);
-
- if (!ok)
- {
- log.warn("Timed out waiting for depage executor on destination " + storeName + " to stop");
- }
-
+
if (currentPage != null)
{
currentPage.close();
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/RemotingConnectionImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -12,22 +12,6 @@
package org.jboss.messaging.core.remoting.impl;
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.Channel;
-import org.jboss.messaging.core.remoting.ChannelHandler;
-import org.jboss.messaging.core.remoting.CloseListener;
-import org.jboss.messaging.core.remoting.CommandConfirmationHandler;
-import org.jboss.messaging.core.remoting.FailureListener;
-import org.jboss.messaging.core.remoting.Interceptor;
-import org.jboss.messaging.core.remoting.Packet;
-import org.jboss.messaging.core.remoting.RemotingConnection;
-import org.jboss.messaging.core.remoting.impl.wireformat.CreateQueueMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.NullResponseMessage;
-import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATESESSION;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATESESSION_RESP;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.CREATE_QUEUE;
@@ -87,6 +71,39 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_XA_SET_TIMEOUT_RESP;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_XA_START;
import static org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl.SESS_XA_SUSPEND;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.Channel;
+import org.jboss.messaging.core.remoting.ChannelHandler;
+import org.jboss.messaging.core.remoting.CloseListener;
+import org.jboss.messaging.core.remoting.CommandConfirmationHandler;
+import org.jboss.messaging.core.remoting.FailureListener;
+import org.jboss.messaging.core.remoting.Interceptor;
+import org.jboss.messaging.core.remoting.Packet;
+import org.jboss.messaging.core.remoting.RemotingConnection;
+import org.jboss.messaging.core.remoting.impl.wireformat.CreateQueueMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.CreateSessionResponseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.NullResponseMessage;
+import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
import org.jboss.messaging.core.remoting.impl.wireformat.PacketsConfirmedMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
@@ -139,21 +156,6 @@
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
import org.jboss.messaging.utils.SimpleIDGenerator;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
/**
* @author <a href="tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -175,11 +177,12 @@
final long pingInterval,
final long connectionTTL,
final ScheduledExecutorService pingExecutor,
+ final Executor threadPool,
final ConnectionLifeCycleListener listener)
{
DelegatingBufferHandler handler = new DelegatingBufferHandler();
- Connector connector = connectorFactory.createConnector(params, handler, listener);
+ Connector connector = connectorFactory.createConnector(params, handler, listener, threadPool);
if (connector == null)
{
@@ -200,6 +203,7 @@
pingInterval,
connectionTTL,
pingExecutor,
+ threadPool,
null);
handler.conn = connection;
@@ -258,6 +262,8 @@
private final long connectionTTL;
private final ScheduledExecutorService pingExecutor;
+
+ private final Executor threadPool;
// Channels 0-9 are reserved for the system
// 0 is for pinging
@@ -290,9 +296,10 @@
final long pingPeriod,
final long connectionTTL,
final ScheduledExecutorService pingExecutor,
+ final Executor threadPool,
final List<Interceptor> interceptors)
{
- this(transportConnection, blockingCallTimeout, pingPeriod, connectionTTL, pingExecutor, interceptors, true, true);
+ this(transportConnection, blockingCallTimeout, pingPeriod, connectionTTL, pingExecutor, threadPool, interceptors, true, true);
}
/*
@@ -301,10 +308,11 @@
public RemotingConnectionImpl(final Connection transportConnection,
final List<Interceptor> interceptors,
final boolean active,
- final long connectionTTL)
+ final long connectionTTL,
+ final Executor threadPool)
{
- this(transportConnection, -1, -1, connectionTTL, null, interceptors, active, false);
+ this(transportConnection, -1, -1, connectionTTL, null, threadPool, interceptors, active, false);
}
private RemotingConnectionImpl(final Connection transportConnection,
@@ -312,6 +320,7 @@
final long pingPeriod,
final long connectionTTL,
final ScheduledExecutorService pingExecutor,
+ final Executor threadPool,
final List<Interceptor> interceptors,
final boolean active,
final boolean client)
@@ -330,6 +339,8 @@
this.connectionTTL = connectionTTL;
this.pingExecutor = pingExecutor;
+
+ this.threadPool = threadPool;
// Channel zero is reserved for pinging
pingChannel = getChannel(0, -1, false);
@@ -1110,7 +1121,7 @@
}
if (connection.active || packet.isWriteAlways())
- {
+ {
connection.transportConnection.write(buffer, flush);
}
}
@@ -1181,6 +1192,7 @@
connection.transportConnection.write(buffer);
+
long toWait = connection.blockingCallTimeout;
long start = System.currentTimeMillis();
@@ -1188,7 +1200,7 @@
while (response == null && toWait > 0)
{
try
- {
+ {
sendCondition.await(toWait, TimeUnit.MILLISECONDS);
}
catch (InterruptedException e)
@@ -1199,7 +1211,7 @@
{
break;
}
-
+
final long now = System.currentTimeMillis();
toWait -= now - start;
@@ -1594,7 +1606,7 @@
confirm(packet);
lock.lock();
-
+
try
{
sendCondition.signal();
@@ -1683,21 +1695,29 @@
// Error - didn't get pong back
final MessagingException me = new MessagingException(MessagingException.NOT_CONNECTED,
"Did not receive pong from server");
-
future.cancel(true);
- fail(me);
+ //Need to call fail on a different thread otherwise can prevent other pings occurring
+ threadPool.execute(new Runnable()
+ {
+ public void run()
+ {
+ fail(me);
+ }
+ });
}
-
- gotPong = false;
-
- firstTime = false;
-
- // Send ping
-
- final Packet ping = new Ping(connectionTTL);
-
- pingChannel.send(ping);
+ else
+ {
+ gotPong = false;
+
+ firstTime = false;
+
+ // Send ping
+
+ final Packet ping = new Ping(connectionTTL);
+
+ pingChannel.send(ping);
+ }
}
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptor.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -24,6 +24,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
@@ -32,6 +33,8 @@
import org.jboss.messaging.core.remoting.spi.Connection;
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
import org.jboss.messaging.utils.ConfigurationHelper;
+import org.jboss.messaging.utils.ExecutorFactory;
+import org.jboss.messaging.utils.OrderedExecutorFactory;
/**
* A InVMAcceptor
@@ -54,16 +57,21 @@
private volatile boolean started;
private boolean paused;
+
+ private final ExecutorFactory executorFactory;
public InVMAcceptor(final Map<String, Object> configuration,
final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
+ final ConnectionLifeCycleListener listener,
+ final Executor threadPool)
{
this.handler = handler;
this.listener = listener;
this.id = ConfigurationHelper.getIntProperty(TransportConstants.SERVER_ID_PROP_NAME, 0, configuration);
+
+ this.executorFactory = new OrderedExecutorFactory(threadPool);
}
public synchronized void start() throws Exception
@@ -148,15 +156,21 @@
return handler;
}
+
+ public ExecutorFactory getExecutorFactory()
+ {
+ return this.executorFactory;
+ }
- public void connect(final String connectionID, final BufferHandler remoteHandler, final InVMConnector connector)
+ public void connect(final String connectionID, final BufferHandler remoteHandler, final InVMConnector connector,
+ final Executor clientExecutor)
{
if (!started)
{
throw new IllegalStateException("Acceptor is not started");
}
- new InVMConnection(id, connectionID, remoteHandler, new Listener(connector));
+ new InVMConnection(id, connectionID, remoteHandler, new Listener(connector), clientExecutor);
}
public void disconnect(final String connectionID)
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptorFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptorFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMAcceptorFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,7 @@
package org.jboss.messaging.core.remoting.impl.invm;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -38,9 +39,10 @@
{
public Acceptor createAcceptor(final Map<String, Object> configuration,
- final BufferHandler handler, final ConnectionLifeCycleListener listener)
+ final BufferHandler handler, final ConnectionLifeCycleListener listener,
+ final Executor threadPool)
{
- return new InVMAcceptor(configuration, handler, listener);
+ return new InVMAcceptor(configuration, handler, listener, threadPool);
}
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnection.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,7 +22,7 @@
package org.jboss.messaging.core.remoting.impl.invm;
import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
+import java.util.concurrent.RejectedExecutionException;
import org.jboss.messaging.core.buffers.ChannelBuffers;
import org.jboss.messaging.core.exception.MessagingException;
@@ -31,9 +31,6 @@
import org.jboss.messaging.core.remoting.spi.Connection;
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
import org.jboss.messaging.core.remoting.spi.MessagingBuffer;
-import org.jboss.messaging.utils.ExecutorFactory;
-import org.jboss.messaging.utils.JBMThreadFactory;
-import org.jboss.messaging.utils.OrderedExecutorFactory;
import org.jboss.messaging.utils.UUIDGenerator;
/**
@@ -53,30 +50,34 @@
private final String id;
private boolean closed;
-
+
private final int serverID;
- private static final ExecutorFactory factory =
- new OrderedExecutorFactory(Executors.newCachedThreadPool(new JBMThreadFactory("JBM-InVM-Transport-Threads")));
-
private final Executor executor;
- public InVMConnection(final int serverID, final BufferHandler handler, final ConnectionLifeCycleListener listener)
- {
- this(serverID, UUIDGenerator.getInstance().generateSimpleStringUUID().toString(), handler, listener);
+ public InVMConnection(final int serverID,
+ final BufferHandler handler,
+ final ConnectionLifeCycleListener listener,
+ final Executor executor)
+ {
+ this(serverID, UUIDGenerator.getInstance().generateSimpleStringUUID().toString(), handler, listener, executor);
}
- public InVMConnection(final int serverID, final String id, final BufferHandler handler, final ConnectionLifeCycleListener listener)
+ public InVMConnection(final int serverID,
+ final String id,
+ final BufferHandler handler,
+ final ConnectionLifeCycleListener listener,
+ final Executor executor)
{
this.serverID = serverID;
-
+
this.handler = handler;
this.listener = listener;
this.id = id;
- executor = factory.getExecutor();
+ this.executor = executor;
listener.connectionCreated(this);
}
@@ -87,27 +88,34 @@
{
return;
}
-
- //Must execute this on the executor, to ensure connection destroyed doesn't get fired before the last DISCONNECT
- //packet is processed
-
- executor.execute(new Runnable()
+
+ // Must execute this on the executor, to ensure connection destroyed doesn't get fired before the last DISCONNECT
+ // packet is processed
+
+ try
{
- public void run()
+ executor.execute(new Runnable()
{
- if (!closed)
+ public void run()
{
- listener.connectionDestroyed(id);
+ if (!closed)
+ {
+ listener.connectionDestroyed(id);
- closed = true;
+ closed = true;
+ }
}
- }
- });
+ });
+ }
+ catch (RejectedExecutionException e)
+ {
+ // Ignore - this can happen if server/client is shutdown
+ }
}
public MessagingBuffer createBuffer(final int size)
{
- return ChannelBuffers.buffer(size);
+ return ChannelBuffers.buffer(size);
}
public Object getID()
@@ -116,44 +124,50 @@
}
public void write(final MessagingBuffer buffer)
- {
+ {
write(buffer, false);
}
-
+
public void write(final MessagingBuffer buffer, final boolean flush)
- {
- executor.execute(new Runnable()
+ {
+ try
{
- public void run()
+ executor.execute(new Runnable()
{
- try
+ public void run()
{
- if (!closed)
+ try
{
- buffer.readInt(); // read and discard
-
- handler.bufferReceived(id, buffer);
- }
+ if (!closed)
+ {
+ buffer.readInt(); // read and discard
+
+ handler.bufferReceived(id, buffer);
+ }
+ }
+ catch (Exception e)
+ {
+ final String msg = "Failed to write to handler";
+ log.error(msg, e);
+ throw new IllegalStateException(msg, e);
+ }
}
- catch (Exception e)
- {
- final String msg = "Failed to write to handler";
- log.error(msg, e);
- throw new IllegalStateException(msg, e);
- }
- }
- });
-
+ });
+ }
+ catch (RejectedExecutionException e)
+ {
+ // Ignore - this can happen if server/client is shutdown and another request comes in
+ }
}
public String getRemoteAddress()
{
return "invm:" + serverID;
}
-
+
public void fail(final MessagingException me)
{
listener.connectionException(id, me);
}
-
+
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnector.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -24,6 +24,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
@@ -33,6 +34,7 @@
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
import org.jboss.messaging.core.remoting.spi.Connector;
import org.jboss.messaging.utils.ConfigurationHelper;
+import org.jboss.messaging.utils.OrderedExecutorFactory;
/**
* A InVMConnector
@@ -79,9 +81,12 @@
private volatile boolean started;
+ protected final OrderedExecutorFactory executorFactory;
+
public InVMConnector(final Map<String, Object> configuration,
final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
+ final ConnectionLifeCycleListener listener,
+ final Executor threadPool)
{
this.listener = listener;
@@ -89,6 +94,8 @@
this.handler = handler;
+ this.executorFactory = new OrderedExecutorFactory(threadPool);
+
InVMRegistry registry = InVMRegistry.instance;
acceptor = registry.getAcceptor(id);
@@ -128,9 +135,9 @@
return null;
}
- Connection conn = internalCreateConnection(acceptor.getHandler(), new Listener());
+ Connection conn = internalCreateConnection(acceptor.getHandler(), new Listener(), acceptor.getExecutorFactory().getExecutor());
- acceptor.connect((String)conn.getID(), handler, this);
+ acceptor.connect((String)conn.getID(), handler, this, executorFactory.getExecutor());
return conn;
}
@@ -161,9 +168,11 @@
}
// This may be an injection point for mocks on tests
- protected Connection internalCreateConnection(final BufferHandler handler, final ConnectionLifeCycleListener listener)
+ protected Connection internalCreateConnection(final BufferHandler handler,
+ final ConnectionLifeCycleListener listener,
+ final Executor serverExecutor)
{
- return new InVMConnection(id, handler, listener);
+ return new InVMConnection(id, handler, listener, serverExecutor);
}
private class Listener implements ConnectionLifeCycleListener
@@ -179,10 +188,10 @@
}
public void connectionDestroyed(final Object connectionID)
- {
+ {
if (connections.remove(connectionID) != null)
- {
- //Execute on different thread to avoid deadlocks
+ {
+ // Execute on different thread to avoid deadlocks
new Thread()
{
public void run()
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnectorFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnectorFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/invm/InVMConnectorFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,7 @@
package org.jboss.messaging.core.remoting.impl.invm;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.BufferHandler;
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
@@ -38,9 +39,10 @@
{
public Connector createConnector(final Map<String, Object> configuration,
final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
+ final ConnectionLifeCycleListener listener,
+ final Executor threadPool)
{
- InVMConnector connector = new InVMConnector(configuration, handler, listener);
+ InVMConnector connector = new InVMConnector(configuration, handler, listener, threadPool);
if (connector.getAcceptor() == null)
{
Modified: trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/remoting/server/impl/RemotingServiceImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -23,6 +23,7 @@
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
@@ -85,12 +86,14 @@
private volatile RemotingConnection serverSideReplicatingConnection;
-
+ private final Executor threadPool;
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
- public RemotingServiceImpl(final Configuration config, final MessagingServer server, final ManagementService managementService)
+ public RemotingServiceImpl(final Configuration config, final MessagingServer server, final ManagementService managementService,
+ final Executor threadPool)
{
transportConfigs = config.getAcceptorConfigurations();
@@ -111,6 +114,7 @@
this.config = config;
this.server = server;
this.managementService = managementService;
+ this.threadPool = threadPool;
}
// RemotingService implementation -------------------------------
@@ -152,7 +156,7 @@
AcceptorFactory factory = (AcceptorFactory)clazz.newInstance();
- Acceptor acceptor = factory.createAcceptor(info.getParams(), bufferHandler, this);
+ Acceptor acceptor = factory.createAcceptor(info.getParams(), bufferHandler, this, threadPool);
acceptors.add(acceptor);
@@ -266,7 +270,8 @@
throw new IllegalStateException("Unable to create connection, server hasn't finished starting up");
}
- RemotingConnection rc = new RemotingConnectionImpl(connection, interceptors, !config.isBackup(), config.getConnectionTTLOverride());
+ RemotingConnection rc = new RemotingConnectionImpl(connection, interceptors, !config.isBackup(), config.getConnectionTTLOverride(),
+ threadPool);
Channel channel1 = rc.getChannel(1, -1, false);
@@ -286,9 +291,21 @@
public void connectionDestroyed(final Object connectionID)
{
- // We DO NOT destroy the connection when this event is received.
- // Instead, the connection will be cleaned up when the connection TTL
- // is hit in FailedConnectionsTask.
+ RemotingConnection conn = connections.get(connectionID);
+
+ if (conn != null)
+ {
+ //if the connection has no failure listeners it means the sesssions etc were already closed so this is a clean
+ //shutdown, therefore we can destroy the connection
+ //otherwise client might have crashed/exited without closing connections so we leave them for connection TTL
+
+ if (conn.getFailureListeners().isEmpty())
+ {
+ connections.remove(connectionID);
+
+ conn.destroy();
+ }
+ }
}
public void connectionException(final Object connectionID, final MessagingException me)
Modified: trunk/src/main/org/jboss/messaging/core/remoting/spi/AcceptorFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/spi/AcceptorFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/remoting/spi/AcceptorFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -23,6 +23,7 @@
package org.jboss.messaging.core.remoting.spi;
import java.util.Map;
+import java.util.concurrent.Executor;
/**
* @author <a href="ataylor at redhat.com">Andy Taylor</a>
@@ -32,5 +33,6 @@
{
Acceptor createAcceptor(final Map<String, Object> configuration,
BufferHandler handler,
- ConnectionLifeCycleListener listener);
+ ConnectionLifeCycleListener listener,
+ Executor threadPool);
}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/spi/ConnectorFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/spi/ConnectorFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/remoting/spi/ConnectorFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -23,6 +23,7 @@
package org.jboss.messaging.core.remoting.spi;
import java.util.Map;
+import java.util.concurrent.Executor;
/**
*
@@ -34,5 +35,6 @@
public interface ConnectorFactory
{
Connector createConnector(Map<String, Object> configuration, BufferHandler handler,
- ConnectionLifeCycleListener listener);
+ ConnectionLifeCycleListener listener,
+ Executor threadPool);
}
Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -82,7 +82,7 @@
boolean autoCommitAcks,
boolean preAcknowledge,
boolean xa,
- int sendWindowSize) throws Exception;
+ int producerWindowSize) throws Exception;
void replicateCreateSession(String name,
long channelID,
Modified: trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/server/cluster/impl/BridgeImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -582,27 +582,12 @@
queue.addConsumer(BridgeImpl.this);
csf = new ClientSessionFactoryImpl(connectorPair.a,
- connectorPair.b,
- failoverOnServerShutdown,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts);
+ connectorPair.b);
+
+ csf.setFailoverOnServerShutdown(failoverOnServerShutdown);
+ csf.setRetryInterval(retryInterval);
+ csf.setRetryIntervalMultiplier(retryIntervalMultiplier);
+ csf.setReconnectAttempts(reconnectAttempts);
//Session is pre-acknowledge
session = (ClientSessionInternal)csf.createSession(SecurityStoreImpl.CLUSTER_ADMIN_USER,
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -82,6 +82,7 @@
import org.jboss.messaging.core.version.Version;
import org.jboss.messaging.utils.ExecutorFactory;
import org.jboss.messaging.utils.Future;
+import org.jboss.messaging.utils.JBMThreadFactory;
import org.jboss.messaging.utils.OrderedExecutorFactory;
import org.jboss.messaging.utils.Pair;
import org.jboss.messaging.utils.SimpleString;
@@ -316,25 +317,16 @@
replicatingChannel = null;
}
- pagingManager.stop();
resourceManager.stop();
postOffice.stop();
- pagingManager = null;
- securityStore = null;
- resourceManager = null;
- postOffice = null;
- securityRepository = null;
- securityStore = null;
- queueFactory = null;
- resourceManager = null;
- messagingServerControl = null;
+ // Need to shutdown pools before shutting down paging manager to make sure everything is written ok
scheduledPool.shutdown();
threadPool.shutdown();
try
{
- if (!threadPool.awaitTermination(10000, TimeUnit.MILLISECONDS))
+ if (!threadPool.awaitTermination(30000, TimeUnit.MILLISECONDS))
{
log.warn("Timed out waiting for pool to terminate");
}
@@ -344,6 +336,18 @@
// Ignore
}
+ pagingManager.stop();
+
+ pagingManager = null;
+ securityStore = null;
+ resourceManager = null;
+ postOffice = null;
+ securityRepository = null;
+ securityStore = null;
+ queueFactory = null;
+ resourceManager = null;
+ messagingServerControl = null;
+
sessions.clear();
started = false;
@@ -456,7 +460,7 @@
final boolean autoCommitAcks,
final boolean preAcknowledge,
final boolean xa,
- final int sendWindowSize) throws Exception
+ final int producerWindowSize) throws Exception
{
doCreateSession(name,
replicatedChannelID,
@@ -470,7 +474,7 @@
autoCommitAcks,
preAcknowledge,
xa,
- sendWindowSize,
+ producerWindowSize,
true);
}
@@ -591,6 +595,7 @@
ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
scheduledPool,
+ threadPool,
listener);
if (replicatingConnection == null)
@@ -859,16 +864,9 @@
private void initialisePart1() throws Exception
{
- managementService = new ManagementServiceImpl(mbeanServer, configuration);
-
- remotingService = new RemotingServiceImpl(configuration, this, managementService);
- }
-
- private void initialisePart2() throws Exception
- {
// Create the pools - we have two pools - one for non scheduled - and another for scheduled
- ThreadFactory tFactory = new org.jboss.messaging.utils.JBMThreadFactory("JBM-threads");
+ ThreadFactory tFactory = new JBMThreadFactory("JBM-server-threads" + System.identityHashCode(this), false);
if (configuration.getThreadPoolMaxSize() == -1)
{
@@ -882,8 +880,16 @@
executorFactory = new OrderedExecutorFactory(threadPool);
scheduledPool = new ScheduledThreadPoolExecutor(configuration.getScheduledThreadPoolMaxSize(),
- new org.jboss.messaging.utils.JBMThreadFactory("JBM-scheduled-threads"));
+ new org.jboss.messaging.utils.JBMThreadFactory("JBM-scheduled-threads",
+ false));
+ managementService = new ManagementServiceImpl(mbeanServer, configuration);
+
+ remotingService = new RemotingServiceImpl(configuration, this, managementService, threadPool);
+ }
+
+ private void initialisePart2() throws Exception
+ {
// Create the hard-wired components
if (configuration.isEnableFileDeployment())
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -226,7 +226,7 @@
response = new MessagingExceptionMessage(new MessagingException(MessagingException.INTERNAL_ERROR));
}
}
-
+
channel1.send(response);
}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerSessionImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -348,6 +348,8 @@
log.error("Failed to delete large message file", error);
}
}
+
+ remotingConnection.removeFailureListener(this);
}
public void promptDelivery(final Queue queue)
Modified: trunk/src/main/org/jboss/messaging/integration/bootstrap/JBMBootstrapServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/bootstrap/JBMBootstrapServer.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/integration/bootstrap/JBMBootstrapServer.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -69,8 +69,6 @@
*/
public static void main(final String[] args) throws Exception
{
- log.info("Starting server");
-
JBMBootstrapServer bootstrap = new JBMBootstrapServer(args);
bootstrap.run();
@@ -81,7 +79,6 @@
try
{
super.run();
- log.info("JBM Server Started");
}
catch (RuntimeException e)
{
@@ -211,7 +208,6 @@
public void shutDown()
{
- log.info("Shutting down");
ListIterator<KernelDeployment> iterator = deployments.listIterator(deployments.size());
while (iterator.hasPrevious())
{
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptor.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -30,8 +30,7 @@
import java.util.Timer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.concurrent.Executor;
import javax.net.ssl.SSLContext;
@@ -44,7 +43,6 @@
import org.jboss.messaging.core.remoting.spi.Connection;
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
import org.jboss.messaging.utils.ConfigurationHelper;
-import org.jboss.messaging.utils.JBMThreadFactory;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
@@ -77,10 +75,6 @@
{
private static final Logger log = Logger.getLogger(NettyAcceptor.class);
- private ExecutorService bossExecutor;
-
- private ExecutorService workerExecutor;
-
private ChannelFactory channelFactory;
private volatile ChannelGroup serverChannelGroup;
@@ -130,10 +124,13 @@
private ConcurrentMap<Object, Connection> connections = new ConcurrentHashMap<Object, Connection>();
private boolean paused;
+
+ private final Executor threadPool;
public NettyAcceptor(final Map<String, Object> configuration,
final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
+ final ConnectionLifeCycleListener listener,
+ final Executor threadPool)
{
this.handler = handler;
@@ -210,6 +207,8 @@
this.tcpReceiveBufferSize = ConfigurationHelper.getIntProperty(TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME,
TransportConstants.DEFAULT_TCP_RECEIVEBUFFER_SIZE,
configuration);
+
+ this.threadPool= threadPool;
}
public synchronized void start() throws Exception
@@ -219,8 +218,6 @@
// Already started
return;
}
- bossExecutor = Executors.newCachedThreadPool(new org.jboss.messaging.utils.JBMThreadFactory("jbm-netty-acceptor-boss-threads"));
- workerExecutor = Executors.newCachedThreadPool(new JBMThreadFactory("jbm-netty-acceptor-worker-threads"));
if (useInvm)
{
@@ -228,11 +225,11 @@
}
else if (useNio)
{
- channelFactory = new NioServerSocketChannelFactory(bossExecutor, workerExecutor);
+ channelFactory = new NioServerSocketChannelFactory(threadPool, threadPool);
}
else
{
- channelFactory = new OioServerSocketChannelFactory(bossExecutor, workerExecutor);
+ channelFactory = new OioServerSocketChannelFactory(threadPool, threadPool);
}
bootstrap = new ServerBootstrap(channelFactory);
@@ -337,25 +334,7 @@
//We *pause* the acceptor so no new connections are made
serverChannelGroup.close().awaitUninterruptibly();
-
-// //We also need to wait for workers to complete, otherwise requests could still sneak in after we have returned
-// //from this method
-// workerExecutor.shutdown();
-//
-// log.info("Waiting for worker to complete************************");
-// try
-// {
-// boolean ok = workerExecutor.awaitTermination(5000, TimeUnit.MILLISECONDS);
-//
-// if (!ok)
-// {
-// log.warn("Timed out in waiting for worker to complete");
-// }
-// }
-// catch (InterruptedException e)
-// {
-// }
-
+
try
{
Thread.sleep(500);
@@ -399,7 +378,7 @@
}
channelGroup.close().awaitUninterruptibly();
- channelFactory.releaseExternalResources();
+
channelFactory = null;
for (Connection connection : connections.values())
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptorFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptorFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyAcceptorFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -23,6 +23,7 @@
package org.jboss.messaging.integration.transports.netty;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -38,8 +39,9 @@
{
public Acceptor createAcceptor(final Map<String, Object> configuration,
final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
+ final ConnectionLifeCycleListener listener,
+ final Executor threadPool)
{
- return new NettyAcceptor(configuration, handler, listener);
+ return new NettyAcceptor(configuration, handler, listener, threadPool);
}
}
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnection.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -64,7 +64,7 @@
this.listener = listener;
- listener.connectionCreated(this);
+ listener.connectionCreated(this);
}
// Public --------------------------------------------------------
@@ -94,21 +94,7 @@
{
channel.close();
}
-
- // This block has been disabled because this method can be called from
- // the Netty I/O thread.
- // TODO Netty should be improved to provide a way to determine
- // if the current code is running in the I/O thread.
- //
- // if (channel.getParent() == null) {
- // // A client channel - wait until everything is cleaned up.
- // // TODO Do not spin - use signal.
- // MessagingChannelHandler handler = (MessagingChannelHandler) channel.getPipeline().get("handler");
- // while (handler.active) {
- // Thread.yield();
- // }
- // }
-
+
closed = true;
listener.connectionDestroyed(getID());
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnector.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -21,6 +21,24 @@
*/
package org.jboss.messaging.integration.transports.netty;
+import static org.jboss.netty.channel.Channels.pipeline;
+import static org.jboss.netty.channel.Channels.write;
+
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Executor;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.impl.ssl.SSLSupport;
@@ -30,7 +48,6 @@
import org.jboss.messaging.core.remoting.spi.Connector;
import org.jboss.messaging.utils.ConfigurationHelper;
import org.jboss.messaging.utils.Future;
-import org.jboss.messaging.utils.JBMThreadFactory;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
@@ -40,8 +57,6 @@
import org.jboss.netty.channel.ChannelPipelineCoverage;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.ChannelStateEvent;
-import static org.jboss.netty.channel.Channels.pipeline;
-import static org.jboss.netty.channel.Channels.write;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.channel.UpstreamMessageEvent;
@@ -65,21 +80,6 @@
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.netty.handler.ssl.SslHandler;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
/**
* A NettyConnector
*
@@ -94,10 +94,6 @@
// Attributes ----------------------------------------------------
- private ExecutorService bossExecutor;
-
- private ExecutorService workerExecutor;
-
private ClientSocketChannelFactory channelFactory;
private ClientBootstrap bootstrap;
@@ -139,6 +135,8 @@
private ConcurrentMap<Object, Connection> connections = new ConcurrentHashMap<Object, Connection>();
private final String servletPath;
+
+ private final Executor threadPool;
// Static --------------------------------------------------------
@@ -148,7 +146,8 @@
public NettyConnector(final Map<String, Object> configuration,
final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
+ final ConnectionLifeCycleListener listener,
+ final Executor threadPool)
{
if (listener == null)
{
@@ -228,6 +227,8 @@
this.tcpReceiveBufferSize = ConfigurationHelper.getIntProperty(TransportConstants.TCP_RECEIVEBUFFER_SIZE_PROPNAME,
TransportConstants.DEFAULT_TCP_RECEIVEBUFFER_SIZE,
configuration);
+
+ this.threadPool = threadPool;
}
public synchronized void start()
@@ -235,22 +236,21 @@
if (channelFactory != null)
{
return;
- }
- workerExecutor = Executors.newCachedThreadPool(new JBMThreadFactory("jbm-netty-connector-worker-threads"));
+ }
+
if (useNio)
- {
- bossExecutor = Executors.newCachedThreadPool(new JBMThreadFactory("jbm-netty-connector-boss-threads"));
- channelFactory = new NioClientSocketChannelFactory(bossExecutor, workerExecutor);
+ {
+ channelFactory = new NioClientSocketChannelFactory(threadPool, threadPool);
}
else
{
- channelFactory = new OioClientSocketChannelFactory(workerExecutor);
+ channelFactory = new OioClientSocketChannelFactory(threadPool);
}
// if we are a servlet wrap the socketChannelFactory
if (useServlet)
{
ClientSocketChannelFactory proxyChannelFactory = channelFactory;
- channelFactory = new HttpTunnelingClientSocketChannelFactory(proxyChannelFactory, workerExecutor);
+ channelFactory = new HttpTunnelingClientSocketChannelFactory(proxyChannelFactory, threadPool);
}
bootstrap = new ClientBootstrap(channelFactory);
@@ -318,8 +318,7 @@
}
bootstrap = null;
- channelGroup.close().awaitUninterruptibly();
- channelFactory.releaseExternalResources();
+ channelGroup.close().awaitUninterruptibly();
channelFactory = null;
for (Connection connection : connections.values())
@@ -328,7 +327,6 @@
}
connections.clear();
-
}
public boolean isStarted()
Modified: trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnectorFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnectorFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/integration/transports/netty/NettyConnectorFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -1,6 +1,7 @@
package org.jboss.messaging.integration.transports.netty;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.BufferHandler;
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
@@ -16,8 +17,9 @@
{
public Connector createConnector(final Map<String, Object> configuration,
final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
+ final ConnectionLifeCycleListener listener,
+ final Executor threadPool)
{
- return new NettyConnector(configuration, handler, listener);
+ return new NettyConnector(configuration, handler, listener, threadPool);
}
}
Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -12,15 +12,8 @@
package org.jboss.messaging.jms.client;
-import org.jboss.messaging.core.client.ClientSessionFactory;
-import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
-import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
-import org.jboss.messaging.core.exception.MessagingException;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.jms.referenceable.ConnectionFactoryObjectFactory;
-import org.jboss.messaging.jms.referenceable.SerializableObjectRefAddr;
-import org.jboss.messaging.utils.Pair;
+import java.io.Serializable;
+import java.util.List;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -37,10 +30,15 @@
import javax.jms.XATopicConnectionFactory;
import javax.naming.NamingException;
import javax.naming.Reference;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.jms.referenceable.ConnectionFactoryObjectFactory;
+import org.jboss.messaging.jms.referenceable.SerializableObjectRefAddr;
+import org.jboss.messaging.utils.Pair;
+
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -62,372 +60,44 @@
// Attributes -----------------------------------------------------------------------------------
- private transient volatile ClientSessionFactory sessionFactory;
+ private transient ClientSessionFactory sessionFactory;
- private final String connectionLoadBalancingPolicyClassName;
+ private String clientID;
- private final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs;
+ private int dupsOKBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- private final String discoveryGroupAddress;
-
- private final int discoveryGroupPort;
-
- private final long discoveryRefreshTimeout;
-
- private final long discoveryInitialWaitTimeout;
-
- private final String clientID;
-
- private final int dupsOKBatchSize;
-
- private final int transactionBatchSize;
-
- private final long pingPeriod;
-
- private final long connectionTTL;
-
- private final long callTimeout;
-
- private final int consumerWindowSize;
-
- private final int consumerMaxRate;
-
- private final int producerWindowSize;
-
- private final int producerMaxRate;
-
- private final int minLargeMessageSize;
-
- private final boolean blockOnAcknowledge;
-
- private final boolean blockOnNonPersistentSend;
-
- private final boolean blockOnPersistentSend;
-
- private final boolean autoGroup;
-
- private final int maxConnections;
-
- private final boolean preAcknowledge;
-
- private final long retryInterval;
-
- private final double retryIntervalMultiplier; // For exponential backoff
-
- private final int reconnectAttempts;
-
- private final boolean failoverOnServerShutdown;
-
+ private int transactionBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+
+ private boolean readOnly;
+
// Constructors ---------------------------------------------------------------------------------
- public JBossConnectionFactory(final String discoveryGroupAddress,
- final int discoveryGroupPort,
- final long discoveryRefreshTimeout,
- final long discoveryInitialWaitTimeout,
- final String loadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int producerWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown)
+ public JBossConnectionFactory()
{
- this.connectorConfigs = null;
- this.discoveryGroupAddress = discoveryGroupAddress;
- this.discoveryGroupPort = discoveryGroupPort;
- this.discoveryRefreshTimeout = discoveryRefreshTimeout;
- this.discoveryInitialWaitTimeout = discoveryInitialWaitTimeout;
- this.connectionLoadBalancingPolicyClassName = loadBalancingPolicyClassName;
- this.clientID = clientID;
- this.dupsOKBatchSize = dupsOKBatchSize;
- this.transactionBatchSize = transactionBatchSize;
- this.pingPeriod = pingPeriod;
- this.connectionTTL = connectionTTL;
- this.callTimeout = callTimeout;
- this.consumerMaxRate = consumerMaxRate;
- this.consumerWindowSize = consumerWindowSize;
- this.producerMaxRate = producerMaxRate;
- this.producerWindowSize = producerWindowSize;
- this.blockOnAcknowledge = blockOnAcknowledge;
- this.minLargeMessageSize = minLargeMessageSize;
- this.blockOnNonPersistentSend = blockOnNonPersistentSend;
- this.blockOnPersistentSend = blockOnPersistentSend;
- this.autoGroup = autoGroup;
- this.maxConnections = maxConnections;
- this.preAcknowledge = preAcknowledge;
- this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.reconnectAttempts = reconnectAttempts;
- this.failoverOnServerShutdown = failoverOnServerShutdown;
+ sessionFactory = new ClientSessionFactoryImpl();
}
- public JBossConnectionFactory(final String discoveryGroupAddress,
- final int discoveryGroupPort,
- final long discoveryRefreshTimeout,
- final long discoveryInitialWaitTimeout)
+ public JBossConnectionFactory(final String discoveryAddress, final int discoveryPort)
{
- this.connectorConfigs = null;
- this.discoveryGroupAddress = discoveryGroupAddress;
- this.discoveryGroupPort = discoveryGroupPort;
- this.discoveryRefreshTimeout = discoveryRefreshTimeout;
- this.discoveryInitialWaitTimeout = discoveryInitialWaitTimeout;
- this.connectionLoadBalancingPolicyClassName = ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
- this.clientID = null;
- this.dupsOKBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- this.transactionBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- this.pingPeriod = ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
- this.connectionTTL = ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
- this.callTimeout = ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
- this.consumerMaxRate = ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
- this.consumerWindowSize = ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
- this.producerMaxRate = ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
- this.producerWindowSize = ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
- this.blockOnAcknowledge = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
- this.minLargeMessageSize = ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
- this.blockOnNonPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
- this.blockOnPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
- this.autoGroup = ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
- this.maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
- this.preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
- this.retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
- this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
- this.failoverOnServerShutdown = ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
+ sessionFactory = new ClientSessionFactoryImpl(discoveryAddress, discoveryPort);
}
- public JBossConnectionFactory(final String discoveryGroupAddress, final int discoveryGroupPort)
+ public JBossConnectionFactory(final List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors)
{
- this(discoveryGroupAddress,
- discoveryGroupPort,
- ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT);
+ sessionFactory = new ClientSessionFactoryImpl(staticConnectors);
}
- public JBossConnectionFactory(final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- final String loadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int sendWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown)
+ public JBossConnectionFactory(final TransportConfiguration connectorConfig,
+ final TransportConfiguration backupConnectorConfig)
{
- this.discoveryGroupAddress = null;
- this.discoveryGroupPort = -1;
- this.discoveryRefreshTimeout = -1;
- this.discoveryInitialWaitTimeout = -1;
- this.connectorConfigs = connectorConfigs;
- this.connectionLoadBalancingPolicyClassName = loadBalancingPolicyClassName;
- this.clientID = clientID;
- this.dupsOKBatchSize = dupsOKBatchSize;
- this.transactionBatchSize = transactionBatchSize;
- this.pingPeriod = pingPeriod;
- this.connectionTTL = connectionTTL;
- this.callTimeout = callTimeout;
- this.consumerMaxRate = consumerMaxRate;
- this.consumerWindowSize = consumerWindowSize;
- this.producerMaxRate = producerMaxRate;
- this.producerWindowSize = sendWindowSize;
- this.blockOnAcknowledge = blockOnAcknowledge;
- this.minLargeMessageSize = minLargeMessageSize;
- this.blockOnNonPersistentSend = blockOnNonPersistentSend;
- this.blockOnPersistentSend = blockOnPersistentSend;
- this.autoGroup = autoGroup;
- this.maxConnections = maxConnections;
- this.preAcknowledge = preAcknowledge;
- this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.reconnectAttempts = reconnectAttempts;
- this.failoverOnServerShutdown = failoverOnServerShutdown;
+ sessionFactory = new ClientSessionFactoryImpl(connectorConfig, backupConnectorConfig);
}
- public JBossConnectionFactory(final TransportConfiguration transportConfig,
- final TransportConfiguration backupConfig,
- final String loadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int sendWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown)
- {
- this.discoveryGroupAddress = null;
- this.discoveryGroupPort = -1;
- this.discoveryRefreshTimeout = -1;
- this.discoveryInitialWaitTimeout = -1;
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
- connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(transportConfig, backupConfig));
- this.connectorConfigs = connectorConfigs;
- this.connectionLoadBalancingPolicyClassName = loadBalancingPolicyClassName;
- this.clientID = null;
- this.dupsOKBatchSize = dupsOKBatchSize;
- this.transactionBatchSize = transactionBatchSize;
- this.pingPeriod = pingPeriod;
- this.connectionTTL = connectionTTL;
- this.callTimeout = callTimeout;
- this.consumerMaxRate = consumerMaxRate;
- this.consumerWindowSize = consumerWindowSize;
- this.producerMaxRate = producerMaxRate;
- this.producerWindowSize = sendWindowSize;
- this.blockOnAcknowledge = blockOnAcknowledge;
- this.minLargeMessageSize = minLargeMessageSize;
- this.blockOnNonPersistentSend = blockOnNonPersistentSend;
- this.blockOnPersistentSend = blockOnPersistentSend;
- this.autoGroup = autoGroup;
- this.maxConnections = maxConnections;
- this.preAcknowledge = preAcknowledge;
- this.retryInterval = retryInterval;
- this.retryIntervalMultiplier = retryIntervalMultiplier;
- this.reconnectAttempts = reconnectAttempts;
- this.failoverOnServerShutdown = failoverOnServerShutdown;
- }
-
- public JBossConnectionFactory(final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs)
- {
- this.discoveryGroupAddress = null;
- this.discoveryGroupPort = -1;
- this.discoveryRefreshTimeout = -1;
- this.discoveryInitialWaitTimeout = -1;
- this.connectorConfigs = connectorConfigs;
- this.connectionLoadBalancingPolicyClassName = ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
- this.clientID = null;
- this.dupsOKBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- this.transactionBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- this.pingPeriod = ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
- this.connectionTTL = ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
- this.callTimeout = ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
- this.consumerMaxRate = ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
- this.consumerWindowSize = ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
- this.producerMaxRate = ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
- this.producerWindowSize = ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
- this.blockOnAcknowledge = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
- this.minLargeMessageSize = ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
- this.blockOnNonPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
- this.blockOnPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
- this.autoGroup = ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
- this.maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
- this.preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
- this.retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
- this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
- this.failoverOnServerShutdown = ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
- }
-
- public JBossConnectionFactory(final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean preAcknowledge)
- {
- this.discoveryGroupAddress = null;
- this.discoveryGroupPort = -1;
- this.discoveryRefreshTimeout = -1;
- this.discoveryInitialWaitTimeout = -1;
- this.connectorConfigs = connectorConfigs;
- this.connectionLoadBalancingPolicyClassName = ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
- this.clientID = null;
- this.dupsOKBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- this.transactionBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- this.pingPeriod = ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
- this.connectionTTL = ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
- this.callTimeout = ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
- this.consumerMaxRate = ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
- this.consumerWindowSize = ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
- this.producerMaxRate = ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
- this.producerWindowSize = ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
- this.blockOnAcknowledge = blockOnAcknowledge;
- this.minLargeMessageSize = ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
- this.blockOnNonPersistentSend = blockOnNonPersistentSend;
- this.blockOnPersistentSend = blockOnPersistentSend;
- this.autoGroup = ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
- this.maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
- this.preAcknowledge = preAcknowledge;
- this.retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
- this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
- this.failoverOnServerShutdown = ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
- }
-
public JBossConnectionFactory(final TransportConfiguration connectorConfig)
{
- this.discoveryGroupAddress = null;
- this.discoveryGroupPort = -1;
- this.discoveryRefreshTimeout = -1;
- this.discoveryInitialWaitTimeout = -1;
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
- Pair<TransportConfiguration, TransportConfiguration> pair = new Pair<TransportConfiguration, TransportConfiguration>(connectorConfig,
- null);
- connectorConfigs.add(pair);
- this.connectorConfigs = connectorConfigs;
- this.connectionLoadBalancingPolicyClassName = ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
- this.clientID = null;
- this.dupsOKBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- this.transactionBatchSize = ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
- this.pingPeriod = ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
- this.connectionTTL = ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
- this.callTimeout = ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
- this.consumerMaxRate = ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
- this.consumerWindowSize = ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
- this.producerMaxRate = ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
- this.producerWindowSize = ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
- this.blockOnAcknowledge = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
- this.minLargeMessageSize = ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
- this.blockOnNonPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
- this.blockOnPersistentSend = ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
- this.autoGroup = ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
- this.maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
- this.preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
- this.retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
- this.retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
- this.reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
- this.failoverOnServerShutdown = ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
+ this(connectorConfig, null);
}
-
+
// ConnectionFactory implementation -------------------------------------------------------------
public Connection createConnection() throws JMSException
@@ -512,111 +182,314 @@
// Public ---------------------------------------------------------------------------------------
- public long getPingPeriod()
+ public synchronized String getConnectionLoadBalancingPolicyClassName()
{
- return pingPeriod;
+ return sessionFactory.getLoadBalancingPolicyClassName();
}
- public long getCallTimeout()
+ public synchronized void setConnectionLoadBalancingPolicyClassName(String connectionLoadBalancingPolicyClassName)
{
- return callTimeout;
+ sessionFactory.setLoadBalancingPolicyClassName(connectionLoadBalancingPolicyClassName);
}
- public String getClientID()
+ public synchronized List<Pair<TransportConfiguration, TransportConfiguration>> getStaticConnectors()
{
+ return sessionFactory.getStaticConnectors();
+ }
+
+ public synchronized void setStaticConnectors(List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors)
+ {
+ sessionFactory.setStaticConnectors(staticConnectors);
+ }
+
+ public synchronized String getDiscoveryAddress()
+ {
+ return sessionFactory.getDiscoveryAddress();
+ }
+
+ public synchronized void setDiscoveryAddress(String discoveryAddress)
+ {
+ sessionFactory.setDiscoveryAddress(discoveryAddress);
+ }
+
+ public synchronized int getDiscoveryPort()
+ {
+ return sessionFactory.getDiscoveryPort();
+ }
+
+ public synchronized void setDiscoveryPort(int discoveryPort)
+ {
+ sessionFactory.setDiscoveryPort(discoveryPort);
+ }
+
+ public synchronized long getDiscoveryRefreshTimeout()
+ {
+ return sessionFactory.getDiscoveryRefreshTimeout();
+ }
+
+ public synchronized void setDiscoveryRefreshTimeout(long discoveryRefreshTimeout)
+ {
+ sessionFactory.setDiscoveryRefreshTimeout(discoveryRefreshTimeout);
+ }
+
+ public synchronized long getDiscoveryInitialWaitTimeout()
+ {
+ return sessionFactory.getInitialWaitTimeout();
+ }
+
+ public synchronized void setDiscoveryInitialWaitTimeout(long discoveryInitialWaitTimeout)
+ {
+ sessionFactory.setInitialWaitTimeout(discoveryInitialWaitTimeout);
+ }
+
+ public synchronized String getClientID()
+ {
return clientID;
}
- public int getDupsOKBatchSize()
+ public synchronized void setClientID(String clientID)
{
+ checkWrite();
+ this.clientID = clientID;
+ }
+
+ public synchronized int getDupsOKBatchSize()
+ {
return dupsOKBatchSize;
}
- public int getTransactionBatchSize()
+ public synchronized void setDupsOKBatchSize(int dupsOKBatchSize)
{
+ checkWrite();
+ this.dupsOKBatchSize = dupsOKBatchSize;
+ }
+
+ public synchronized int getTransactionBatchSize()
+ {
return transactionBatchSize;
}
- public long getConnectionTTL()
+ public synchronized void setTransactionBatchSize(int transactionBatchSize)
{
- return connectionTTL;
+ checkWrite();
+ this.transactionBatchSize = transactionBatchSize;
}
- public int getConsumerWindowSize()
+ public synchronized long getPingPeriod()
{
- return consumerWindowSize;
+ return sessionFactory.getPingPeriod();
}
- public int getConsumerMaxRate()
+ public synchronized void setPingPeriod(long pingPeriod)
{
- return consumerMaxRate;
+ sessionFactory.setPingPeriod(pingPeriod);
}
- public int getProducerWindowSize()
+ public synchronized long getConnectionTTL()
{
- return producerWindowSize;
+ return sessionFactory.getConnectionTTL();
}
- public int getProducerMaxRate()
+ public synchronized void setConnectionTTL(long connectionTTL)
{
- return producerMaxRate;
+ sessionFactory.setConnectionTTL(connectionTTL);
}
- public int getMinLargeMessageSize()
+ public synchronized long getCallTimeout()
{
- return minLargeMessageSize;
+ return sessionFactory.getCallTimeout();
}
- public int getMaxConnections()
+ public synchronized void setCallTimeout(long callTimeout)
{
- return maxConnections;
+ sessionFactory.setCallTimeout(callTimeout);
}
- public int getReconnectAttempts()
+ public synchronized int getConsumerWindowSize()
{
- return reconnectAttempts;
+ return sessionFactory.getConsumerWindowSize();
}
- public boolean isFailoverOnServerShutdown()
+ public synchronized void setConsumerWindowSize(int consumerWindowSize)
{
- return failoverOnServerShutdown;
+ sessionFactory.setConsumerWindowSize(consumerWindowSize);
}
- public boolean isBlockOnAcknowledge()
+ public synchronized int getConsumerMaxRate()
{
- return blockOnAcknowledge;
+ return sessionFactory.getConsumerMaxRate();
}
- public boolean isBlockOnNonPersistentSend()
+ public synchronized void setConsumerMaxRate(int consumerMaxRate)
{
- return blockOnNonPersistentSend;
+ sessionFactory.setConsumerMaxRate(consumerMaxRate);
}
- public boolean isBlockOnPersistentSend()
+ public synchronized int getProducerWindowSize()
{
- return blockOnPersistentSend;
+ return sessionFactory.getProducerWindowSize();
}
- public boolean isPreAcknowledge()
+ public synchronized void setProducerWindowSize(int producerWindowSize)
{
- return preAcknowledge;
+ sessionFactory.setProducerWindowSize(producerWindowSize);
}
- public boolean isAutoGroup()
+ public synchronized int getProducerMaxRate()
{
- return autoGroup;
+ return sessionFactory.getProducerMaxRate();
}
- public long getRetryInterval()
+ public synchronized void setProducerMaxRate(int producerMaxRate)
{
- return retryInterval;
+ sessionFactory.setProducerMaxRate(producerMaxRate);
}
- public double getRetryIntervalMultiplier()
+ public synchronized int getMinLargeMessageSize()
{
- return retryIntervalMultiplier;
+ return sessionFactory.getMinLargeMessageSize();
}
+ public synchronized void setMinLargeMessageSize(int minLargeMessageSize)
+ {
+ sessionFactory.setMinLargeMessageSize(minLargeMessageSize);
+ }
+
+ public synchronized boolean isBlockOnAcknowledge()
+ {
+ return sessionFactory.isBlockOnAcknowledge();
+ }
+
+ public synchronized void setBlockOnAcknowledge(boolean blockOnAcknowledge)
+ {
+ sessionFactory.setBlockOnAcknowledge(blockOnAcknowledge);
+ }
+
+ public synchronized boolean isBlockOnNonPersistentSend()
+ {
+ return sessionFactory.isBlockOnNonPersistentSend();
+ }
+
+ public synchronized void setBlockOnNonPersistentSend(boolean blockOnNonPersistentSend)
+ {
+ sessionFactory.setBlockOnNonPersistentSend(blockOnNonPersistentSend);
+ }
+
+ public synchronized boolean isBlockOnPersistentSend()
+ {
+ return sessionFactory.isBlockOnPersistentSend();
+ }
+
+ public synchronized void setBlockOnPersistentSend(boolean blockOnPersistentSend)
+ {
+ sessionFactory.setBlockOnPersistentSend(blockOnPersistentSend);
+ }
+
+ public synchronized boolean isAutoGroup()
+ {
+ return sessionFactory.isAutoGroup();
+ }
+
+ public synchronized void setAutoGroup(boolean autoGroup)
+ {
+ sessionFactory.setAutoGroup(autoGroup);
+ }
+
+ public synchronized int getMaxConnections()
+ {
+ return sessionFactory.getMaxConnections();
+ }
+
+ public synchronized void setMaxConnections(int maxConnections)
+ {
+ sessionFactory.setMaxConnections(maxConnections);
+ }
+
+ public synchronized boolean isPreAcknowledge()
+ {
+ return sessionFactory.isPreAcknowledge();
+ }
+
+ public synchronized void setPreAcknowledge(boolean preAcknowledge)
+ {
+ sessionFactory.setPreAcknowledge(preAcknowledge);
+ }
+
+ public synchronized long getRetryInterval()
+ {
+ return sessionFactory.getRetryInterval();
+ }
+
+ public synchronized void setRetryInterval(long retryInterval)
+ {
+ sessionFactory.setRetryInterval(retryInterval);
+ }
+
+ public synchronized double getRetryIntervalMultiplier()
+ {
+ return sessionFactory.getRetryIntervalMultiplier();
+ }
+
+ public synchronized void setRetryIntervalMultiplier(double retryIntervalMultiplier)
+ {
+ sessionFactory.setRetryIntervalMultiplier(retryIntervalMultiplier);
+ }
+
+ public synchronized int getReconnectAttempts()
+ {
+ return sessionFactory.getReconnectAttempts();
+ }
+
+ public synchronized void setReconnectAttempts(int reconnectAttempts)
+ {
+ sessionFactory.setReconnectAttempts(reconnectAttempts);
+ }
+
+ public synchronized boolean isFailoverOnServerShutdown()
+ {
+ return sessionFactory.isFailoverOnServerShutdown();
+ }
+
+ public synchronized void setFailoverOnServerShutdown(boolean failoverOnServerShutdown)
+ {
+ sessionFactory.setFailoverOnServerShutdown(failoverOnServerShutdown);
+ }
+
+ public synchronized boolean isUseGlobalPools()
+ {
+ return sessionFactory.isUseGlobalPools();
+ }
+
+ public synchronized void setUseGlobalPools(boolean useGlobalPools)
+ {
+ sessionFactory.setUseGlobalPools(useGlobalPools);
+ }
+
+ public synchronized int getScheduledThreadPoolMaxSize()
+ {
+ return sessionFactory.getScheduledThreadPoolMaxSize();
+ }
+
+ public synchronized void setScheduledThreadPoolMaxSize(int scheduledThreadPoolMaxSize)
+ {
+ sessionFactory.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
+ }
+
+ public synchronized int getThreadPoolMaxSize()
+ {
+ return sessionFactory.getThreadPoolMaxSize();
+ }
+
+ public synchronized void setThreadPoolMaxSize(int threadPoolMaxSize)
+ {
+ sessionFactory.setThreadPoolMaxSize(threadPoolMaxSize);
+ }
+
+ public ClientSessionFactory getCoreFactory()
+ {
+ return sessionFactory;
+ }
+
// Package protected ----------------------------------------------------------------------------
// Protected ------------------------------------------------------------------------------------
@@ -626,18 +499,8 @@
final boolean isXA,
final int type) throws JMSException
{
- try
- {
- if (sessionFactory == null)
- {
- createFactory();
- }
- }
- catch (MessagingException me)
- {
- throw JMSExceptionHelper.convertFromMessagingException(me);
- }
-
+ readOnly = false;
+
JBossConnection connection = new JBossConnection(username,
password,
type,
@@ -647,75 +510,21 @@
sessionFactory);
connection.authorize();
-
+
return connection;
}
- private void createFactory() throws MessagingException
+ // Private --------------------------------------------------------------------------------------
+
+ private void checkWrite()
{
- if (connectorConfigs != null)
+ if (readOnly)
{
- sessionFactory = new ClientSessionFactoryImpl(connectorConfigs,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- dupsOKBatchSize,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnServerShutdown);
+ throw new IllegalStateException("Cannot set attribute on JBossConnectionFactory after it has been used");
}
- else
- {
- sessionFactory = new ClientSessionFactoryImpl(discoveryGroupAddress,
- discoveryGroupPort,
- discoveryRefreshTimeout,
- discoveryInitialWaitTimeout,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- dupsOKBatchSize,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnServerShutdown);
- }
}
- // Private --------------------------------------------------------------------------------------
-
+
// Inner classes --------------------------------------------------------------------------------
- public ClientSessionFactory getCoreFactory() throws MessagingException
- {
- if (sessionFactory == null)
- {
- createFactory();
- }
- return sessionFactory;
- }
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -27,7 +27,6 @@
import javax.naming.Context;
import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
import org.jboss.messaging.core.server.MessagingComponent;
import org.jboss.messaging.utils.Pair;
@@ -110,71 +109,99 @@
*/
boolean destroyTopic(String name) throws Exception;
- boolean createConnectionFactory(String name,
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- List<String> jndiBindings) throws Exception;
-
- boolean createConnectionFactory(String name,
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean preAcknowledge,
- List<String> bindings) throws Exception;
+ void createConnectionFactory(String name, String discoveryAddress, int discoveryPort, List<String> jndiBindings) throws Exception;
- boolean createConnectionFactory(String name,
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- String connectionLoadBalancingPolicyClassName,
- long pingPeriod,
- long connectionTTL,
- long callTimeout,
- String clientID,
- int dupsOKBatchSize,
- int transactionBatchSize,
- int consumerWindowSize,
- int consumerMaxRate,
- int sendWindowSize,
- int producerMaxRate,
- int minLargeMessageSize,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean autoGroup,
- int maxConnections,
- boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnNodeShutdown,
- List<String> jndiBindings) throws Exception;
-
- boolean createConnectionFactory(String name,
- DiscoveryGroupConfiguration discoveryGroupConfig,
- long discoveryInitialWait,
- String connectionLoadBalancingPolicyClassName,
- long pingPeriod,
- long connectionTTL,
- long callTimeout,
- String clientID,
- int dupsOKBatchSize,
- int transactionBatchSize,
- int consumerWindowSize,
- int consumerMaxRate,
- int sendWindowSize,
- int producerMaxRate,
- int minLargeMessageSize,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean autoGroup,
- int maxConnections,
- boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnNodeShutdown,
- List<String> jndiBindings) throws Exception;
+ void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ List<String> jndiBindings) throws Exception;
+ void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name, TransportConfiguration liveTC, List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name, TransportConfiguration liveTC, String clientID, List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ long pingPeriod,
+ long connectionTTL,
+ long callTimeout,
+ int maxConnections,
+ int minLargeMessageSize,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
+ int producerMaxRate,
+ boolean blockOnAcknowledge,
+ boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
+ boolean autoGroup,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int reconnectAttempts,
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ long discoveryRefreshTimeout,
+ long pingPeriod,
+ long connectionTTL,
+ long callTimeout,
+ int maxConnections,
+ int minLargeMessageSize,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
+ int producerMaxRate,
+ boolean blockOnAcknowledge,
+ boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
+ boolean autoGroup,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ long initialWaitTimeout,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int reconnectAttempts,
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception;
+
/**
* destroys a connection factory.
*
Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerDeployer.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -42,7 +42,7 @@
private static final String CLIENTID_ELEMENT = "client-id";
private static final String PING_PERIOD_ELEMENT = "ping-period";
-
+
private static final String CONNECTION_TTL_ELEMENT = "connection-ttl";
private static final String CALL_TIMEOUT_ELEMENT = "call-timeout";
@@ -78,8 +78,14 @@
private static final String RETRY_INTERVAL_MULTIPLIER = "retry-interval-multiplier";
private static final String RECONNECT_ATTEMPTS = "reconnect-attempts";
+
+ private static final String FAILOVER_ON_SERVER_SHUTDOWN = "failover-on-server-shutdown";
- private static final String FAILOVER_ON_NODE_SHUTDOWN = "failover-on-server-shutdown";
+ private static final String USE_GLOBAL_POOLS = "use-global-pools";
+
+ private static final String SCHEDULED_THREAD_POOL_MAX_SIZE = "scheduled-thread-pool-max-size";
+
+ private static final String THREAD_POOL_MAX_SIZE = "thread-pool-max-size";
private static final String CONNECTOR_LINK_ELEMENT = "connector-ref";
@@ -99,16 +105,17 @@
private static final String DISCOVERY_INITIAL_WAIT_ELEMENT = "discovery-initial-wait";
- public JMSServerDeployer(final JMSServerManager jmsServerManager, final DeploymentManager deploymentManager, final Configuration config)
+ public JMSServerDeployer(final JMSServerManager jmsServerManager,
+ final DeploymentManager deploymentManager,
+ final Configuration config)
{
super(deploymentManager);
-
+
this.jmsServerControl = jmsServerManager;
this.configuration = config;
}
-
/**
* the names of the elements to deploy
*
@@ -125,7 +132,7 @@
{
org.jboss.messaging.utils.XMLUtil.validate(rootNode, "jbm-jms.xsd");
}
-
+
/**
* deploy an element
*
@@ -134,7 +141,7 @@
*/
@Override
public void deploy(final Node node) throws Exception
- {
+ {
createAndBindObject(node);
}
@@ -145,9 +152,9 @@
* @throws Exception .
*/
private void createAndBindObject(final Node node) throws Exception
- {
+ {
if (node.getNodeName().equals(CONNECTION_FACTORY_NODE_NAME))
- {
+ {
NodeList children = node.getChildNodes();
long pingPeriod = ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
@@ -168,9 +175,12 @@
int maxConnections = ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
boolean preAcknowledge = ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
long retryInterval = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
- double retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+ double retryIntervalMultiplier = ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
int reconnectAttempts = ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
- boolean failoverOnNodeShutdown = ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
+ boolean failoverOnServerShutdown = ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
+ boolean useGlobalPools = ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS;
+ int scheduledThreadPoolMaxSize = ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
+ int threadPoolMaxSize = ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE;
List<String> jndiBindings = new ArrayList<String>();
List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
@@ -247,8 +257,8 @@
maxConnections = org.jboss.messaging.utils.XMLUtil.parseInt(child);
}
else if (PRE_ACKNOWLEDGE_ELEMENT.equals(child.getNodeName()))
- {
- preAcknowledge = org.jboss.messaging.utils.XMLUtil.parseBoolean(child);
+ {
+ preAcknowledge = org.jboss.messaging.utils.XMLUtil.parseBoolean(child);
}
else if (RETRY_INTERVAL.equals(child.getNodeName()))
{
@@ -262,10 +272,22 @@
{
reconnectAttempts = org.jboss.messaging.utils.XMLUtil.parseInt(child);
}
- else if (FAILOVER_ON_NODE_SHUTDOWN.equals(child.getNodeName()))
+ else if (FAILOVER_ON_SERVER_SHUTDOWN.equals(child.getNodeName()))
{
- failoverOnNodeShutdown = org.jboss.messaging.utils.XMLUtil.parseBoolean(child);
- }
+ failoverOnServerShutdown = org.jboss.messaging.utils.XMLUtil.parseBoolean(child);
+ }
+ else if (USE_GLOBAL_POOLS.equals(child.getNodeName()))
+ {
+ useGlobalPools = org.jboss.messaging.utils.XMLUtil.parseBoolean(child);
+ }
+ else if (SCHEDULED_THREAD_POOL_MAX_SIZE.equals(child.getNodeName()))
+ {
+ scheduledThreadPoolMaxSize = org.jboss.messaging.utils.XMLUtil.parseInt(child);
+ }
+ else if (THREAD_POOL_MAX_SIZE.equals(child.getNodeName()))
+ {
+ threadPoolMaxSize = org.jboss.messaging.utils.XMLUtil.parseInt(child);
+ }
else if (ENTRIES_NODE_NAME.equals(child.getNodeName()))
{
NodeList entries = child.getChildNodes();
@@ -276,7 +298,7 @@
{
String jndiName = entry.getAttributes().getNamedItem("name").getNodeValue();
- jndiBindings.add(jndiName);
+ jndiBindings.add(jndiName);
}
}
}
@@ -333,7 +355,7 @@
return;
}
- }
+ }
}
String name = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
@@ -341,64 +363,72 @@
if (discoveryGroupConfiguration != null)
{
jmsServerControl.createConnectionFactory(name,
- discoveryGroupConfiguration,
- discoveryInitialWait,
- connectionLoadBalancingPolicyClassName,
+ discoveryGroupConfiguration.getGroupAddress(),
+ discoveryGroupConfiguration.getGroupPort(),
+ clientID,
+ discoveryGroupConfiguration.getRefreshTimeout(),
pingPeriod,
connectionTTL,
callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
+ maxConnections,
+ minLargeMessageSize,
consumerWindowSize,
consumerMaxRate,
producerWindowSize,
producerMaxRate,
- minLargeMessageSize,
blockOnAcknowledge,
+ blockOnPersistentSend,
blockOnNonPersistentSend,
- blockOnPersistentSend,
autoGroup,
- maxConnections,
- preAcknowledge,
+ preAcknowledge,
+ connectionLoadBalancingPolicyClassName,
+ transactionBatchSize,
+ dupsOKBatchSize,
+ discoveryInitialWait,
+ useGlobalPools,
+ scheduledThreadPoolMaxSize,
+ threadPoolMaxSize,
retryInterval,
- retryIntervalMultiplier,
+ retryIntervalMultiplier,
reconnectAttempts,
- failoverOnNodeShutdown,
+ failoverOnServerShutdown,
jndiBindings);
}
else
{
jmsServerControl.createConnectionFactory(name,
connectorConfigs,
- connectionLoadBalancingPolicyClassName,
+ clientID,
pingPeriod,
connectionTTL,
callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
+ maxConnections,
+ minLargeMessageSize,
consumerWindowSize,
consumerMaxRate,
producerWindowSize,
producerMaxRate,
- minLargeMessageSize,
blockOnAcknowledge,
+ blockOnPersistentSend,
blockOnNonPersistentSend,
- blockOnPersistentSend,
autoGroup,
- maxConnections,
- preAcknowledge,
+ preAcknowledge,
+ connectionLoadBalancingPolicyClassName,
+ transactionBatchSize,
+ dupsOKBatchSize,
+ useGlobalPools,
+ scheduledThreadPoolMaxSize,
+ threadPoolMaxSize,
retryInterval,
- retryIntervalMultiplier,
+ retryIntervalMultiplier,
reconnectAttempts,
- failoverOnNodeShutdown,
+ failoverOnServerShutdown,
jndiBindings);
}
}
else if (node.getNodeName().equals(QUEUE_NODE_NAME))
- {
- String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
+ {
+ String queueName = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++)
{
@@ -456,7 +486,7 @@
public String[] getDefaultConfigFileNames()
{
- return new String[] {"jbm-jms.xml"};
+ return new String[] { "jbm-jms.xml" };
}
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -35,7 +35,6 @@
import javax.naming.NamingException;
import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
import org.jboss.messaging.core.deployers.Deployer;
import org.jboss.messaging.core.deployers.DeploymentManager;
import org.jboss.messaging.core.deployers.impl.FileDeploymentManager;
@@ -124,9 +123,12 @@
{
return;
}
+
+ log.info("context is " + context);
if (context == null)
{
+ log.info("creating initial context");
context = new InitialContext();
}
@@ -183,6 +185,7 @@
public synchronized void setContext(final Context context)
{
+ log.info("setting context with " + context);
this.context = context;
}
@@ -198,11 +201,14 @@
checkInitialised();
JBossQueue jBossQueue = new JBossQueue(queueName);
server.getMessagingServerControl().deployQueue(jBossQueue.getAddress(), jBossQueue.getAddress());
+
boolean added = bindToJndi(jndiBinding, jBossQueue);
+
if (added)
{
addToDestinationBindings(queueName, jndiBinding);
}
+
jmsManagementService.registerQueue(jBossQueue, jndiBinding);
return added;
}
@@ -269,171 +275,264 @@
return true;
}
+
+ public synchronized void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ List<String> jndiBindings) throws Exception
+ {
+ checkInitialised();
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ cf = new JBossConnectionFactory(connectorConfigs);
+ }
- public synchronized boolean createConnectionFactory(final String name,
- final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- final String connectionLoadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int sendWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnNodeShutdown,
- final List<String> jndiBindings) throws Exception
+ bindConnectionFactory(cf, name, jndiBindings);
+ }
+
+ public synchronized void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ List<String> jndiBindings) throws Exception
{
checkInitialised();
JBossConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = new JBossConnectionFactory(connectorConfigs,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- sendWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnNodeShutdown);
+ cf = new JBossConnectionFactory(connectorConfigs);
+ cf.setClientID(clientID);
}
bindConnectionFactory(cf, name, jndiBindings);
-
- return true;
}
- public synchronized boolean createConnectionFactory(final String name,
- final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- final List<String> jndiBindings) throws Exception
+ public synchronized void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ long pingPeriod,
+ long connectionTTL,
+ long callTimeout,
+ int maxConnections,
+ int minLargeMessageSize,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
+ int producerMaxRate,
+ boolean blockOnAcknowledge,
+ boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
+ boolean autoGroup,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int reconnectAttempts,
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception
{
checkInitialised();
JBossConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
cf = new JBossConnectionFactory(connectorConfigs);
+ cf.setClientID(clientID);
+ cf.setPingPeriod(pingPeriod);
+ cf.setConnectionTTL(connectionTTL);
+ cf.setCallTimeout(callTimeout);
+ cf.setMaxConnections(maxConnections);
+ cf.setMinLargeMessageSize(minLargeMessageSize);
+ cf.setConsumerWindowSize(consumerWindowSize);
+ cf.setConsumerMaxRate(consumerMaxRate);
+ cf.setProducerWindowSize(producerWindowSize);
+ cf.setProducerMaxRate(producerMaxRate);
+ cf.setBlockOnAcknowledge(blockOnAcknowledge);
+ cf.setBlockOnPersistentSend(blockOnPersistentSend);
+ cf.setBlockOnNonPersistentSend(blockOnNonPersistentSend);
+ cf.setAutoGroup(autoGroup);
+ cf.setPreAcknowledge(preAcknowledge);
+ cf.setConnectionLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
+ cf.setTransactionBatchSize(transactionBatchSize);
+ cf.setDupsOKBatchSize(dupsOKBatchSize);
+ cf.setUseGlobalPools(useGlobalPools);
+ cf.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
+ cf.setThreadPoolMaxSize(threadPoolMaxSize);
+ cf.setRetryInterval(retryInterval);
+ cf.setRetryInterval(retryInterval);
+ cf.setReconnectAttempts(reconnectAttempts);
+ cf.setFailoverOnServerShutdown(failoverOnServerShutdown);
}
bindConnectionFactory(cf, name, jndiBindings);
+ }
- return true;
+ public synchronized void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ long discoveryRefreshTimeout,
+ long pingPeriod,
+ long connectionTTL,
+ long callTimeout,
+ int maxConnections,
+ int minLargeMessageSize,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
+ int producerMaxRate,
+ boolean blockOnAcknowledge,
+ boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
+ boolean autoGroup,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ long initialWaitTimeout,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int reconnectAttempts,
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception
+ {
+ checkInitialised();
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ cf = new JBossConnectionFactory(discoveryAddress, discoveryPort);
+ cf.setClientID(clientID);
+ cf.setDiscoveryRefreshTimeout(discoveryRefreshTimeout);
+ cf.setPingPeriod(pingPeriod);
+ cf.setConnectionTTL(connectionTTL);
+ cf.setCallTimeout(callTimeout);
+ cf.setMaxConnections(maxConnections);
+ cf.setMinLargeMessageSize(minLargeMessageSize);
+ cf.setConsumerWindowSize(consumerWindowSize);
+ cf.setConsumerMaxRate(consumerMaxRate);
+ cf.setProducerWindowSize(producerWindowSize);
+ cf.setProducerMaxRate(producerMaxRate);
+ cf.setBlockOnAcknowledge(blockOnAcknowledge);
+ cf.setBlockOnPersistentSend(blockOnPersistentSend);
+ cf.setBlockOnNonPersistentSend(blockOnNonPersistentSend);
+ cf.setAutoGroup(autoGroup);
+ cf.setPreAcknowledge(preAcknowledge);
+ cf.setConnectionLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
+ cf.setTransactionBatchSize(transactionBatchSize);
+ cf.setDupsOKBatchSize(dupsOKBatchSize);
+ cf.setDiscoveryInitialWaitTimeout(initialWaitTimeout);
+ cf.setUseGlobalPools(useGlobalPools);
+ cf.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
+ cf.setThreadPoolMaxSize(threadPoolMaxSize);
+ cf.setRetryInterval(retryInterval);
+ cf.setRetryInterval(retryInterval);
+ cf.setReconnectAttempts(reconnectAttempts);
+ cf.setFailoverOnServerShutdown(failoverOnServerShutdown);
+ }
+
+ bindConnectionFactory(cf, name, jndiBindings);
}
- public synchronized boolean createConnectionFactory(String name,
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean preAcknowledge,
- List<String> jndiBindings) throws Exception
+ public synchronized void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ List<String> jndiBindings) throws Exception
{
checkInitialised();
JBossConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = new JBossConnectionFactory(connectorConfigs,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- preAcknowledge);
+ cf = new JBossConnectionFactory(discoveryAddress, discoveryPort);
}
bindConnectionFactory(cf, name, jndiBindings);
+ }
- return true;
+ public synchronized void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ checkInitialised();
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ cf = new JBossConnectionFactory(discoveryAddress, discoveryPort);
+ cf.setClientID(clientID);
+ }
+
+ bindConnectionFactory(cf, name, jndiBindings);
}
- public synchronized boolean createConnectionFactory(final String name,
- final DiscoveryGroupConfiguration discoveryGroupConfig,
- final long discoveryInitialWait,
- final String connectionLoadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int sendWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnNodeShutdown,
- final List<String> jndiBindings) throws Exception
+ public synchronized void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ List<String> jndiBindings) throws Exception
{
checkInitialised();
JBossConnectionFactory cf = connectionFactories.get(name);
if (cf == null)
{
- cf = new JBossConnectionFactory(discoveryGroupConfig.getGroupAddress(),
- discoveryGroupConfig.getGroupPort(),
- discoveryGroupConfig.getRefreshTimeout(),
- discoveryInitialWait,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- sendWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnNodeShutdown);
+ cf = new JBossConnectionFactory(liveTC);
}
bindConnectionFactory(cf, name, jndiBindings);
+ }
- return true;
+ public synchronized void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ checkInitialised();
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ cf = new JBossConnectionFactory(liveTC);
+ cf.setClientID(clientID);
+ }
+
+ bindConnectionFactory(cf, name, jndiBindings);
}
+ public synchronized void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ List<String> jndiBindings) throws Exception
+ {
+ checkInitialised();
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ cf = new JBossConnectionFactory(liveTC, backupTC);
+ }
+
+ bindConnectionFactory(cf, name, jndiBindings);
+ }
+
+ public synchronized void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ checkInitialised();
+ JBossConnectionFactory cf = connectionFactories.get(name);
+ if (cf == null)
+ {
+ cf = new JBossConnectionFactory(liveTC, backupTC);
+ cf.setClientID(clientID);
+ }
+
+ bindConnectionFactory(cf, name, jndiBindings);
+ }
+
public synchronized boolean destroyConnectionFactory(final String name) throws Exception
{
checkInitialised();
@@ -549,6 +648,9 @@
Context c = org.jboss.messaging.utils.JNDIUtil.createContext(context, parentContext);
c.rebind(jndiNameInContext, objectToBind);
+
+ c.close();
+
return true;
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -66,153 +66,96 @@
boolean destroyTopic(@Parameter(name = "name", desc = "Name of the topic to destroy")
String name) throws Exception;
- void createConnectionFactory(String name, String connectorFactoryClassName, String[] jndiBindings) throws Exception;
+ void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ List<String> jndiBindings) throws Exception;
void createConnectionFactory(String name,
- String connectorFactoryClassName,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean preAcknowledge,
- String[] jndiBindings) throws Exception;
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ List<String> jndiBindings) throws Exception;
- void createSimpleConnectionFactory(String name,
- String connectorFactoryClassName,
- String connectionLoadBalancingPolicyClassName,
- long pingPeriod,
- long connectionTTL,
- long callTimeout,
- String clientID,
- int dupsOKBatchSize,
- int transactionBatchSize,
- int consumerWindowSize,
- int consumerMaxRate,
- int producerWindowSize,
- int producerMaxRate,
- int minLargeMessageSize,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean autoGroup,
- int maxConnections,
- boolean preAcknowledge,
- long retryInterval,
- double retryIntervalMultiplier,
- int reconnectAttempts,
- boolean failoverOnNodeShutdown,
- String[] jndiBindings) throws Exception;
+ void createConnectionFactory(String name, TransportConfiguration liveTC, List<String> jndiBindings) throws Exception;
- @Operation(desc = "Create a JMS ConnectionFactory with a static list of servers", impact = ACTION)
- void createConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to create")
- String name,
- @Parameter(name = "connectorConfigs", desc = "List of pairs of live configuration, backup configuration")
+ void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name,
List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- @Parameter(name = "connectionLoadBalancingPolicyClassName", desc = "The name of the class to use for client side connection load-balancing")
- String connectionLoadBalancingPolicyClassName,
- @Parameter(name = "pingPeriod", desc = "The ping period in ms")
+ String clientID,
+ List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name, TransportConfiguration liveTC, String clientID, List<String> jndiBindings) throws Exception;
+
+ void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
long pingPeriod,
- @Parameter(name = "connectionTTL", desc = "The connection TTL in ms")
long connectionTTL,
- @Parameter(name = "callTimeout", desc = "The call timeout in ms")
long callTimeout,
- @Parameter(name = "clientID", desc = "ClientID for created connections")
- String clientID,
- @Parameter(name = "dupsOKBatchSize", desc = "Size of the batch in bytes when using DUPS_OK")
- int dupsOKBatchSize,
- @Parameter(name = "transactionBatchSize", desc = "Size of the batch in bytes when using transacted session")
- int transactionBatchSize,
- @Parameter(name = "consumerWindowSize", desc = "Consumer's window size")
+ int maxConnections,
+ int minLargeMessageSize,
int consumerWindowSize,
- @Parameter(name = "consumerMaxRate", desc = "Consumer's max rate")
int consumerMaxRate,
- @Parameter(name = "producerWindowSize", desc = "Producer's window size")
int producerWindowSize,
- @Parameter(name = "producerMaxRate", desc = "Producer's max rate")
int producerMaxRate,
- @Parameter(name = "minLargeMessageSize", desc = "Size of what is considered a big message requiring sending in chunks")
- int minLargeMessageSize,
- @Parameter(name = "blockOnAcknowledge", desc = "Does acknowlegment block?")
boolean blockOnAcknowledge,
- @Parameter(name = "blockOnNonPersistentSend", desc = "Does sending non persistent messages block?")
- boolean blockOnNonPersistentSend,
- @Parameter(name = "blockOnPersistentSend", desc = "Does sending persistent messages block?")
boolean blockOnPersistentSend,
- @Parameter(name = "autoGroup", desc = "Any Messages sent via this factories connections will automatically set the property 'JBM_GroupID'")
+ boolean blockOnNonPersistentSend,
boolean autoGroup,
- @Parameter(name = "maxConnections", desc = "The maximum number of physical connections created per client using this connection factory. Sessions created will be assigned a connection in a round-robin fashion")
- int maxConnections,
- @Parameter(name = "preAcknowledge", desc = "If the server will acknowledge delivery of a message before it is delivered")
boolean preAcknowledge,
- @Parameter(name = "retryInterval", desc = "The retry interval in ms when retrying connecting to same server")
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
long retryInterval,
- @Parameter(name = "retryIntervalMultiplier", desc = "The retry interval multiplier when retrying connecting to same server")
double retryIntervalMultiplier,
- @Parameter(name = "reconnectAttempts", desc = "The maximum number of attempts to make to establish a connection to the server. -1 means no maximum")
int reconnectAttempts,
- @Parameter(name = "failoverOnNodeShutdown", desc = "If the server is cleanly shutdown, should the client attempt failover to backup (if specified)?")
- boolean failoverOnNodeShutdown,
- @Parameter(name = "jndiBindings", desc = "JNDI Bindings")
- String[] jndiBindings) throws Exception;
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception;
- @Operation(desc = "Create a JMS ConnectionFactory specifying a discovery group to obtain list of servers from", impact = ACTION)
- void createConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to create")
- String name,
- @Parameter(name = "discoveryGroupName", desc = "Name of the Discovery group configuration")
- String discoveryGroupName,
- @Parameter(name = "discoveryGroupAddress", desc = "Address of the Discovery group")
- String discoveryGroupAddress,
- @Parameter(name = "discoveryGroupPort", desc = "port of the Discovery group")
- int discoveryGroupPort,
- @Parameter(name = "discoveryGroupRefreshTimeout", desc = "Refresh timeout of the discovery group")
- long discoveryGroupRefreshTimeout,
- @Parameter(name = "discoveryInitialWait", desc = "The amount of time in ms to wait for initial discovery information to arrive at first using connection factory")
- long discoveryInitialWait,
- @Parameter(name = "connectionLoadBalancingPolicyClassName", desc = "The name of the class to use for client side connection load-balancing")
- String connectionLoadBalancingPolicyClassName,
- @Parameter(name = "pingPeriod", desc = "The ping period in m")
+ void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ long discoveryRefreshTimeout,
long pingPeriod,
- @Parameter(name = "connectionTTL", desc = "The connection TTL in ms")
long connectionTTL,
- @Parameter(name = "callTimeout", desc = "The call timeout in m")
long callTimeout,
- @Parameter(name = "clientID", desc = "ClientID for created connections")
- String clientID,
- @Parameter(name = "dupsOKBatchSize", desc = "Size of the batch in bytes when using DUPS_OK")
- int dupsOKBatchSize,
- @Parameter(name = "transactionBatchSize", desc = "Size of the batch in bytes when using transacted session")
- int transactionBatchSize,
- @Parameter(name = "consumerWindowSize", desc = "Consumer's window size")
+ int maxConnections,
+ int minLargeMessageSize,
int consumerWindowSize,
- @Parameter(name = "consumerMaxRate", desc = "Consumer's max rate")
int consumerMaxRate,
- @Parameter(name = "producerWindowSize", desc = "Producer's window size")
int producerWindowSize,
- @Parameter(name = "producerMaxRate", desc = "Producer's max rate")
int producerMaxRate,
- @Parameter(name = "minLargeMessageSize", desc = "Size of what is considered a big message requiring sending in chunks")
- int minLargeMessageSize,
- @Parameter(name = "blockOnAcknowledge", desc = "Does acknowlegment block?")
boolean blockOnAcknowledge,
- @Parameter(name = "blockOnNonPersistentSend", desc = "Does sending non persistent messages block?")
- boolean blockOnNonPersistentSend,
- @Parameter(name = "blockOnPersistentSend", desc = "Does sending persistent messages block?")
boolean blockOnPersistentSend,
- @Parameter(name = "autoGroup", desc = "Any Messages sent via this factories connections will automatically set the property 'JBM_GroupID'")
+ boolean blockOnNonPersistentSend,
boolean autoGroup,
- @Parameter(name = "maxConnections", desc = "The maximum number of physical connections created per client using this connection factory. Sessions created will be assigned a connection in a round-robin fashion")
- int maxConnections,
- @Parameter(name = "preAcknowledge", desc = "If the server will acknowledge delivery of a message before it is delivered")
boolean preAcknowledge,
- @Parameter(name = "retryInterval", desc = "The retry interval in ms when retrying connecting to same server")
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ long initialWaitTimeout,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
long retryInterval,
- @Parameter(name = "retryIntervalMultiplier", desc = "The retry interval multiplier when retrying connecting to same server")
double retryIntervalMultiplier,
- @Parameter(name = "reconnectAttempts", desc = "The maximum number of attempts to make to establish a connection to the server. -1 means no maximum")
int reconnectAttempts,
- @Parameter(name = "failoverOnNodeShutdown", desc = "If the server is cleanly shutdown, should the client attempt failover to backup (if specified)?")
- boolean failoverOnNodeShutdown,
- @Parameter(name = "jndiBindings", desc = "JNDI Bindings")
- String[] jndiBindings) throws Exception;
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception;
@Operation(desc = "Create a JMS ConnectionFactory", impact = ACTION)
void destroyConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to create")
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSManagementHelper.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -38,7 +38,6 @@
*/
public class JMSManagementHelper
{
-
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,8 +22,6 @@
package org.jboss.messaging.jms.server.management.impl;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
@@ -39,7 +37,6 @@
import javax.management.StandardMBean;
import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
import org.jboss.messaging.jms.server.JMSServerManager;
import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
@@ -79,227 +76,145 @@
// JMSServerControlMBean implementation --------------------------
- public void createSimpleConnectionFactory(String name,
- String connectorFactoryClassName,
- String connectionLoadBalancingPolicyClassName,
- long pingPeriod,
+ public void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ List<String> jndiBindings) throws Exception
+ {
+ server.createConnectionFactory(name, connectorConfigs, jndiBindings);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+
+ public void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ server.createConnectionFactory(name, connectorConfigs, clientID, jndiBindings);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+
+ public void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ long pingPeriod,
long connectionTTL,
long callTimeout,
- String clientID,
- int dupsOKBatchSize,
- int transactionBatchSize,
+ int maxConnections,
+ int minLargeMessageSize,
int consumerWindowSize,
int consumerMaxRate,
int producerWindowSize,
int producerMaxRate,
- int minLargeMessageSize,
boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
boolean autoGroup,
- int maxConnections,
- boolean preAcknowledge,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
long retryInterval,
- double retryIntervalMultiplier,
+ double retryIntervalMultiplier,
int reconnectAttempts,
- boolean failoverOnNodeShutdown,
- String[] jndiBindings) throws Exception
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception
{
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
- connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(connectorFactoryClassName), null));
+ server.createConnectionFactory(name, connectorConfigs, clientID, pingPeriod, connectionTTL, callTimeout, maxConnections, minLargeMessageSize, consumerWindowSize, consumerMaxRate, producerWindowSize, producerMaxRate, blockOnAcknowledge, blockOnPersistentSend, blockOnNonPersistentSend, autoGroup, preAcknowledge, loadBalancingPolicyClassName, transactionBatchSize, dupsOKBatchSize, useGlobalPools, scheduledThreadPoolMaxSize, threadPoolMaxSize, retryInterval, retryIntervalMultiplier, reconnectAttempts, failoverOnServerShutdown, jndiBindings);
- boolean created = server.createConnectionFactory(name,
- connectorConfigs,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnNodeShutdown,
- Arrays.asList(jndiBindings));
- if (created)
- {
- sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
- }
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
}
-
- public void createConnectionFactory(String name,
- String connectorFactoryClassName,
- String[] jndiBindings) throws Exception
- {
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
- connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(connectorFactoryClassName), null));
- boolean created = server.createConnectionFactory(name,
- connectorConfigs,
- Arrays.asList(jndiBindings));
- if (created)
- {
- sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
- }
- }
-
public void createConnectionFactory(String name,
- String connectorFactoryClassName,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean preAcknowledge,
- String[] jndiBindings) throws Exception
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ List<String> jndiBindings) throws Exception
{
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
- connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(connectorFactoryClassName), null));
-
- boolean created = server.createConnectionFactory(name,
- connectorConfigs,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- preAcknowledge,
- Arrays.asList(jndiBindings));
- if (created)
- {
- sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
- }
+ server.createConnectionFactory(name, discoveryAddress, discoveryPort, clientID, jndiBindings);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
}
public void createConnectionFactory(String name,
- List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- String connectionLoadBalancingPolicyClassName,
- long pingPeriod,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ long discoveryRefreshTimeout,
+ long pingPeriod,
long connectionTTL,
long callTimeout,
- String clientID,
- int dupsOKBatchSize,
- int transactionBatchSize,
+ int maxConnections,
+ int minLargeMessageSize,
int consumerWindowSize,
int consumerMaxRate,
int producerWindowSize,
int producerMaxRate,
- int minLargeMessageSize,
boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
boolean autoGroup,
- int maxConnections,
- boolean preAcknowledge,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ long initialWaitTimeout,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
long retryInterval,
- double retryIntervalMultiplier,
+ double retryIntervalMultiplier,
int reconnectAttempts,
- boolean failoverOnNodeShutdown,
- String[] jndiBindings) throws Exception
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception
{
- boolean created = server.createConnectionFactory(name,
- connectorConfigs,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnNodeShutdown,
- Arrays.asList(jndiBindings));
- if (created)
- {
- sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
- }
+ server.createConnectionFactory(name, discoveryAddress, discoveryPort, clientID, discoveryRefreshTimeout, pingPeriod, connectionTTL, callTimeout, maxConnections, minLargeMessageSize, consumerWindowSize, consumerMaxRate, producerWindowSize, producerMaxRate, blockOnAcknowledge, blockOnPersistentSend, blockOnNonPersistentSend, autoGroup, preAcknowledge, loadBalancingPolicyClassName, transactionBatchSize, dupsOKBatchSize, initialWaitTimeout, useGlobalPools, scheduledThreadPoolMaxSize, threadPoolMaxSize, retryInterval, retryIntervalMultiplier, reconnectAttempts, failoverOnServerShutdown, jndiBindings);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
}
-
- public void createConnectionFactory(final String name,
- final String discoveryGroupName,
- final String discoveryGroupAddress,
- final int discoveryGroupPort,
- final long discoveryGroupRefreshTimeout,
- final long discoveryInitialWait,
- final String connectionLoadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int producerWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnNodeShutdown,
- final String[] jndiBindings) throws Exception
- {
- DiscoveryGroupConfiguration discoveryGroupConfig = new DiscoveryGroupConfiguration(discoveryGroupName, discoveryGroupAddress, discoveryGroupPort, discoveryGroupRefreshTimeout);
- boolean created = server.createConnectionFactory(name,
- discoveryGroupConfig,
- discoveryInitialWait,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnNodeShutdown,
- Arrays.asList(jndiBindings));
- if (created)
- {
- sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
- }
+ public void createConnectionFactory(String name, TransportConfiguration liveTC, List<String> jndiBindings) throws Exception
+ {
+ server.createConnectionFactory(name, liveTC, jndiBindings);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
}
+ public void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ server.createConnectionFactory(name, liveTC, clientID, jndiBindings);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+
+ public void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ List<String> jndiBindings) throws Exception
+ {
+ server.createConnectionFactory(name, liveTC, backupTC, jndiBindings);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+
+ public void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ server.createConnectionFactory(name, liveTC, backupTC, clientID, jndiBindings);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+
public boolean createQueue(final String name, final String jndiBinding) throws Exception
{
boolean created = server.createQueue(name, jndiBinding);
@@ -463,4 +378,6 @@
CONNECTION_FACTORY_CREATED,
CONNECTION_FACTORY_DESTROYED;
}
+
+
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -68,78 +68,73 @@
return localControl.closeConnectionsForAddress(ipAddress);
}
- public void createConnectionFactory(final String name,
- final String connectorFactoryClassName,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ List<String> jndiBindings) throws Exception
{
- replicationAwareInvoke("createConnectionFactory", name, connectorFactoryClassName, jndiBindings);
+ replicationAwareInvoke("createConnectionFactory", connectorConfigs, jndiBindings);
}
- public void createConnectionFactory(final String name,
- final String connectorFactoryClassName,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean preAcknowledge,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ List<String> jndiBindings) throws Exception
{
- replicationAwareInvoke("createConnectionFactory",
- name,
- connectorFactoryClassName,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- preAcknowledge,
- jndiBindings);
+ replicationAwareInvoke("createConnectionFactory", connectorConfigs, clientID, jndiBindings);
}
- public void createSimpleConnectionFactory(final String name,
- final String connectorFactoryClassName,
- final String connectionLoadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int producerWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ long pingPeriod,
+ long connectionTTL,
+ long callTimeout,
+ int maxConnections,
+ int minLargeMessageSize,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
+ int producerMaxRate,
+ boolean blockOnAcknowledge,
+ boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
+ boolean autoGroup,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int reconnectAttempts,
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception
{
- replicationAwareInvoke("createSimpleConnectionFactory",
- name,
- connectorFactoryClassName,
- connectionLoadBalancingPolicyClassName,
+ replicationAwareInvoke("createConnectionFactory",
+ connectorConfigs,
+ clientID,
pingPeriod,
connectionTTL,
callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
+ maxConnections,
+ minLargeMessageSize,
consumerWindowSize,
consumerMaxRate,
producerWindowSize,
producerMaxRate,
- minLargeMessageSize,
blockOnAcknowledge,
- blockOnNonPersistentSend,
blockOnPersistentSend,
+ blockOnNonPersistentSend,
autoGroup,
- maxConnections,
preAcknowledge,
+ loadBalancingPolicyClassName,
+ transactionBatchSize,
+ dupsOKBatchSize,
+ useGlobalPools,
+ scheduledThreadPoolMaxSize,
+ threadPoolMaxSize,
retryInterval,
retryIntervalMultiplier,
reconnectAttempts,
@@ -147,116 +142,72 @@
jndiBindings);
}
- public void createConnectionFactory(final String name,
- final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- final String connectionLoadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int producerWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ List<String> jndiBindings) throws Exception
{
- // FIXME need to store correctly the connector configs
- replicationAwareInvoke("createConnectionFactory",
- name,
- connectorConfigs,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnServerShutdown,
- jndiBindings);
+ replicationAwareInvoke("createConnectionFactory", discoveryAddress, discoveryPort, clientID, jndiBindings);
}
- public void createConnectionFactory(final String name,
- final String discoveryGroupName,
- final String discoveryGroupAddress,
- final int discoveryGroupPort,
- final long discoveryGroupRefreshTimeout,
- final long discoveryInitialWait,
- final String connectionLoadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int producerWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ long discoveryRefreshTimeout,
+ long pingPeriod,
+ long connectionTTL,
+ long callTimeout,
+ int maxConnections,
+ int minLargeMessageSize,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
+ int producerMaxRate,
+ boolean blockOnAcknowledge,
+ boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
+ boolean autoGroup,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ long initialWaitTimeout,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int reconnectAttempts,
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception
{
replicationAwareInvoke("createConnectionFactory",
- name,
- discoveryGroupName,
- discoveryGroupAddress,
- discoveryGroupPort,
- discoveryGroupRefreshTimeout,
- discoveryInitialWait,
- connectionLoadBalancingPolicyClassName,
+ discoveryAddress,
+ discoveryPort,
+ clientID,
pingPeriod,
connectionTTL,
callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
+ maxConnections,
+ minLargeMessageSize,
consumerWindowSize,
consumerMaxRate,
producerWindowSize,
producerMaxRate,
- minLargeMessageSize,
blockOnAcknowledge,
- blockOnNonPersistentSend,
blockOnPersistentSend,
+ blockOnNonPersistentSend,
autoGroup,
- maxConnections,
preAcknowledge,
+ loadBalancingPolicyClassName,
+ transactionBatchSize,
+ dupsOKBatchSize,
+ initialWaitTimeout,
+ useGlobalPools,
+ scheduledThreadPoolMaxSize,
+ threadPoolMaxSize,
retryInterval,
retryIntervalMultiplier,
reconnectAttempts,
@@ -264,6 +215,36 @@
jndiBindings);
}
+ public void createConnectionFactory(String name, TransportConfiguration liveTC, List<String> jndiBindings) throws Exception
+ {
+ replicationAwareInvoke("createConnectionFactory", liveTC, jndiBindings);
+ }
+
+ public void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ replicationAwareInvoke("createConnectionFactory", liveTC, clientID, jndiBindings);
+ }
+
+ public void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ List<String> jndiBindings) throws Exception
+ {
+ replicationAwareInvoke("createConnectionFactory", liveTC, backupTC, jndiBindings);
+ }
+
+ public void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ replicationAwareInvoke("createConnectionFactory", liveTC, backupTC, clientID, jndiBindings);
+ }
+
public boolean createQueue(final String name, final String jndiBinding) throws Exception
{
return (Boolean)replicationAwareInvoke("createQueue", name, jndiBinding);
Modified: trunk/src/main/org/jboss/messaging/ra/JBMBytesMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMBytesMessage.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMBytesMessage.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -37,7 +37,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMBytesMessage.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
@@ -46,14 +46,16 @@
* @param message the message
* @param session the session
*/
- public JBMBytesMessage(BytesMessage message, JBMSession session)
+ public JBMBytesMessage(final BytesMessage message, final JBMSession session)
{
super(message, session);
if (trace)
+ {
log.trace("constructor(" + message + ", " + session + ")");
+ }
}
-
+
/**
* Get body length
* @return The value
@@ -62,11 +64,13 @@
public long getBodyLength() throws JMSException
{
if (trace)
+ {
log.trace("getBodyLength()");
+ }
- return ((BytesMessage) message).getBodyLength();
+ return ((BytesMessage)message).getBodyLength();
}
-
+
/**
* Read
* @return The value
@@ -75,11 +79,13 @@
public boolean readBoolean() throws JMSException
{
if (trace)
+ {
log.trace("readBoolean()");
+ }
- return ((BytesMessage) message).readBoolean();
+ return ((BytesMessage)message).readBoolean();
}
-
+
/**
* Read
* @return The value
@@ -88,11 +94,13 @@
public byte readByte() throws JMSException
{
if (trace)
+ {
log.trace("readByte()");
+ }
- return ((BytesMessage) message).readByte();
+ return ((BytesMessage)message).readByte();
}
-
+
/**
* Read
* @param value The value
@@ -100,28 +108,32 @@
* @return The result
* @exception JMSException Thrown if an error occurs
*/
- public int readBytes(byte[] value, int length) throws JMSException
+ public int readBytes(final byte[] value, final int length) throws JMSException
{
if (trace)
+ {
log.trace("readBytes(" + value + ", " + length + ")");
+ }
- return ((BytesMessage) message).readBytes(value, length);
+ return ((BytesMessage)message).readBytes(value, length);
}
-
+
/**
* Read
* @param value The value
* @return The result
* @exception JMSException Thrown if an error occurs
*/
- public int readBytes(byte[] value) throws JMSException
+ public int readBytes(final byte[] value) throws JMSException
{
if (trace)
+ {
log.trace("readBytes(" + value + ")");
+ }
- return ((BytesMessage) message).readBytes(value);
+ return ((BytesMessage)message).readBytes(value);
}
-
+
/**
* Read
* @return The value
@@ -130,11 +142,13 @@
public char readChar() throws JMSException
{
if (trace)
+ {
log.trace("readChar()");
+ }
- return ((BytesMessage) message).readChar();
+ return ((BytesMessage)message).readChar();
}
-
+
/**
* Read
* @return The value
@@ -143,11 +157,13 @@
public double readDouble() throws JMSException
{
if (trace)
+ {
log.trace("readDouble()");
+ }
- return ((BytesMessage) message).readDouble();
+ return ((BytesMessage)message).readDouble();
}
-
+
/**
* Read
* @return The value
@@ -156,11 +172,13 @@
public float readFloat() throws JMSException
{
if (trace)
+ {
log.trace("readFloat()");
+ }
- return ((BytesMessage) message).readFloat();
+ return ((BytesMessage)message).readFloat();
}
-
+
/**
* Read
* @return The value
@@ -169,11 +187,13 @@
public int readInt() throws JMSException
{
if (trace)
+ {
log.trace("readInt()");
+ }
- return ((BytesMessage) message).readInt();
+ return ((BytesMessage)message).readInt();
}
-
+
/**
* Read
* @return The value
@@ -182,11 +202,13 @@
public long readLong() throws JMSException
{
if (trace)
+ {
log.trace("readLong()");
+ }
- return ((BytesMessage) message).readLong();
+ return ((BytesMessage)message).readLong();
}
-
+
/**
* Read
* @return The value
@@ -195,11 +217,13 @@
public short readShort() throws JMSException
{
if (trace)
+ {
log.trace("readShort()");
+ }
- return ((BytesMessage) message).readShort();
+ return ((BytesMessage)message).readShort();
}
-
+
/**
* Read
* @return The value
@@ -208,11 +232,13 @@
public int readUnsignedByte() throws JMSException
{
if (trace)
+ {
log.trace("readUnsignedByte()");
+ }
- return ((BytesMessage) message).readUnsignedByte();
+ return ((BytesMessage)message).readUnsignedByte();
}
-
+
/**
* Read
* @return The value
@@ -221,11 +247,13 @@
public int readUnsignedShort() throws JMSException
{
if (trace)
+ {
log.trace("readUnsignedShort()");
+ }
- return ((BytesMessage) message).readUnsignedShort();
+ return ((BytesMessage)message).readUnsignedShort();
}
-
+
/**
* Read
* @return The value
@@ -234,11 +262,13 @@
public String readUTF() throws JMSException
{
if (trace)
+ {
log.trace("readUTF()");
+ }
- return ((BytesMessage) message).readUTF();
+ return ((BytesMessage)message).readUTF();
}
-
+
/**
* Reset
* @exception JMSException Thrown if an error occurs
@@ -246,37 +276,43 @@
public void reset() throws JMSException
{
if (trace)
+ {
log.trace("reset()");
+ }
- ((BytesMessage) message).reset();
+ ((BytesMessage)message).reset();
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeBoolean(boolean value) throws JMSException
+ public void writeBoolean(final boolean value) throws JMSException
{
if (trace)
+ {
log.trace("writeBoolean(" + value + ")");
+ }
- ((BytesMessage) message).writeBoolean(value);
+ ((BytesMessage)message).writeBoolean(value);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeByte(byte value) throws JMSException
+ public void writeByte(final byte value) throws JMSException
{
if (trace)
+ {
log.trace("writeByte(" + value + ")");
+ }
- ((BytesMessage) message).writeByte(value);
+ ((BytesMessage)message).writeByte(value);
}
-
+
/**
* Write
* @param value The value
@@ -284,90 +320,104 @@
* @param length The length
* @exception JMSException Thrown if an error occurs
*/
- public void writeBytes(byte[] value, int offset, int length) throws JMSException
+ public void writeBytes(final byte[] value, final int offset, final int length) throws JMSException
{
if (trace)
+ {
log.trace("writeBytes(" + value + ", " + offset + ", " + length + ")");
+ }
- ((BytesMessage) message).writeBytes(value, offset, length);
+ ((BytesMessage)message).writeBytes(value, offset, length);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeBytes(byte[] value) throws JMSException
+ public void writeBytes(final byte[] value) throws JMSException
{
if (trace)
+ {
log.trace("writeBytes(" + value + ")");
+ }
- ((BytesMessage) message).writeBytes(value);
+ ((BytesMessage)message).writeBytes(value);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeChar(char value) throws JMSException
+ public void writeChar(final char value) throws JMSException
{
if (trace)
+ {
log.trace("writeChar(" + value + ")");
+ }
- ((BytesMessage) message).writeChar(value);
+ ((BytesMessage)message).writeChar(value);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeDouble(double value) throws JMSException
+ public void writeDouble(final double value) throws JMSException
{
if (trace)
+ {
log.trace("writeDouble(" + value + ")");
+ }
- ((BytesMessage) message).writeDouble(value);
+ ((BytesMessage)message).writeDouble(value);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeFloat(float value) throws JMSException
+ public void writeFloat(final float value) throws JMSException
{
if (trace)
+ {
log.trace("writeFloat(" + value + ")");
+ }
- ((BytesMessage) message).writeFloat(value);
+ ((BytesMessage)message).writeFloat(value);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeInt(int value) throws JMSException
+ public void writeInt(final int value) throws JMSException
{
if (trace)
+ {
log.trace("writeInt(" + value + ")");
+ }
- ((BytesMessage) message).writeInt(value);
+ ((BytesMessage)message).writeInt(value);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeLong(long value) throws JMSException
+ public void writeLong(final long value) throws JMSException
{
if (trace)
+ {
log.trace("writeLong(" + value + ")");
+ }
- ((BytesMessage) message).writeLong(value);
+ ((BytesMessage)message).writeLong(value);
}
/**
@@ -375,12 +425,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeObject(Object value) throws JMSException
+ public void writeObject(final Object value) throws JMSException
{
if (trace)
+ {
log.trace("writeObject(" + value + ")");
+ }
- ((BytesMessage) message).writeObject(value);
+ ((BytesMessage)message).writeObject(value);
}
/**
@@ -388,12 +440,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeShort(short value) throws JMSException
+ public void writeShort(final short value) throws JMSException
{
if (trace)
+ {
log.trace("writeShort(" + value + ")");
+ }
- ((BytesMessage) message).writeShort(value);
+ ((BytesMessage)message).writeShort(value);
}
/**
@@ -401,11 +455,13 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeUTF(String value) throws JMSException
+ public void writeUTF(final String value) throws JMSException
{
if (trace)
+ {
log.trace("writeUTF(" + value + ")");
+ }
- ((BytesMessage) message).writeUTF(value);
+ ((BytesMessage)message).writeUTF(value);
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -37,13 +37,8 @@
* @author <a href="mailto:jesper.pedersen at jboss.com">Jesper Pedersen</a>
* @version $Revision: $
*/
-public interface JBMConnectionFactory extends ConnectionFactory,
- TopicConnectionFactory,
- QueueConnectionFactory,
- XAConnectionFactory,
- XAQueueConnectionFactory,
- XATopicConnectionFactory,
- Serializable
+public interface JBMConnectionFactory extends ConnectionFactory, TopicConnectionFactory, QueueConnectionFactory,
+ XAConnectionFactory, XAQueueConnectionFactory, XATopicConnectionFactory, Serializable
{
/** Connection factory capable of handling connections */
public static final int CONNECTION = 0;
Modified: trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactoryImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMConnectionFactoryImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -53,7 +53,7 @@
private static boolean trace = log.isTraceEnabled();
/** The managed connection factory */
- private JBMManagedConnectionFactory mcf;
+ private final JBMManagedConnectionFactory mcf;
/** The connection manager */
private ConnectionManager cm;
@@ -66,10 +66,12 @@
* @param mcf The managed connection factory
* @param cm The connection manager
*/
- public JBMConnectionFactoryImpl(JBMManagedConnectionFactory mcf, ConnectionManager cm)
+ public JBMConnectionFactoryImpl(final JBMManagedConnectionFactory mcf, final ConnectionManager cm)
{
if (trace)
+ {
log.trace("constructor(" + mcf + ", " + cm + ")");
+ }
this.mcf = mcf;
@@ -78,57 +80,71 @@
// This is standalone usage, no appserver
this.cm = new JBMConnectionManager();
if (trace)
+ {
log.trace("Created new ConnectionManager=" + this.cm);
+ }
}
else
+ {
this.cm = cm;
+ }
if (trace)
+ {
log.trace("Using ManagedConnectionFactory=" + mcf + ", ConnectionManager=" + cm);
+ }
}
/**
* Set the reference
* @param reference The reference
*/
- public void setReference(Reference reference)
+ public void setReference(final Reference reference)
{
if (trace)
+ {
log.trace("setReference(" + reference + ")");
+ }
this.reference = reference;
}
-
+
/**
* Get the reference
* @return The reference
*/
- public Reference getReference()
+ public Reference getReference()
{
if (trace)
+ {
log.trace("getReference()");
+ }
return reference;
}
-
+
/**
* Create a queue connection
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public QueueConnection createQueueConnection() throws JMSException
+ public QueueConnection createQueueConnection() throws JMSException
{
if (trace)
+ {
log.trace("createQueueConnection()");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, QUEUE_CONNECTION);
if (trace)
+ {
log.trace("Created queue connection: " + s);
-
+ }
+
return s;
}
-
+
/**
* Create a queue connection
* @param userName The user name
@@ -136,39 +152,47 @@
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public QueueConnection createQueueConnection(String userName, String password) throws JMSException
+ public QueueConnection createQueueConnection(final String userName, final String password) throws JMSException
{
if (trace)
+ {
log.trace("createQueueConnection(" + userName + ", ****)");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, QUEUE_CONNECTION);
s.setUserName(userName);
s.setPassword(password);
if (trace)
+ {
log.trace("Created queue connection: " + s);
-
+ }
+
return s;
- }
+ }
/**
* Create a topic connection
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public TopicConnection createTopicConnection() throws JMSException
+ public TopicConnection createTopicConnection() throws JMSException
{
if (trace)
+ {
log.trace("createTopicConnection()");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, TOPIC_CONNECTION);
if (trace)
+ {
log.trace("Created topic connection: " + s);
+ }
return s;
}
-
+
/**
* Create a topic connection
* @param userName The user name
@@ -176,17 +200,21 @@
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public TopicConnection createTopicConnection(String userName, String password) throws JMSException
+ public TopicConnection createTopicConnection(final String userName, final String password) throws JMSException
{
if (trace)
+ {
log.trace("createTopicConnection(" + userName + ", ****)");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, TOPIC_CONNECTION);
s.setUserName(userName);
s.setPassword(password);
-
+
if (trace)
+ {
log.trace("Created topic connection: " + s);
+ }
return s;
}
@@ -196,15 +224,19 @@
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public Connection createConnection() throws JMSException
+ public Connection createConnection() throws JMSException
{
if (trace)
+ {
log.trace("createConnection()");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, CONNECTION);
if (trace)
+ {
log.trace("Created connection: " + s);
+ }
return s;
}
@@ -216,39 +248,47 @@
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public Connection createConnection(String userName, String password) throws JMSException
+ public Connection createConnection(final String userName, final String password) throws JMSException
{
if (trace)
+ {
log.trace("createConnection(" + userName + ", ****)");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, CONNECTION);
s.setUserName(userName);
s.setPassword(password);
-
+
if (trace)
+ {
log.trace("Created connection: " + s);
+ }
return s;
- }
+ }
/**
* Create a XA queue connection
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public XAQueueConnection createXAQueueConnection() throws JMSException
+ public XAQueueConnection createXAQueueConnection() throws JMSException
{
if (trace)
+ {
log.trace("createXAQueueConnection()");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, XA_QUEUE_CONNECTION);
if (trace)
+ {
log.trace("Created queue connection: " + s);
-
+ }
+
return s;
}
-
+
/**
* Create a XA queue connection
* @param userName The user name
@@ -256,39 +296,47 @@
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public XAQueueConnection createXAQueueConnection(String userName, String password) throws JMSException
+ public XAQueueConnection createXAQueueConnection(final String userName, final String password) throws JMSException
{
if (trace)
+ {
log.trace("createXAQueueConnection(" + userName + ", ****)");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, XA_QUEUE_CONNECTION);
s.setUserName(userName);
s.setPassword(password);
if (trace)
+ {
log.trace("Created queue connection: " + s);
-
+ }
+
return s;
- }
+ }
/**
* Create a XA topic connection
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public XATopicConnection createXATopicConnection() throws JMSException
+ public XATopicConnection createXATopicConnection() throws JMSException
{
if (trace)
+ {
log.trace("createXATopicConnection()");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, XA_TOPIC_CONNECTION);
if (trace)
+ {
log.trace("Created topic connection: " + s);
+ }
return s;
}
-
+
/**
* Create a XA topic connection
* @param userName The user name
@@ -296,17 +344,21 @@
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public XATopicConnection createXATopicConnection(String userName, String password) throws JMSException
+ public XATopicConnection createXATopicConnection(final String userName, final String password) throws JMSException
{
if (trace)
+ {
log.trace("createXATopicConnection(" + userName + ", ****)");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, XA_TOPIC_CONNECTION);
s.setUserName(userName);
s.setPassword(password);
-
+
if (trace)
+ {
log.trace("Created topic connection: " + s);
+ }
return s;
}
@@ -316,15 +368,19 @@
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public XAConnection createXAConnection() throws JMSException
+ public XAConnection createXAConnection() throws JMSException
{
if (trace)
+ {
log.trace("createXAConnection()");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, XA_CONNECTION);
if (trace)
+ {
log.trace("Created connection: " + s);
+ }
return s;
}
@@ -336,18 +392,22 @@
* @return The connection
* @exception JMSException Thrown if the operation fails
*/
- public XAConnection createXAConnection(String userName, String password) throws JMSException
+ public XAConnection createXAConnection(final String userName, final String password) throws JMSException
{
if (trace)
+ {
log.trace("createXAConnection(" + userName + ", ****)");
+ }
JBMSessionFactoryImpl s = new JBMSessionFactoryImpl(mcf, cm, XA_CONNECTION);
s.setUserName(userName);
s.setPassword(password);
-
+
if (trace)
+ {
log.trace("Created connection: " + s);
+ }
return s;
- }
+ }
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMConnectionManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMConnectionManager.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMConnectionManager.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -23,9 +23,9 @@
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
-import javax.resource.spi.ManagedConnectionFactory;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
import org.jboss.messaging.core.logging.Logger;
@@ -43,17 +43,19 @@
/** The logger */
private static final Logger log = Logger.getLogger(JBMConnectionManager.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
-
+
/**
* Constructor
*/
public JBMConnectionManager()
{
if (trace)
+ {
log.trace("constructor()");
+ }
}
/**
@@ -63,19 +65,21 @@
* @return The connection
* @exception ResourceException Thrown if there is a problem obtaining the connection
*/
- public Object allocateConnection(ManagedConnectionFactory mcf,
- ConnectionRequestInfo cxRequestInfo)
- throws ResourceException
+ public Object allocateConnection(final ManagedConnectionFactory mcf, final ConnectionRequestInfo cxRequestInfo) throws ResourceException
{
if (trace)
+ {
log.trace("allocateConnection(" + mcf + ", " + cxRequestInfo + ")");
-
+ }
+
ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo);
Object c = mc.getConnection(null, cxRequestInfo);
if (trace)
+ {
log.trace("Allocated connection: " + c + ", with managed connection: " + mc);
-
+ }
+
return c;
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMConnectionMetaData.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMConnectionMetaData.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMConnectionMetaData.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -39,7 +39,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMConnectionMetaData.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
@@ -49,7 +49,9 @@
public JBMConnectionMetaData()
{
if (trace)
+ {
log.trace("constructor()");
+ }
}
/**
@@ -59,11 +61,13 @@
public String getJMSVersion()
{
if (trace)
+ {
log.trace("getJMSVersion()");
+ }
return "1.1";
}
-
+
/**
* Get the JMS major version
* @return The major version
@@ -71,11 +75,13 @@
public int getJMSMajorVersion()
{
if (trace)
+ {
log.trace("getJMSMajorVersion()");
+ }
return 1;
}
-
+
/**
* Get the JMS minor version
* @return The minor version
@@ -83,7 +89,9 @@
public int getJMSMinorVersion()
{
if (trace)
+ {
log.trace("getJMSMinorVersion()");
+ }
return 1;
}
@@ -95,7 +103,9 @@
public String getJMSProviderName()
{
if (trace)
+ {
log.trace("getJMSProviderName()");
+ }
return "JBoss Messaging";
}
@@ -107,7 +117,9 @@
public String getProviderVersion()
{
if (trace)
+ {
log.trace("getJMSProviderName()");
+ }
return "2.0";
}
@@ -119,7 +131,9 @@
public int getProviderMajorVersion()
{
if (trace)
+ {
log.trace("getProviderMajorVersion()");
+ }
return 2;
}
@@ -131,7 +145,9 @@
public int getProviderMinorVersion()
{
if (trace)
+ {
log.trace("getProviderMinorVersion()");
+ }
return 0;
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMConnectionRequestInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMConnectionRequestInfo.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMConnectionRequestInfo.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,7 +22,6 @@
package org.jboss.messaging.ra;
import javax.jms.Session;
-
import javax.resource.spi.ConnectionRequestInfo;
import org.jboss.messaging.core.logging.Logger;
@@ -39,7 +38,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMConnectionRequestInfo.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
@@ -56,45 +55,49 @@
private boolean useXA;
/** The type */
- private int type;
+ private final int type;
/** Use transactions */
- private boolean transacted;
+ private final boolean transacted;
/** The acknowledge mode */
- private int acknowledgeMode;
+ private final int acknowledgeMode;
/**
* Constructor
* @param prop The resource adapter properties
* @param type The connection type
*/
- public JBMConnectionRequestInfo(JBMRAProperties prop, int type)
+ public JBMConnectionRequestInfo(final JBMRAProperties prop, final int type)
{
if (trace)
+ {
log.trace("constructor(" + prop + ")");
+ }
- this.userName = prop.getUserName();
- this.password = prop.getPassword();
- this.clientID = prop.getClientID();
- this.useXA = prop.isUseXA();
+ userName = prop.getUserName();
+ password = prop.getPassword();
+ clientID = prop.getClientID();
+ useXA = prop.isUseXA();
this.type = type;
- this.transacted = true;
- this.acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
+ transacted = true;
+ acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
}
/**
* Constructor
* @param type The connection type
*/
- public JBMConnectionRequestInfo(int type)
+ public JBMConnectionRequestInfo(final int type)
{
if (trace)
+ {
log.trace("constructor(" + type + ")");
+ }
this.type = type;
- this.transacted = true;
- this.acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
+ transacted = true;
+ acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
}
/**
@@ -103,10 +106,12 @@
* @param acknowledgeMode The acknowledge mode
* @param type The connection type
*/
- public JBMConnectionRequestInfo(boolean transacted, int acknowledgeMode, int type)
+ public JBMConnectionRequestInfo(final boolean transacted, final int acknowledgeMode, final int type)
{
if (trace)
+ {
log.trace("constructor(" + transacted + ", " + acknowledgeMode + ", " + type + ")");
+ }
this.transacted = transacted;
this.acknowledgeMode = acknowledgeMode;
@@ -117,17 +122,25 @@
* Fill in default values if they are missing
* @param prop The resource adapter properties
*/
- public void setDefaults(JBMRAProperties prop)
+ public void setDefaults(final JBMRAProperties prop)
{
if (trace)
+ {
log.trace("setDefaults(" + prop + ")");
+ }
if (userName == null)
+ {
userName = prop.getUserName();
- if (password == null)
+ }
+ if (password == null)
+ {
password = prop.getPassword();
- if (clientID == null)
+ }
+ if (clientID == null)
+ {
clientID = prop.getClientID();
+ }
useXA = prop.isUseXA();
}
@@ -135,34 +148,40 @@
* Get the user name
* @return The value
*/
- public String getUserName()
+ public String getUserName()
{
if (trace)
+ {
log.trace("getUserName()");
+ }
return userName;
}
-
+
/**
* Set the user name
* @param userName The value
*/
- public void setUserName(String userName)
+ public void setUserName(final String userName)
{
if (trace)
+ {
log.trace("setUserName(" + userName + ")");
+ }
this.userName = userName;
}
-
+
/**
* Get the password
* @return The value
*/
- public String getPassword()
+ public String getPassword()
{
if (trace)
+ {
log.trace("getPassword()");
+ }
return password;
}
@@ -171,22 +190,26 @@
* Set the password
* @param password The value
*/
- public void setPassword(String password)
+ public void setPassword(final String password)
{
if (trace)
+ {
log.trace("setPassword(****)");
+ }
this.password = password;
}
-
+
/**
* Get the client id
* @return The value
*/
- public String getClientID()
+ public String getClientID()
{
if (trace)
+ {
log.trace("getClientID()");
+ }
return clientID;
}
@@ -195,13 +218,16 @@
* Set the client id
* @param clientID The value
*/
- public void setClientID(String clientID)
+ public void setClientID(final String clientID)
{
if (trace)
+ {
log.trace("setClientID(" + clientID + ")");
+ }
this.clientID = clientID;
}
+
/**
* Get the connection type
* @return The type
@@ -209,7 +235,9 @@
public int getType()
{
if (trace)
+ {
log.trace("getType()");
+ }
return type;
}
@@ -221,7 +249,9 @@
public boolean isUseXA()
{
if (trace)
+ {
log.trace("isUseXA()");
+ }
return useXA;
}
@@ -233,7 +263,9 @@
public boolean isTransacted()
{
if (trace)
+ {
log.trace("isTransacted()");
+ }
return transacted;
}
@@ -245,7 +277,9 @@
public int getAcknowledgeMode()
{
if (trace)
+ {
log.trace("getAcknowledgeMode()");
+ }
return acknowledgeMode;
}
@@ -255,47 +289,56 @@
* @param obj Object with which to compare
* @return True if this object is the same as the obj argument; false otherwise.
*/
- public boolean equals(Object obj)
+ @Override
+ public boolean equals(final Object obj)
{
if (trace)
+ {
log.trace("equals(" + obj + ")");
+ }
- if (obj == null)
+ if (obj == null)
+ {
return false;
+ }
if (obj instanceof JBMConnectionRequestInfo)
{
- JBMConnectionRequestInfo you = (JBMConnectionRequestInfo) obj;
- return (Util.compare(userName, you.getUserName()) &&
- Util.compare(password, you.getPassword()) &&
- Util.compare(clientID, you.getClientID()) &&
- (type == you.getType()) &&
- (useXA == you.isUseXA()) &&
- (transacted == you.isTransacted()) &&
- (acknowledgeMode == you.getAcknowledgeMode()));
+ JBMConnectionRequestInfo you = (JBMConnectionRequestInfo)obj;
+ return Util.compare(userName, you.getUserName()) && Util.compare(password, you.getPassword()) &&
+ Util.compare(clientID, you.getClientID()) &&
+ type == you.getType() &&
+ useXA == you.isUseXA() &&
+ transacted == you.isTransacted() &&
+ acknowledgeMode == you.getAcknowledgeMode();
}
else
+ {
return false;
+ }
}
-
+
/**
* Return the hash code for the object
* @return The hash code
*/
+ @Override
public int hashCode()
{
if (trace)
+ {
log.trace("hashCode()");
+ }
int hash = 7;
-
+
hash += 31 * hash + (userName != null ? userName.hashCode() : 0);
hash += 31 * hash + (password != null ? password.hashCode() : 0);
hash += 31 * hash + Integer.valueOf(type).hashCode();
hash += 31 * hash + (useXA ? 1 : 0);
hash += 31 * hash + (transacted ? 1 : 0);
hash += 31 * hash + Integer.valueOf(acknowledgeMode).hashCode();
-
+
return hash;
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMCredential.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMCredential.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMCredential.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -48,7 +48,7 @@
/** The logger */
private static final Logger log = Logger.getLogger(JBMCredential.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
@@ -64,7 +64,9 @@
private JBMCredential()
{
if (trace)
+ {
log.trace("constructor()");
+ }
}
/**
@@ -74,7 +76,9 @@
public String getUserName()
{
if (trace)
+ {
log.trace("getUserName()");
+ }
return userName;
}
@@ -83,14 +87,16 @@
* Set the user name
* @param userName The value
*/
- private void setUserName(String userName)
+ private void setUserName(final String userName)
{
if (trace)
+ {
log.trace("setUserName(" + userName + ")");
+ }
this.userName = userName;
}
-
+
/**
* Get the password
* @return The value
@@ -98,7 +104,9 @@
public String getPassword()
{
if (trace)
+ {
log.trace("getPassword()");
+ }
return password;
}
@@ -107,10 +115,12 @@
* Set the password
* @param password The value
*/
- private void setPassword(String password)
+ private void setPassword(final String password)
{
if (trace)
+ {
log.trace("setPassword(****)");
+ }
this.password = password;
}
@@ -123,11 +133,14 @@
* @return The credentials
* @exception SecurityException Thrown if the credentials cant be retrieved
*/
- public static JBMCredential getCredential(ManagedConnectionFactory mcf, Subject subject, ConnectionRequestInfo info)
- throws SecurityException
+ public static JBMCredential getCredential(final ManagedConnectionFactory mcf,
+ final Subject subject,
+ final ConnectionRequestInfo info) throws SecurityException
{
if (trace)
+ {
log.trace("getCredential(" + mcf + ", " + subject + ", " + info + ")");
+ }
JBMCredential jc = new JBMCredential();
if (subject == null && info != null)
@@ -140,7 +153,9 @@
PasswordCredential pwdc = GetCredentialAction.getCredential(subject, mcf);
if (pwdc == null)
+ {
throw new SecurityException("No password credentials found");
+ }
jc.setUserName(pwdc.getUserName());
jc.setPassword(new String(pwdc.getPassword()));
@@ -157,39 +172,44 @@
* String representation
* @return The representation
*/
+ @Override
public String toString()
{
if (trace)
+ {
log.trace("toString()");
+ }
return super.toString() + "{ username=" + userName + ", password=**** }";
}
-
+
/**
* Privileged class to get credentials
*/
private static class GetCredentialAction implements PrivilegedAction<PasswordCredential>
{
/** The subject */
- private Subject subject;
+ private final Subject subject;
/** The managed connection factory */
- private ManagedConnectionFactory mcf;
+ private final ManagedConnectionFactory mcf;
/**
* Constructor
* @param subject The subject
* @param mcf The managed connection factory
*/
- GetCredentialAction(Subject subject, ManagedConnectionFactory mcf)
+ GetCredentialAction(final Subject subject, final ManagedConnectionFactory mcf)
{
if (trace)
+ {
log.trace("constructor(" + subject + ", " + mcf + ")");
+ }
this.subject = subject;
this.mcf = mcf;
}
-
+
/**
* Run
* @return The credential
@@ -197,12 +217,14 @@
public PasswordCredential run()
{
if (trace)
+ {
log.trace("run()");
-
+ }
+
Set<PasswordCredential> creds = subject.getPrivateCredentials(PasswordCredential.class);
PasswordCredential pwdc = null;
-
- for (PasswordCredential curCred: creds)
+
+ for (PasswordCredential curCred : creds)
{
if (curCred.getManagedConnectionFactory().equals(mcf))
{
@@ -219,13 +241,15 @@
* @param mcf The managed connection factory
* @return The credential
*/
- static PasswordCredential getCredential(Subject subject, ManagedConnectionFactory mcf)
+ static PasswordCredential getCredential(final Subject subject, final ManagedConnectionFactory mcf)
{
if (trace)
+ {
log.trace("getCredential(" + subject + ", " + mcf + ")");
+ }
GetCredentialAction action = new GetCredentialAction(subject, mcf);
- return (PasswordCredential) AccessController.doPrivileged(action);
+ return AccessController.doPrivileged(action);
}
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMLocalTransaction.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMLocalTransaction.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMLocalTransaction.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -38,21 +38,23 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMLocalTransaction.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
/** The managed connection */
- private JBMManagedConnection mc;
-
+ private final JBMManagedConnection mc;
+
/**
* Constructor
* @param mc The managed connection
*/
- public JBMLocalTransaction(JBMManagedConnection mc)
+ public JBMLocalTransaction(final JBMManagedConnection mc)
{
if (trace)
+ {
log.trace("constructor(" + mc + ")");
+ }
this.mc = mc;
}
@@ -75,7 +77,9 @@
try
{
if (mc.getSession().getTransacted())
+ {
mc.getSession().commit();
+ }
}
catch (JMSException e)
{
@@ -97,7 +101,9 @@
try
{
if (mc.getSession().getTransacted())
+ {
mc.getSession().rollback();
+ }
}
catch (JMSException ex)
{
Modified: trunk/src/main/org/jboss/messaging/ra/JBMMCFProperties.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMMCFProperties.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMMCFProperties.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -44,7 +44,7 @@
/** The logger */
private static final Logger log = Logger.getLogger(JBMMCFProperties.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
@@ -54,10 +54,9 @@
/** The topic type */
private static final String TOPIC_TYPE = Topic.class.getName();
-
/** The transport config, changing the default configured from the RA */
private Map<String, Object> connectionParameters;
-
+
public String strConnectionParameters;
/** The transport type, changing the default configured from the RA */
@@ -68,14 +67,16 @@
/** Use tryLock */
private Integer useTryLock;
-
+
/**
* Constructor
*/
public JBMMCFProperties()
{
if (trace)
+ {
log.trace("constructor()");
+ }
useTryLock = null;
}
@@ -87,11 +88,13 @@
public int getType()
{
if (trace)
+ {
log.trace("getType()");
+ }
return type;
}
-
+
/**
* @return the connectionParameters
*/
@@ -99,18 +102,18 @@
{
return strConnectionParameters;
}
-
+
public Map<String, Object> getParsedConnectionParameters()
{
return connectionParameters;
}
- public void setConnectionParameters(String configuration)
+ public void setConnectionParameters(final String configuration)
{
- this.strConnectionParameters = configuration;
- this.connectionParameters = Util.parseConfig(configuration);
+ strConnectionParameters = configuration;
+ connectionParameters = Util.parseConfig(configuration);
}
-
+
/**
* @return the transportType
*/
@@ -118,27 +121,35 @@
{
return connectorClassName;
}
-
- public void setConnectorClassName(String value)
+
+ public void setConnectorClassName(final String value)
{
- this.connectorClassName = value;
+ connectorClassName = value;
}
/**
* Set the default session type.
* @param defaultType either javax.jms.Topic or javax.jms.Queue
*/
- public void setSessionDefaultType(String defaultType)
+ public void setSessionDefaultType(final String defaultType)
{
if (trace)
+ {
log.trace("setSessionDefaultType(" + type + ")");
+ }
if (defaultType.equals(QUEUE_TYPE))
- this.type = JBMConnectionFactory.QUEUE_CONNECTION;
- else if(defaultType.equals(TOPIC_TYPE))
- this.type = JBMConnectionFactory.TOPIC_CONNECTION;
+ {
+ type = JBMConnectionFactory.QUEUE_CONNECTION;
+ }
+ else if (defaultType.equals(TOPIC_TYPE))
+ {
+ type = JBMConnectionFactory.TOPIC_CONNECTION;
+ }
else
- this.type = JBMConnectionFactory.CONNECTION;
+ {
+ type = JBMConnectionFactory.CONNECTION;
+ }
}
/**
@@ -148,14 +159,22 @@
public String getSessionDefaultType()
{
if (trace)
+ {
log.trace("getSessionDefaultType()");
+ }
if (type == JBMConnectionFactory.CONNECTION)
+ {
return "BOTH";
+ }
else if (type == JBMConnectionFactory.QUEUE_CONNECTION)
+ {
return TOPIC_TYPE;
+ }
else
+ {
return QUEUE_TYPE;
+ }
}
/**
@@ -165,58 +184,69 @@
public Integer getUseTryLock()
{
if (trace)
+ {
log.trace("getUseTryLock()");
+ }
return useTryLock;
}
-
+
/**
* Set the useTryLock.
* @param useTryLock the useTryLock.
*/
- public void setUseTryLock(Integer useTryLock)
+ public void setUseTryLock(final Integer useTryLock)
{
if (trace)
+ {
log.trace("setUseTryLock(" + useTryLock + ")");
+ }
this.useTryLock = useTryLock;
}
-
+
/**
* Indicates whether some other object is "equal to" this one.
* @param obj Object with which to compare
* @return True if this object is the same as the obj argument; false otherwise.
*/
- public boolean equals(Object obj)
+ @Override
+ public boolean equals(final Object obj)
{
if (trace)
+ {
log.trace("equals(" + obj + ")");
+ }
- if (obj == null)
+ if (obj == null)
+ {
return false;
-
+ }
+
if (obj instanceof JBMMCFProperties)
{
- JBMMCFProperties you = (JBMMCFProperties) obj;
- return (type == you.getType() &&
- Util.compare(useTryLock, you.getUseTryLock()));
+ JBMMCFProperties you = (JBMMCFProperties)obj;
+ return type == you.getType() && Util.compare(useTryLock, you.getUseTryLock());
}
-
+
return false;
}
-
+
/**
* Return the hash code for the object
* @return The hash code
*/
+ @Override
public int hashCode()
{
if (trace)
+ {
log.trace("hashCode()");
+ }
int hash = 7;
- hash += 31 * hash + (Integer.valueOf(type).hashCode());
+ hash += 31 * hash + Integer.valueOf(type).hashCode();
hash += 31 * hash + (useTryLock != null ? useTryLock.hashCode() : 0);
return hash;
Modified: trunk/src/main/org/jboss/messaging/ra/JBMManagedConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMManagedConnection.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMManagedConnection.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -72,43 +72,51 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMManagedConnection.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
-
+
/** The managed connection factory */
- private JBMManagedConnectionFactory mcf;
+ private final JBMManagedConnectionFactory mcf;
/** The connection request information */
- private JBMConnectionRequestInfo cri;
+ private final JBMConnectionRequestInfo cri;
/** The user name */
- private String userName;
+ private final String userName;
/** The password */
- private String password;
+ private final String password;
/** Has the connection been destroyed */
- private AtomicBoolean isDestroyed = new AtomicBoolean(false);
+ private final AtomicBoolean isDestroyed = new AtomicBoolean(false);
/** Event listeners */
- private List<ConnectionEventListener> eventListeners;
-
+ private final List<ConnectionEventListener> eventListeners;
+
/** Handles */
- private Set<JBMSession> handles;
+ private final Set<JBMSession> handles;
/** Lock */
private ReentrantLock lock = new ReentrantLock();
-
+
// Physical JMS connection stuff
private Connection connection;
+
private XAConnection xaConnection;
+
private Session session;
+
private TopicSession topicSession;
+
private QueueSession queueSession;
+
private XASession xaSession;
+
private XATopicSession xaTopicSession;
+
private XAQueueSession xaQueueSession;
+
private XAResource xaResource;
/**
@@ -118,31 +126,32 @@
* @param userName The user name
* @param password The password
*/
- public JBMManagedConnection(JBMManagedConnectionFactory mcf,
- JBMConnectionRequestInfo cri,
- String userName,
- String password)
- throws ResourceException
+ public JBMManagedConnection(final JBMManagedConnectionFactory mcf,
+ final JBMConnectionRequestInfo cri,
+ final String userName,
+ final String password) throws ResourceException
{
if (trace)
+ {
log.trace("constructor(" + mcf + ", " + cri + ", " + userName + ", ****)");
+ }
this.mcf = mcf;
this.cri = cri;
this.userName = userName;
this.password = password;
- this.eventListeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>());
- this.handles = Collections.synchronizedSet(new HashSet<JBMSession>());
+ eventListeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>());
+ handles = Collections.synchronizedSet(new HashSet<JBMSession>());
- this.connection = null;
- this.xaConnection = null;
- this.session = null;
- this.topicSession = null;
- this.queueSession = null;
- this.xaSession = null;
- this.xaTopicSession = null;
- this.xaQueueSession = null;
- this.xaResource = null;
+ connection = null;
+ xaConnection = null;
+ session = null;
+ topicSession = null;
+ queueSession = null;
+ xaSession = null;
+ xaTopicSession = null;
+ xaQueueSession = null;
+ xaResource = null;
try
{
@@ -168,24 +177,31 @@
* @return The connection
* @exception ResourceException Thrown if an error occurs
*/
- public synchronized Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo)
- throws ResourceException
+ public synchronized Object getConnection(final Subject subject, final ConnectionRequestInfo cxRequestInfo) throws ResourceException
{
if (trace)
+ {
log.trace("getConnection(" + subject + ", " + cxRequestInfo + ")");
+ }
// Check user first
JBMCredential credential = JBMCredential.getCredential(mcf, subject, cxRequestInfo);
// Null users are allowed!
if (userName != null && !userName.equals(credential.getUserName()))
+ {
throw new SecurityException("Password credentials not the same, reauthentication not allowed");
+ }
if (userName == null && credential.getUserName() != null)
+ {
throw new SecurityException("Password credentials not the same, reauthentication not allowed");
+ }
if (isDestroyed.get())
+ {
throw new IllegalStateException("The managed connection is already destroyed");
+ }
JBMSession session = new JBMSession(this, (JBMConnectionRequestInfo)cxRequestInfo);
handles.add(session);
@@ -199,22 +215,28 @@
private void destroyHandles() throws ResourceException
{
if (trace)
+ {
log.trace("destroyHandles()");
+ }
try
{
if (xaConnection != null)
- xaConnection.stop();
+ {
+ xaConnection.stop();
+ }
if (connection != null)
- connection.stop();
+ {
+ connection.stop();
+ }
}
catch (Throwable t)
{
log.trace("Ignored error stopping connection", t);
}
-
- for (JBMSession session: handles)
+
+ for (JBMSession session : handles)
{
session.destroy();
}
@@ -229,10 +251,14 @@
public void destroy() throws ResourceException
{
if (trace)
+ {
log.trace("destroy()");
+ }
- if (isDestroyed.get() || (xaConnection == null && connection == null))
+ if (isDestroyed.get() || xaConnection == null && connection == null)
+ {
return;
+ }
isDestroyed.set(true);
@@ -251,30 +277,42 @@
{
log.debug("Error unsetting the exception listener " + this, e);
}
-
+
destroyHandles();
-
+
try
{
try
{
if (topicSession != null)
+ {
topicSession.close();
+ }
if (xaTopicSession != null)
+ {
xaTopicSession.close();
+ }
if (queueSession != null)
+ {
queueSession.close();
+ }
if (xaQueueSession != null)
+ {
xaQueueSession.close();
+ }
if (session != null)
+ {
session.close();
+ }
if (xaSession != null)
+ {
xaSession.close();
+ }
}
catch (JMSException e)
{
@@ -282,10 +320,14 @@
}
if (connection != null)
+ {
connection.close();
+ }
if (xaConnection != null)
+ {
xaConnection.close();
+ }
}
catch (Throwable e)
{
@@ -300,10 +342,14 @@
public void cleanup() throws ResourceException
{
if (trace)
+ {
log.trace("cleanup()");
+ }
if (isDestroyed.get())
+ {
throw new IllegalStateException("ManagedConnection already destroyed");
+ }
destroyHandles();
@@ -323,7 +369,9 @@
public void associateConnection(final Object obj) throws ResourceException
{
if (trace)
+ {
log.trace("associateConnection(" + obj + ")");
+ }
if (!isDestroyed.get() && obj instanceof JBMSession)
{
@@ -332,7 +380,9 @@
handles.add(h);
}
else
+ {
throw new IllegalStateException("ManagedConnection in an illegal state");
+ }
}
/**
@@ -341,7 +391,9 @@
protected void lock()
{
if (trace)
+ {
log.trace("lock()");
+ }
lock.lock();
}
@@ -353,7 +405,9 @@
protected void tryLock() throws JMSException
{
if (trace)
+ {
log.trace("tryLock()");
+ }
Integer tryLock = mcf.getUseTryLock();
if (tryLock == null || tryLock.intValue() <= 0)
@@ -364,7 +418,9 @@
try
{
if (lock.tryLock(tryLock.intValue(), TimeUnit.SECONDS) == false)
+ {
throw new ResourceAllocationException("Unable to obtain lock in " + tryLock + " seconds: " + this);
+ }
}
catch (InterruptedException e)
{
@@ -378,7 +434,9 @@
protected void unlock()
{
if (trace)
+ {
log.trace("unlock()");
+ }
lock.unlock();
}
@@ -387,11 +445,13 @@
* Add a connection event listener.
* @param l The connection event listener to be added.
*/
- public void addConnectionEventListener(ConnectionEventListener l)
+ public void addConnectionEventListener(final ConnectionEventListener l)
{
if (trace)
+ {
log.trace("addConnectionEventListener(" + l + ")");
-
+ }
+
eventListeners.add(l);
}
@@ -399,10 +459,12 @@
* Remove a connection event listener.
* @param l The connection event listener to be removed.
*/
- public void removeConnectionEventListener(ConnectionEventListener l)
+ public void removeConnectionEventListener(final ConnectionEventListener l)
{
if (trace)
+ {
log.trace("removeConnectionEventListener(" + l + ")");
+ }
eventListeners.remove(l);
}
@@ -415,10 +477,14 @@
public XAResource getXAResource() throws ResourceException
{
if (trace)
+ {
log.trace("getXAResource()");
-
+ }
+
if (xaConnection == null)
+ {
throw new NotSupportedException("Non XA transaction not supported");
+ }
//
// Spec says a mc must allways return the same XA resource,
@@ -427,15 +493,23 @@
if (xaResource == null)
{
if (xaTopicSession != null)
+ {
xaResource = xaTopicSession.getXAResource();
+ }
else if (xaQueueSession != null)
+ {
xaResource = xaQueueSession.getXAResource();
+ }
else
+ {
xaResource = xaSession.getXAResource();
+ }
}
if (trace)
+ {
log.trace("XAResource=" + xaResource);
+ }
xaResource = new JBMXAResource(this, xaResource);
return xaResource;
@@ -449,12 +523,16 @@
public LocalTransaction getLocalTransaction() throws ResourceException
{
if (trace)
+ {
log.trace("getLocalTransaction()");
-
+ }
+
LocalTransaction tx = new JBMLocalTransaction(this);
if (trace)
+ {
log.trace("LocalTransaction=" + tx);
+ }
return tx;
}
@@ -468,10 +546,14 @@
public ManagedConnectionMetaData getMetaData() throws ResourceException
{
if (trace)
+ {
log.trace("getMetaData()");
-
+ }
+
if (isDestroyed.get())
+ {
throw new IllegalStateException("The managed connection is already destroyed");
+ }
return new JBMMetaData(this);
}
@@ -481,10 +563,12 @@
* @param out The log writer
* @exception ResourceException If operation fails
*/
- public void setLogWriter(PrintWriter out) throws ResourceException
+ public void setLogWriter(final PrintWriter out) throws ResourceException
{
if (trace)
+ {
log.trace("setLogWriter(" + out + ")");
+ }
}
/**
@@ -495,7 +579,9 @@
public PrintWriter getLogWriter() throws ResourceException
{
if (trace)
+ {
log.trace("getLogWriter()");
+ }
return null;
}
@@ -504,15 +590,19 @@
* Notifies user of a JMS exception.
* @param exception The JMS exception
*/
- public void onException(JMSException exception)
+ public void onException(final JMSException exception)
{
if (trace)
+ {
log.trace("onException(" + exception + ")");
+ }
if (isDestroyed.get())
{
if (trace)
+ {
log.trace("Ignoring error on already destroyed connection " + this, exception);
+ }
return;
}
@@ -533,11 +623,11 @@
{
log.debug("Unable to unset exception listener", e);
}
-
+
ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, exception);
sendEvent(event);
}
-
+
/**
* Is managed connection running in XA mode
* @return True if XA; otherwise false
@@ -545,7 +635,9 @@
protected boolean isXA()
{
if (trace)
+ {
log.trace("isXA()");
+ }
return xaConnection != null;
}
@@ -557,19 +649,29 @@
protected XASession getXASession()
{
if (trace)
+ {
log.trace("getXASession()");
+ }
if (isXA())
{
if (xaTopicSession != null)
+ {
return xaTopicSession;
+ }
else if (xaQueueSession != null)
+ {
return xaQueueSession;
+ }
else
+ {
return xaSession;
+ }
}
else
+ {
return null;
+ }
}
/**
@@ -579,34 +681,44 @@
protected Session getSession()
{
if (trace)
+ {
log.trace("getSession()");
+ }
if (topicSession != null)
+ {
return topicSession;
+ }
else if (queueSession != null)
+ {
return queueSession;
+ }
else
+ {
return session;
+ }
}
/**
* Send an event.
* @param event The event to send.
*/
- protected void sendEvent(ConnectionEvent event)
+ protected void sendEvent(final ConnectionEvent event)
{
if (trace)
+ {
log.trace("sendEvent(" + event + ")");
+ }
int type = event.getId();
// convert to an array to avoid concurrent modification exceptions
- ConnectionEventListener[] list =
- (ConnectionEventListener[])eventListeners.toArray(new ConnectionEventListener[eventListeners.size()]);
+ ConnectionEventListener[] list = eventListeners.toArray(new ConnectionEventListener[eventListeners.size()]);
for (ConnectionEventListener l : list)
{
- switch (type) {
+ switch (type)
+ {
case ConnectionEvent.CONNECTION_CLOSED:
l.connectionClosed(event);
break;
@@ -637,10 +749,12 @@
* Remove a handle from the handle map.
* @param handle The handle to remove.
*/
- protected void removeHandle(JBMSession handle)
+ protected void removeHandle(final JBMSession handle)
{
if (trace)
+ {
log.trace("removeHandle(" + handle + ")");
+ }
handles.remove(handle);
}
@@ -652,7 +766,9 @@
protected JBMConnectionRequestInfo getCRI()
{
if (trace)
+ {
log.trace("getCRI()");
+ }
return cri;
}
@@ -664,7 +780,9 @@
protected JBMManagedConnectionFactory getManagedConnectionFactory()
{
if (trace)
+ {
log.trace("getManagedConnectionFactory()");
+ }
return mcf;
}
@@ -676,13 +794,19 @@
void start() throws JMSException
{
if (trace)
+ {
log.trace("start()");
+ }
if (connection != null)
+ {
connection.start();
+ }
if (xaConnection != null)
+ {
xaConnection.start();
+ }
}
/**
@@ -692,15 +816,21 @@
void stop() throws JMSException
{
if (trace)
+ {
log.trace("stop()");
+ }
if (xaConnection != null)
+ {
xaConnection.stop();
+ }
if (connection != null)
+ {
connection.stop();
+ }
}
-
+
/**
* Get the user name
* @return The user name
@@ -708,7 +838,9 @@
protected String getUserName()
{
if (trace)
+ {
log.trace("getUserName()");
+ }
return userName;
}
@@ -720,7 +852,9 @@
private void setup() throws ResourceException
{
if (trace)
+ {
log.trace("setup()");
+ }
try
{
Modified: trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMManagedConnectionFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -52,19 +52,19 @@
/** The logger */
private static final Logger log = Logger.getLogger(JBMManagedConnectionFactory.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
/** The resource adapter */
private JBMResourceAdapter ra;
-
+
/** Connection manager */
private ConnectionManager cm;
/** The managed connection factory properties */
- private JBMMCFProperties mcfProperties;
-
+ private final JBMMCFProperties mcfProperties;
+
/** Connection Factory used if properties are set */
private JBossConnectionFactory connectionFactory;
@@ -74,13 +74,15 @@
public JBMManagedConnectionFactory()
{
if (trace)
+ {
log.trace("constructor()");
-
+ }
+
ra = null;
cm = null;
mcfProperties = new JBMMCFProperties();
}
-
+
/**
* Creates a Connection Factory instance
* @return javax.resource.cci.ConnectionFactory instance
@@ -89,8 +91,10 @@
public Object createConnectionFactory() throws ResourceException
{
if (trace)
+ {
log.debug("createConnectionFactory()");
-
+ }
+
return createConnectionFactory(new JBMConnectionManager());
}
@@ -100,21 +104,25 @@
* @return javax.resource.cci.ConnectionFactory instance
* @exception ResourceException Thrown if a connection factory cant be created
*/
- public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
+ public Object createConnectionFactory(final ConnectionManager cxManager) throws ResourceException
{
if (trace)
+ {
log.trace("createConnectionFactory(" + cxManager + ")");
+ }
cm = cxManager;
JBMConnectionFactory cf = new JBMConnectionFactoryImpl(this, cm);
if (trace)
+ {
log.trace("Created connection factory: " + cf + ", using connection manager: " + cm);
-
+ }
+
return cf;
}
-
+
/**
* Creates a new physical connection to the underlying EIS resource manager.
* @param subject Caller's security information
@@ -122,25 +130,29 @@
* @return The managed connection
* @exception ResourceException Thrown if a managed connection cant be created
*/
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo cxRequestInfo)
- throws ResourceException
+ public ManagedConnection createManagedConnection(final Subject subject, final ConnectionRequestInfo cxRequestInfo) throws ResourceException
{
if (trace)
+ {
log.trace("createManagedConnection(" + subject + ", " + cxRequestInfo + ")");
+ }
JBMConnectionRequestInfo cri = getCRI((JBMConnectionRequestInfo)cxRequestInfo);
JBMCredential credential = JBMCredential.getCredential(this, subject, cri);
if (trace)
+ {
log.trace("jms credential: " + credential);
+ }
JBMManagedConnection mc = new JBMManagedConnection(this, cri, credential.getUserName(), credential.getPassword());
-
+
if (trace)
+ {
log.trace("created new managed connection: " + mc);
-
+ }
+
return mc;
}
@@ -152,46 +164,54 @@
* @return The managed connection
* @exception ResourceException Thrown if no managed connection cant be found
*/
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject,
- ConnectionRequestInfo cxRequestInfo)
- throws ResourceException
+ public ManagedConnection matchManagedConnections(final Set connectionSet,
+ final Subject subject,
+ final ConnectionRequestInfo cxRequestInfo) throws ResourceException
{
if (trace)
+ {
log.trace("matchManagedConnections(" + connectionSet + ", " + subject + ", " + cxRequestInfo + ")");
+ }
JBMConnectionRequestInfo cri = getCRI((JBMConnectionRequestInfo)cxRequestInfo);
JBMCredential credential = JBMCredential.getCredential(this, subject, cri);
-
+
if (trace)
+ {
log.trace("Looking for connection matching credentials: " + credential);
-
+ }
+
Iterator connections = connectionSet.iterator();
-
+
while (connections.hasNext())
{
Object obj = connections.next();
-
+
if (obj instanceof JBMManagedConnection)
{
- JBMManagedConnection mc = (JBMManagedConnection) obj;
+ JBMManagedConnection mc = (JBMManagedConnection)obj;
ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
-
- if ((mc.getUserName() == null || (mc.getUserName() != null && mc.getUserName().equals(credential.getUserName()))) && mcf.equals(this))
+
+ if ((mc.getUserName() == null || mc.getUserName() != null && mc.getUserName()
+ .equals(credential.getUserName())) && mcf.equals(this))
{
if (cri.equals(mc.getCRI()))
{
if (trace)
+ {
log.trace("Found matching connection: " + mc);
-
+ }
+
return mc;
}
}
}
}
-
+
if (trace)
+ {
log.trace("No matching connection was found");
+ }
return null;
}
@@ -201,10 +221,12 @@
* @param out The writer
* @exception ResourceException Thrown if the writer cant be set
*/
- public void setLogWriter(PrintWriter out) throws ResourceException
+ public void setLogWriter(final PrintWriter out) throws ResourceException
{
if (trace)
+ {
log.trace("setLogWriter(" + out + ")");
+ }
}
/**
@@ -215,7 +237,9 @@
public PrintWriter getLogWriter() throws ResourceException
{
if (trace)
+ {
log.trace("getLogWriter()");
+ }
return null;
}
@@ -227,7 +251,9 @@
public ResourceAdapter getResourceAdapter()
{
if (trace)
+ {
log.trace("getResourceAdapter()");
+ }
return ra;
}
@@ -237,12 +263,15 @@
* @param ra The resource adapter
* @exception ResourceException Thrown if incorrect resource adapter
*/
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException
+ public void setResourceAdapter(final ResourceAdapter ra) throws ResourceException
{
if (trace)
+ {
log.trace("setResourceAdapter(" + ra + ")");
+ }
- if (ra == null || !(ra instanceof JBMResourceAdapter)) {
+ if (ra == null || !(ra instanceof JBMResourceAdapter))
+ {
throw new ResourceException("Resource adapter is " + ra);
}
@@ -254,20 +283,24 @@
* @param obj Object with which to compare
* @return True if this object is the same as the obj argument; false otherwise.
*/
- public boolean equals(Object obj)
+ @Override
+ public boolean equals(final Object obj)
{
if (trace)
+ {
log.trace("equals(" + obj + ")");
+ }
if (obj == null)
+ {
return false;
+ }
if (obj instanceof JBMManagedConnectionFactory)
{
JBMManagedConnectionFactory other = (JBMManagedConnectionFactory)obj;
- return mcfProperties.equals(other.getProperties()) &&
- ra.equals(other.getResourceAdapter());
+ return mcfProperties.equals(other.getProperties()) && ra.equals(other.getResourceAdapter());
}
else
{
@@ -279,10 +312,13 @@
* Return the hash code for the object
* @return The hash code
*/
+ @Override
public int hashCode()
{
if (trace)
+ {
log.trace("hashCode()");
+ }
int hash = mcfProperties.hashCode();
hash += 31 * ra.hashCode();
@@ -297,7 +333,9 @@
public String getSessionDefaultType()
{
if (trace)
+ {
log.trace("getSessionDefaultType()");
+ }
return mcfProperties.getSessionDefaultType();
}
@@ -306,15 +344,16 @@
* Set the default session type
* @param type either javax.jms.Topic or javax.jms.Queue
*/
- public void setSessionDefaultType(String type)
+ public void setSessionDefaultType(final String type)
{
if (trace)
+ {
log.trace("setSessionDefaultType(" + type + ")");
+ }
mcfProperties.setSessionDefaultType(type);
}
-
/**
* @return the connectionParameters
*/
@@ -322,12 +361,12 @@
{
return mcfProperties.getConnectionParameters();
}
-
- public void setConnectionParameters(String configuration)
+
+ public void setConnectionParameters(final String configuration)
{
mcfProperties.setConnectionParameters(configuration);
}
-
+
/**
* @return the transportType
*/
@@ -335,12 +374,12 @@
{
return mcfProperties.getConnectorClassName();
}
-
- public void setConnectorClassName(String value)
+
+ public void setConnectorClassName(final String value)
{
mcfProperties.setConnectorClassName(value);
}
-
+
/**
* Get the useTryLock.
* @return the useTryLock.
@@ -348,23 +387,27 @@
public Integer getUseTryLock()
{
if (trace)
+ {
log.trace("getUseTryLock()");
+ }
return mcfProperties.getUseTryLock();
}
-
+
/**
* Set the useTryLock.
* @param useTryLock the useTryLock.
*/
- public void setUseTryLock(Integer useTryLock)
+ public void setUseTryLock(final Integer useTryLock)
{
if (trace)
+ {
log.trace("setUseTryLock(" + useTryLock + ")");
+ }
mcfProperties.setUseTryLock(useTryLock);
}
-
+
/**
* Get the connection metadata
* @return The metadata
@@ -372,7 +415,9 @@
public ConnectionMetaData getMetaData()
{
if (trace)
+ {
log.trace("getMetadata()");
+ }
return new JBMConnectionMetaData();
}
@@ -383,13 +428,14 @@
*/
protected synchronized JBossConnectionFactory getJBossConnectionFactory() throws ResourceException
{
- if (this.mcfProperties.getConnectorClassName() != null)
+ if (mcfProperties.getConnectorClassName() != null)
{
if (connectionFactory == null)
{
- connectionFactory = ra.createRemoteFactory(mcfProperties.getConnectorClassName(), mcfProperties.getParsedConnectionParameters());
+ connectionFactory = ra.createRemoteFactory(mcfProperties.getConnectorClassName(),
+ mcfProperties.getParsedConnectionParameters());
}
-
+
return connectionFactory;
}
else
@@ -405,7 +451,9 @@
protected JBMMCFProperties getProperties()
{
if (trace)
+ {
log.trace("getProperties()");
+ }
return mcfProperties;
}
@@ -415,10 +463,12 @@
* @param info The instance that should be updated; may be <code>null</code>
* @return The instance
*/
- private JBMConnectionRequestInfo getCRI(JBMConnectionRequestInfo info)
+ private JBMConnectionRequestInfo getCRI(final JBMConnectionRequestInfo info)
{
if (trace)
+ {
log.trace("getCRI(" + info + ")");
+ }
if (info == null)
{
Modified: trunk/src/main/org/jboss/messaging/ra/JBMMapMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMMapMessage.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMMapMessage.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -39,7 +39,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMMapMessage.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
@@ -49,12 +49,14 @@
* @param message the message
* @param session the session
*/
- public JBMMapMessage(MapMessage message, JBMSession session)
+ public JBMMapMessage(final MapMessage message, final JBMSession session)
{
super(message, session);
if (trace)
+ {
log.trace("constructor(" + message + ", " + session + ")");
+ }
}
/**
@@ -63,26 +65,30 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public boolean getBoolean(String name) throws JMSException
+ public boolean getBoolean(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getBoolean(" + name + ")");
+ }
- return ((MapMessage) message).getBoolean(name);
+ return ((MapMessage)message).getBoolean(name);
}
-
+
/**
* Get
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public byte getByte(String name) throws JMSException
+ public byte getByte(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getByte(" + name + ")");
+ }
- return ((MapMessage) message).getByte(name);
+ return ((MapMessage)message).getByte(name);
}
/**
@@ -91,12 +97,14 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public byte[] getBytes(String name) throws JMSException
+ public byte[] getBytes(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getBytes(" + name + ")");
+ }
- return ((MapMessage) message).getBytes(name);
+ return ((MapMessage)message).getBytes(name);
}
/**
@@ -105,12 +113,14 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public char getChar(String name) throws JMSException
+ public char getChar(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getChar(" + name + ")");
+ }
- return ((MapMessage) message).getChar(name);
+ return ((MapMessage)message).getChar(name);
}
/**
@@ -119,12 +129,14 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public double getDouble(String name) throws JMSException
+ public double getDouble(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getDouble(" + name + ")");
+ }
- return ((MapMessage) message).getDouble(name);
+ return ((MapMessage)message).getDouble(name);
}
/**
@@ -133,26 +145,30 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public float getFloat(String name) throws JMSException
+ public float getFloat(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getFloat(" + name + ")");
+ }
- return ((MapMessage) message).getFloat(name);
+ return ((MapMessage)message).getFloat(name);
}
-
+
/**
* Get
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public int getInt(String name) throws JMSException
+ public int getInt(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getInt(" + name + ")");
+ }
- return ((MapMessage) message).getInt(name);
+ return ((MapMessage)message).getInt(name);
}
/**
@@ -161,12 +177,14 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public long getLong(String name) throws JMSException
+ public long getLong(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getLong(" + name + ")");
+ }
- return ((MapMessage) message).getLong(name);
+ return ((MapMessage)message).getLong(name);
}
/**
@@ -177,9 +195,11 @@
public Enumeration getMapNames() throws JMSException
{
if (trace)
+ {
log.trace("getMapNames()");
+ }
- return ((MapMessage) message).getMapNames();
+ return ((MapMessage)message).getMapNames();
}
/**
@@ -188,12 +208,14 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public Object getObject(String name) throws JMSException
+ public Object getObject(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getObject(" + name + ")");
+ }
- return ((MapMessage) message).getObject(name);
+ return ((MapMessage)message).getObject(name);
}
/**
@@ -202,12 +224,14 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public short getShort(String name) throws JMSException
+ public short getShort(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getShort(" + name + ")");
+ }
- return ((MapMessage) message).getShort(name);
+ return ((MapMessage)message).getShort(name);
}
/**
@@ -216,12 +240,14 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public String getString(String name) throws JMSException
+ public String getString(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getString(" + name + ")");
+ }
- return ((MapMessage) message).getString(name);
+ return ((MapMessage)message).getString(name);
}
/**
@@ -230,12 +256,14 @@
* @return True / false
* @exception JMSException Thrown if an error occurs
*/
- public boolean itemExists(String name) throws JMSException
+ public boolean itemExists(final String name) throws JMSException
{
if (trace)
+ {
log.trace("itemExists(" + name + ")");
+ }
- return ((MapMessage) message).itemExists(name);
+ return ((MapMessage)message).itemExists(name);
}
/**
@@ -244,12 +272,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setBoolean(String name, boolean value) throws JMSException
+ public void setBoolean(final String name, final boolean value) throws JMSException
{
if (trace)
+ {
log.trace("setBoolean(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setBoolean(name, value);
+ ((MapMessage)message).setBoolean(name, value);
}
/**
@@ -258,12 +288,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setByte(String name, byte value) throws JMSException
+ public void setByte(final String name, final byte value) throws JMSException
{
if (trace)
+ {
log.trace("setByte(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setByte(name, value);
+ ((MapMessage)message).setByte(name, value);
}
/**
@@ -274,12 +306,14 @@
* @param length The length
* @exception JMSException Thrown if an error occurs
*/
- public void setBytes(String name, byte[] value, int offset, int length) throws JMSException
+ public void setBytes(final String name, final byte[] value, final int offset, final int length) throws JMSException
{
if (trace)
+ {
log.trace("setBytes(" + name + ", " + value + ", " + offset + ", " + length + ")");
+ }
- ((MapMessage) message).setBytes(name, value, offset, length);
+ ((MapMessage)message).setBytes(name, value, offset, length);
}
/**
@@ -288,12 +322,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setBytes(String name, byte[] value) throws JMSException
+ public void setBytes(final String name, final byte[] value) throws JMSException
{
if (trace)
+ {
log.trace("setBytes(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setBytes(name, value);
+ ((MapMessage)message).setBytes(name, value);
}
/**
@@ -302,12 +338,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setChar(String name, char value) throws JMSException
+ public void setChar(final String name, final char value) throws JMSException
{
if (trace)
+ {
log.trace("setChar(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setChar(name, value);
+ ((MapMessage)message).setChar(name, value);
}
/**
@@ -316,12 +354,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setDouble(String name, double value) throws JMSException
+ public void setDouble(final String name, final double value) throws JMSException
{
if (trace)
+ {
log.trace("setDouble(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setDouble(name, value);
+ ((MapMessage)message).setDouble(name, value);
}
/**
@@ -330,12 +370,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setFloat(String name, float value) throws JMSException
+ public void setFloat(final String name, final float value) throws JMSException
{
if (trace)
+ {
log.trace("setFloat(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setFloat(name, value);
+ ((MapMessage)message).setFloat(name, value);
}
/**
@@ -344,12 +386,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setInt(String name, int value) throws JMSException
+ public void setInt(final String name, final int value) throws JMSException
{
if (trace)
+ {
log.trace("setInt(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setInt(name, value);
+ ((MapMessage)message).setInt(name, value);
}
/**
@@ -358,40 +402,46 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setLong(String name, long value) throws JMSException
+ public void setLong(final String name, final long value) throws JMSException
{
if (trace)
+ {
log.trace("setLong(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setLong(name, value);
+ ((MapMessage)message).setLong(name, value);
}
-
+
/**
* Set
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setObject(String name, Object value) throws JMSException
+ public void setObject(final String name, final Object value) throws JMSException
{
if (trace)
+ {
log.trace("setObject(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setObject(name, value);
+ ((MapMessage)message).setObject(name, value);
}
-
+
/**
* Set
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setShort(String name, short value) throws JMSException
+ public void setShort(final String name, final short value) throws JMSException
{
if (trace)
+ {
log.trace("setShort(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setShort(name, value);
+ ((MapMessage)message).setShort(name, value);
}
/**
@@ -400,11 +450,13 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setString(String name, String value) throws JMSException
+ public void setString(final String name, final String value) throws JMSException
{
if (trace)
+ {
log.trace("setString(" + name + ", " + value + ")");
+ }
- ((MapMessage) message).setString(name, value);
+ ((MapMessage)message).setString(name, value);
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMMessage.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMMessage.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -39,13 +39,13 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMMessage.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
/** The message */
protected Message message;
-
+
/** The session */
protected JBMSession session;
@@ -54,10 +54,12 @@
* @param message the message
* @param session the session
*/
- public JBMMessage(Message message, JBMSession session)
+ public JBMMessage(final Message message, final JBMSession session)
{
if (trace)
+ {
log.trace("constructor(" + message + ", " + session + ")");
+ }
this.message = message;
this.session = session;
@@ -70,12 +72,14 @@
public void acknowledge() throws JMSException
{
if (trace)
+ {
log.trace("acknowledge()");
+ }
session.getSession(); // Check for closed
message.acknowledge();
}
-
+
/**
* Clear body
* @exception JMSException Thrown if an error occurs
@@ -83,11 +87,13 @@
public void clearBody() throws JMSException
{
if (trace)
+ {
log.trace("clearBody()");
+ }
message.clearBody();
}
-
+
/**
* Clear properties
* @exception JMSException Thrown if an error occurs
@@ -95,35 +101,41 @@
public void clearProperties() throws JMSException
{
if (trace)
+ {
log.trace("clearProperties()");
+ }
message.clearProperties();
}
-
+
/**
* Get property
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public boolean getBooleanProperty(String name) throws JMSException
+ public boolean getBooleanProperty(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getBooleanProperty(" + name + ")");
+ }
return message.getBooleanProperty(name);
}
-
+
/**
* Get property
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public byte getByteProperty(String name) throws JMSException
+ public byte getByteProperty(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getByteProperty(" + name + ")");
+ }
return message.getByteProperty(name);
}
@@ -134,42 +146,48 @@
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public double getDoubleProperty(String name) throws JMSException
+ public double getDoubleProperty(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getDoubleProperty(" + name + ")");
+ }
return message.getDoubleProperty(name);
}
-
+
/**
* Get property
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public float getFloatProperty(String name) throws JMSException
+ public float getFloatProperty(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getFloatProperty(" + name + ")");
+ }
return message.getFloatProperty(name);
}
-
+
/**
* Get property
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public int getIntProperty(String name) throws JMSException
+ public int getIntProperty(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getIntProperty(" + name + ")");
+ }
return message.getIntProperty(name);
}
-
+
/**
* Get correlation id
* @return The value
@@ -178,11 +196,13 @@
public String getJMSCorrelationID() throws JMSException
{
if (trace)
+ {
log.trace("getJMSCorrelationID()");
+ }
return message.getJMSCorrelationID();
}
-
+
/**
* Get correlation id
* @return The value
@@ -191,11 +211,13 @@
public byte[] getJMSCorrelationIDAsBytes() throws JMSException
{
if (trace)
+ {
log.trace("getJMSCorrelationIDAsBytes()");
+ }
return message.getJMSCorrelationIDAsBytes();
}
-
+
/**
* Get delivery mode
* @return The value
@@ -204,11 +226,13 @@
public int getJMSDeliveryMode() throws JMSException
{
if (trace)
+ {
log.trace("getJMSDeliveryMode()");
+ }
return message.getJMSDeliveryMode();
}
-
+
/**
* Get destination
* @return The value
@@ -217,11 +241,13 @@
public Destination getJMSDestination() throws JMSException
{
if (trace)
+ {
log.trace("getJMSDestination()");
+ }
return message.getJMSDestination();
}
-
+
/**
* Get expiration
* @return The value
@@ -230,11 +256,13 @@
public long getJMSExpiration() throws JMSException
{
if (trace)
+ {
log.trace("getJMSExpiration()");
+ }
return message.getJMSExpiration();
}
-
+
/**
* Get message id
* @return The value
@@ -243,11 +271,13 @@
public String getJMSMessageID() throws JMSException
{
if (trace)
+ {
log.trace("getJMSMessageID()");
+ }
return message.getJMSMessageID();
}
-
+
/**
* Get priority
* @return The value
@@ -256,11 +286,13 @@
public int getJMSPriority() throws JMSException
{
if (trace)
+ {
log.trace("getJMSPriority()");
+ }
return message.getJMSPriority();
}
-
+
/**
* Get redelivered status
* @return The value
@@ -269,11 +301,13 @@
public boolean getJMSRedelivered() throws JMSException
{
if (trace)
+ {
log.trace("getJMSRedelivered()");
+ }
return message.getJMSRedelivered();
}
-
+
/**
* Get reply to destination
* @return The value
@@ -282,11 +316,13 @@
public Destination getJMSReplyTo() throws JMSException
{
if (trace)
+ {
log.trace("getJMSReplyTo()");
+ }
return message.getJMSReplyTo();
}
-
+
/**
* Get timestamp
* @return The value
@@ -295,11 +331,13 @@
public long getJMSTimestamp() throws JMSException
{
if (trace)
+ {
log.trace("getJMSTimestamp()");
+ }
return message.getJMSTimestamp();
}
-
+
/**
* Get type
* @return The value
@@ -308,39 +346,45 @@
public String getJMSType() throws JMSException
{
if (trace)
+ {
log.trace("getJMSType()");
+ }
return message.getJMSType();
}
-
+
/**
* Get property
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public long getLongProperty(String name) throws JMSException
+ public long getLongProperty(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getLongProperty(" + name + ")");
+ }
return message.getLongProperty(name);
}
-
+
/**
* Get property
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public Object getObjectProperty(String name) throws JMSException
+ public Object getObjectProperty(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getObjectProperty(" + name + ")");
+ }
return message.getObjectProperty(name);
}
-
+
/**
* Get property names
* @return The values
@@ -349,132 +393,152 @@
public Enumeration getPropertyNames() throws JMSException
{
if (trace)
+ {
log.trace("getPropertyNames()");
+ }
return message.getPropertyNames();
}
-
+
/**
* Get property
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public short getShortProperty(String name) throws JMSException
+ public short getShortProperty(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getShortProperty(" + name + ")");
+ }
return message.getShortProperty(name);
}
-
+
/**
* Get property
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public String getStringProperty(String name) throws JMSException
+ public String getStringProperty(final String name) throws JMSException
{
if (trace)
+ {
log.trace("getStringProperty(" + name + ")");
+ }
return message.getStringProperty(name);
}
-
+
/**
* Do property exist
* @param name The name
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public boolean propertyExists(String name) throws JMSException
+ public boolean propertyExists(final String name) throws JMSException
{
if (trace)
+ {
log.trace("propertyExists(" + name + ")");
+ }
return message.propertyExists(name);
}
-
+
/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setBooleanProperty(String name, boolean value) throws JMSException
+ public void setBooleanProperty(final String name, final boolean value) throws JMSException
{
if (trace)
+ {
log.trace("setBooleanProperty(" + name + ", " + value + ")");
+ }
message.setBooleanProperty(name, value);
}
-
+
/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setByteProperty(String name, byte value) throws JMSException
+ public void setByteProperty(final String name, final byte value) throws JMSException
{
if (trace)
+ {
log.trace("setByteProperty(" + name + ", " + value + ")");
+ }
message.setByteProperty(name, value);
}
-
+
/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setDoubleProperty(String name, double value) throws JMSException
+ public void setDoubleProperty(final String name, final double value) throws JMSException
{
if (trace)
+ {
log.trace("setDoubleProperty(" + name + ", " + value + ")");
+ }
message.setDoubleProperty(name, value);
}
-
+
/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setFloatProperty(String name, float value) throws JMSException
+ public void setFloatProperty(final String name, final float value) throws JMSException
{
if (trace)
+ {
log.trace("setFloatProperty(" + name + ", " + value + ")");
+ }
message.setFloatProperty(name, value);
}
-
+
/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setIntProperty(String name, int value) throws JMSException
+ public void setIntProperty(final String name, final int value) throws JMSException
{
if (trace)
+ {
log.trace("setIntProperty(" + name + ", " + value + ")");
+ }
message.setIntProperty(name, value);
}
-
+
/**
* Set correlation id
* @param correlationID The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSCorrelationID(String correlationID) throws JMSException
+ public void setJMSCorrelationID(final String correlationID) throws JMSException
{
if (trace)
+ {
log.trace("setJMSCorrelationID(" + correlationID + ")");
+ }
message.setJMSCorrelationID(correlationID);
}
@@ -484,10 +548,12 @@
* @param correlationID The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException
+ public void setJMSCorrelationIDAsBytes(final byte[] correlationID) throws JMSException
{
if (trace)
+ {
log.trace("setJMSCorrelationIDAsBytes(" + correlationID + ")");
+ }
message.setJMSCorrelationIDAsBytes(correlationID);
}
@@ -497,10 +563,12 @@
* @param deliveryMode The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSDeliveryMode(int deliveryMode) throws JMSException
+ public void setJMSDeliveryMode(final int deliveryMode) throws JMSException
{
if (trace)
+ {
log.trace("setJMSDeliveryMode(" + deliveryMode + ")");
+ }
message.setJMSDeliveryMode(deliveryMode);
}
@@ -510,62 +578,72 @@
* @param destination The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSDestination(Destination destination) throws JMSException
+ public void setJMSDestination(final Destination destination) throws JMSException
{
if (trace)
+ {
log.trace("setJMSDestination(" + destination + ")");
+ }
message.setJMSDestination(destination);
}
-
+
/**
* Set expiration
* @param expiration The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSExpiration(long expiration) throws JMSException
+ public void setJMSExpiration(final long expiration) throws JMSException
{
if (trace)
+ {
log.trace("setJMSExpiration(" + expiration + ")");
+ }
message.setJMSExpiration(expiration);
}
-
+
/**
* Set message id
* @param id The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSMessageID(String id) throws JMSException
+ public void setJMSMessageID(final String id) throws JMSException
{
if (trace)
+ {
log.trace("setJMSMessageID(" + id + ")");
+ }
message.setJMSMessageID(id);
}
-
+
/**
* Set priority
* @param priority The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSPriority(int priority) throws JMSException
+ public void setJMSPriority(final int priority) throws JMSException
{
if (trace)
+ {
log.trace("setJMSPriority(" + priority + ")");
+ }
message.setJMSPriority(priority);
}
-
+
/**
* Set redelivered status
* @param redelivered The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSRedelivered(boolean redelivered) throws JMSException
+ public void setJMSRedelivered(final boolean redelivered) throws JMSException
{
if (trace)
+ {
log.trace("setJMSRedelivered(" + redelivered + ")");
+ }
message.setJMSRedelivered(redelivered);
}
@@ -575,10 +653,12 @@
* @param replyTo The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSReplyTo(Destination replyTo) throws JMSException
+ public void setJMSReplyTo(final Destination replyTo) throws JMSException
{
if (trace)
+ {
log.trace("setJMSReplyTo(" + replyTo + ")");
+ }
message.setJMSReplyTo(replyTo);
}
@@ -588,119 +668,144 @@
* @param timestamp The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSTimestamp(long timestamp) throws JMSException
+ public void setJMSTimestamp(final long timestamp) throws JMSException
{
if (trace)
+ {
log.trace("setJMSTimestamp(" + timestamp + ")");
+ }
message.setJMSTimestamp(timestamp);
}
-
+
/**
* Set type
* @param type The value
* @exception JMSException Thrown if an error occurs
*/
- public void setJMSType(String type) throws JMSException
+ public void setJMSType(final String type) throws JMSException
{
if (trace)
+ {
log.trace("setJMSType(" + type + ")");
+ }
message.setJMSType(type);
}
-
+
/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setLongProperty(String name, long value) throws JMSException
+ public void setLongProperty(final String name, final long value) throws JMSException
{
if (trace)
+ {
log.trace("setLongProperty(" + name + ", " + value + ")");
+ }
message.setLongProperty(name, value);
}
-
+
/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setObjectProperty(String name, Object value) throws JMSException
+ public void setObjectProperty(final String name, final Object value) throws JMSException
{
if (trace)
+ {
log.trace("setObjectProperty(" + name + ", " + value + ")");
+ }
message.setObjectProperty(name, value);
}
-
+
/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setShortProperty(String name, short value) throws JMSException
+ public void setShortProperty(final String name, final short value) throws JMSException
{
if (trace)
+ {
log.trace("setShortProperty(" + name + ", " + value + ")");
+ }
message.setShortProperty(name, value);
}
-
+
/**
* Set property
* @param name The name
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setStringProperty(String name, String value) throws JMSException
+ public void setStringProperty(final String name, final String value) throws JMSException
{
if (trace)
+ {
log.trace("setStringProperty(" + name + ", " + value + ")");
+ }
message.setStringProperty(name, value);
}
-
+
/**
* Return the hash code
* @return The hash code
*/
+ @Override
public int hashCode()
{
if (trace)
+ {
log.trace("hashCode()");
+ }
return message.hashCode();
}
-
+
/**
* Check for equality
* @param object The other object
* @return True / false
*/
- public boolean equals(Object object)
+ @Override
+ public boolean equals(final Object object)
{
if (trace)
+ {
log.trace("equals(" + object + ")");
+ }
if (object != null && object instanceof JBMMessage)
- return message.equals(((JBMMessage) object).message);
+ {
+ return message.equals(((JBMMessage)object).message);
+ }
else
+ {
return message.equals(object);
+ }
}
-
+
/**
* Return string representation
* @return The string
*/
+ @Override
public String toString()
{
if (trace)
+ {
log.trace("toString()");
+ }
return message.toString();
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMMessageConsumer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMMessageConsumer.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMMessageConsumer.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -44,13 +44,13 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMMessageConsumer.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
/** The wrapped message consumer */
protected MessageConsumer consumer;
-
+
/** The session for this consumer */
protected JBMSession session;
@@ -59,13 +59,15 @@
* @param consumer the consumer
* @param session the session
*/
- public JBMMessageConsumer(MessageConsumer consumer, JBMSession session)
+ public JBMMessageConsumer(final MessageConsumer consumer, final JBMSession session)
{
this.consumer = consumer;
this.session = session;
-
+
if (trace)
+ {
log.trace("new JBMMessageConsumer " + this + " consumer=" + consumer + " session=" + session);
+ }
}
/**
@@ -75,7 +77,9 @@
public void close() throws JMSException
{
if (trace)
+ {
log.trace("close " + this);
+ }
try
{
closeConsumer();
@@ -93,9 +97,11 @@
void checkState() throws JMSException
{
if (trace)
+ {
log.trace("checkState()");
+ }
}
-
+
/**
* Get message listener
* @return The listener
@@ -104,19 +110,21 @@
public MessageListener getMessageListener() throws JMSException
{
if (trace)
+ {
log.trace("getMessageListener()");
+ }
checkState();
session.checkStrict();
return consumer.getMessageListener();
}
-
+
/**
* Set message listener
* @param listener The listener
* @exception JMSException Thrown if an error occurs
*/
- public void setMessageListener(MessageListener listener) throws JMSException
+ public void setMessageListener(final MessageListener listener) throws JMSException
{
session.lock();
try
@@ -124,9 +132,13 @@
checkState();
session.checkStrict();
if (listener == null)
+ {
consumer.setMessageListener(null);
+ }
else
+ {
consumer.setMessageListener(wrapMessageListener(listener));
+ }
}
finally
{
@@ -142,12 +154,14 @@
public String getMessageSelector() throws JMSException
{
if (trace)
+ {
log.trace("getMessageSelector()");
+ }
checkState();
return consumer.getMessageSelector();
}
-
+
/**
* Receive
* @return The message
@@ -159,18 +173,26 @@
try
{
if (trace)
+ {
log.trace("receive " + this);
+ }
checkState();
Message message = consumer.receive();
if (trace)
+ {
log.trace("received " + this + " result=" + message);
+ }
if (message == null)
+ {
return null;
+ }
else
+ {
return wrapMessage(message);
+ }
}
finally
{
@@ -184,24 +206,32 @@
* @return The message
* @exception JMSException Thrown if an error occurs
*/
- public Message receive(long timeout) throws JMSException
+ public Message receive(final long timeout) throws JMSException
{
session.lock();
try
{
if (trace)
+ {
log.trace("receive " + this + " timeout=" + timeout);
+ }
checkState();
Message message = consumer.receive(timeout);
if (trace)
+ {
log.trace("received " + this + " result=" + message);
+ }
if (message == null)
+ {
return null;
+ }
else
+ {
return wrapMessage(message);
+ }
}
finally
{
@@ -220,25 +250,33 @@
try
{
if (trace)
+ {
log.trace("receiveNoWait " + this);
+ }
checkState();
Message message = consumer.receiveNoWait();
if (trace)
+ {
log.trace("received " + this + " result=" + message);
+ }
if (message == null)
+ {
return null;
+ }
else
+ {
return wrapMessage(message);
+ }
}
finally
{
session.unlock();
}
}
-
+
/**
* Close consumer
* @exception JMSException Thrown if an error occurs
@@ -246,43 +284,59 @@
void closeConsumer() throws JMSException
{
if (trace)
+ {
log.trace("closeConsumer()");
+ }
consumer.close();
}
-
+
/**
* Wrap message
* @param message The message to be wrapped
* @return The wrapped message
*/
- Message wrapMessage(Message message)
+ Message wrapMessage(final Message message)
{
if (trace)
+ {
log.trace("wrapMessage(" + message + ")");
+ }
if (message instanceof BytesMessage)
- return new JBMBytesMessage((BytesMessage) message, session);
+ {
+ return new JBMBytesMessage((BytesMessage)message, session);
+ }
else if (message instanceof MapMessage)
- return new JBMMapMessage((MapMessage) message, session);
+ {
+ return new JBMMapMessage((MapMessage)message, session);
+ }
else if (message instanceof ObjectMessage)
- return new JBMObjectMessage((ObjectMessage) message, session);
+ {
+ return new JBMObjectMessage((ObjectMessage)message, session);
+ }
else if (message instanceof StreamMessage)
- return new JBMStreamMessage((StreamMessage) message, session);
+ {
+ return new JBMStreamMessage((StreamMessage)message, session);
+ }
else if (message instanceof TextMessage)
- return new JBMTextMessage((TextMessage) message, session);
+ {
+ return new JBMTextMessage((TextMessage)message, session);
+ }
return new JBMMessage(message, session);
}
-
+
/**
* Wrap message listener
* @param listener The listener to be wrapped
* @return The wrapped listener
*/
- MessageListener wrapMessageListener(MessageListener listener)
+ MessageListener wrapMessageListener(final MessageListener listener)
{
if (trace)
+ {
log.trace("getMessageSelector()");
+ }
return new JBMMessageListener(listener, this);
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMMessageListener.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMMessageListener.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMMessageListener.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -36,25 +36,27 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMMessageListener.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
/** The message listener */
- private MessageListener listener;
-
+ private final MessageListener listener;
+
/** The consumer */
- private JBMMessageConsumer consumer;
+ private final JBMMessageConsumer consumer;
/**
* Create a new wrapper
* @param listener the listener
* @param consumer the consumer
*/
- public JBMMessageListener(MessageListener listener, JBMMessageConsumer consumer)
+ public JBMMessageListener(final MessageListener listener, final JBMMessageConsumer consumer)
{
if (trace)
+ {
log.trace("constructor(" + listener + ", " + consumer + ")");
+ }
this.listener = listener;
this.consumer = consumer;
@@ -67,7 +69,9 @@
public void onMessage(Message message)
{
if (trace)
+ {
log.trace("onMessage(" + message + ")");
+ }
message = consumer.wrapMessage(message);
listener.onMessage(message);
Modified: trunk/src/main/org/jboss/messaging/ra/JBMMessageProducer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMMessageProducer.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMMessageProducer.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -39,13 +39,13 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMMessageProducer.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
/** The wrapped message producer */
protected MessageProducer producer;
-
+
/** The session for this consumer */
protected JBMSession session;
@@ -54,13 +54,15 @@
* @param producer the producer
* @param session the session
*/
- public JBMMessageProducer(MessageProducer producer, JBMSession session)
+ public JBMMessageProducer(final MessageProducer producer, final JBMSession session)
{
this.producer = producer;
this.session = session;
-
+
if (trace)
+ {
log.trace("new JBMMessageProducer " + this + " producer=" + producer + " session=" + session);
+ }
}
/**
@@ -70,7 +72,9 @@
public void close() throws JMSException
{
if (trace)
+ {
log.trace("close " + this);
+ }
try
{
closeProducer();
@@ -90,20 +94,38 @@
* @param timeToLive The time to live
* @exception JMSException Thrown if an error occurs
*/
- public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
+ public void send(final Destination destination,
+ final Message message,
+ final int deliveryMode,
+ final int priority,
+ final long timeToLive) throws JMSException
{
session.lock();
try
{
if (trace)
- log.trace("send " + this + " destination=" + destination + " message=" + message + " deliveryMode=" + deliveryMode + " priority=" + priority + " ttl=" + timeToLive);
+ {
+ log.trace("send " + this +
+ " destination=" +
+ destination +
+ " message=" +
+ message +
+ " deliveryMode=" +
+ deliveryMode +
+ " priority=" +
+ priority +
+ " ttl=" +
+ timeToLive);
+ }
checkState();
producer.send(destination, message, deliveryMode, priority, timeToLive);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
@@ -117,20 +139,24 @@
* @param message The message
* @exception JMSException Thrown if an error occurs
*/
- public void send(Destination destination, Message message) throws JMSException
+ public void send(final Destination destination, final Message message) throws JMSException
{
session.lock();
try
{
if (trace)
+ {
log.trace("send " + this + " destination=" + destination + " message=" + message);
+ }
checkState();
producer.send(destination, message);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
@@ -146,20 +172,32 @@
* @param timeToLive The time to live
* @exception JMSException Thrown if an error occurs
*/
- public void send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
+ public void send(final Message message, final int deliveryMode, final int priority, final long timeToLive) throws JMSException
{
session.lock();
try
{
if (trace)
- log.trace("send " + this + " message=" + message + " deliveryMode=" + deliveryMode + " priority=" + priority + " ttl=" + timeToLive);
+ {
+ log.trace("send " + this +
+ " message=" +
+ message +
+ " deliveryMode=" +
+ deliveryMode +
+ " priority=" +
+ priority +
+ " ttl=" +
+ timeToLive);
+ }
checkState();
producer.send(message, deliveryMode, priority, timeToLive);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
@@ -172,20 +210,24 @@
* @param message The message
* @exception JMSException Thrown if an error occurs
*/
- public void send(Message message) throws JMSException
+ public void send(final Message message) throws JMSException
{
session.lock();
try
{
if (trace)
+ {
log.trace("send " + this + " message=" + message);
+ }
checkState();
producer.send(message);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
@@ -201,7 +243,9 @@
public int getDeliveryMode() throws JMSException
{
if (trace)
+ {
log.trace("getDeliveryMode()");
+ }
return producer.getDeliveryMode();
}
@@ -214,7 +258,9 @@
public Destination getDestination() throws JMSException
{
if (trace)
+ {
log.trace("getDestination()");
+ }
return producer.getDestination();
}
@@ -227,7 +273,9 @@
public boolean getDisableMessageID() throws JMSException
{
if (trace)
+ {
log.trace("getDisableMessageID()");
+ }
return producer.getDisableMessageID();
}
@@ -240,7 +288,9 @@
public boolean getDisableMessageTimestamp() throws JMSException
{
if (trace)
+ {
log.trace("getDisableMessageTimestamp()");
+ }
return producer.getDisableMessageTimestamp();
}
@@ -253,7 +303,9 @@
public int getPriority() throws JMSException
{
if (trace)
+ {
log.trace("getPriority()");
+ }
return producer.getPriority();
}
@@ -266,7 +318,9 @@
public long getTimeToLive() throws JMSException
{
if (trace)
+ {
log.trace("getTimeToLive()");
+ }
return producer.getTimeToLive();
}
@@ -276,10 +330,12 @@
* @param deliveryMode The mode
* @exception JMSException Thrown if an error occurs
*/
- public void setDeliveryMode(int deliveryMode) throws JMSException
+ public void setDeliveryMode(final int deliveryMode) throws JMSException
{
if (trace)
+ {
log.trace("setDeliveryMode(" + deliveryMode + ")");
+ }
producer.setDeliveryMode(deliveryMode);
}
@@ -289,10 +345,12 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setDisableMessageID(boolean value) throws JMSException
+ public void setDisableMessageID(final boolean value) throws JMSException
{
if (trace)
+ {
log.trace("setDisableMessageID(" + value + ")");
+ }
producer.setDisableMessageID(value);
}
@@ -302,10 +360,12 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void setDisableMessageTimestamp(boolean value) throws JMSException
+ public void setDisableMessageTimestamp(final boolean value) throws JMSException
{
if (trace)
+ {
log.trace("setDisableMessageTimestamp(" + value + ")");
+ }
producer.setDisableMessageTimestamp(value);
}
@@ -315,10 +375,12 @@
* @param defaultPriority The value
* @exception JMSException Thrown if an error occurs
*/
- public void setPriority(int defaultPriority) throws JMSException
+ public void setPriority(final int defaultPriority) throws JMSException
{
if (trace)
+ {
log.trace("setPriority(" + defaultPriority + ")");
+ }
producer.setPriority(defaultPriority);
}
@@ -328,10 +390,12 @@
* @param timeToLive The value
* @exception JMSException Thrown if an error occurs
*/
- public void setTimeToLive(long timeToLive) throws JMSException
+ public void setTimeToLive(final long timeToLive) throws JMSException
{
if (trace)
+ {
log.trace("setTimeToLive(" + timeToLive + ")");
+ }
producer.setTimeToLive(timeToLive);
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMMetaData.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMMetaData.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMMetaData.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -37,33 +37,39 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMMetaData.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
/** The managed connection */
- private JBMManagedConnection mc;
-
+ private final JBMManagedConnection mc;
+
/**
* Constructor
* @param mc The managed connection
*/
- public JBMMetaData(JBMManagedConnection mc) {
+ public JBMMetaData(final JBMManagedConnection mc)
+ {
if (trace)
+ {
log.trace("constructor(" + mc + ")");
+ }
this.mc = mc;
}
-
+
/**
* Get the EIS product name
* @return The name
* @exception ResourceException Thrown if operation fails
*/
- public String getEISProductName() throws ResourceException {
+ public String getEISProductName() throws ResourceException
+ {
if (trace)
+ {
log.trace("getEISProductName()");
-
+ }
+
return "JBoss Messaging";
}
@@ -72,9 +78,12 @@
* @return The version
* @exception ResourceException Thrown if operation fails
*/
- public String getEISProductVersion() throws ResourceException {
+ public String getEISProductVersion() throws ResourceException
+ {
if (trace)
+ {
log.trace("getEISProductVersion()");
+ }
return "2.0";
}
@@ -84,21 +93,27 @@
* @return The number
* @exception ResourceException Thrown if operation fails
*/
- public int getMaxConnections() throws ResourceException {
+ public int getMaxConnections() throws ResourceException
+ {
if (trace)
+ {
log.trace("getMaxConnections()");
+ }
return 0;
}
-
+
/**
* Get the user name
* @return The user name
* @exception ResourceException Thrown if operation fails
*/
- public String getUserName() throws ResourceException {
+ public String getUserName() throws ResourceException
+ {
if (trace)
+ {
log.trace("getUserName()");
+ }
return mc.getUserName();
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMObjectMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMObjectMessage.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMObjectMessage.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -39,7 +39,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMObjectMessage.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
@@ -48,12 +48,14 @@
* @param message the message
* @param session the session
*/
- public JBMObjectMessage(ObjectMessage message, JBMSession session)
+ public JBMObjectMessage(final ObjectMessage message, final JBMSession session)
{
super(message, session);
if (trace)
+ {
log.trace("constructor(" + message + ", " + session + ")");
+ }
}
/**
@@ -64,21 +66,25 @@
public Serializable getObject() throws JMSException
{
if (trace)
+ {
log.trace("getObject()");
+ }
- return ((ObjectMessage) message).getObject();
+ return ((ObjectMessage)message).getObject();
}
-
+
/**
* Set the object
* @param object The object
* @exception JMSException Thrown if an error occurs
*/
- public void setObject(Serializable object) throws JMSException
+ public void setObject(final Serializable object) throws JMSException
{
if (trace)
+ {
log.trace("setObject(" + object + ")");
+ }
- ((ObjectMessage) message).setObject(object);
+ ((ObjectMessage)message).setObject(object);
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMQueueReceiver.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMQueueReceiver.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMQueueReceiver.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -38,7 +38,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMQueueReceiver.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
@@ -47,12 +47,14 @@
* @param consumer the queue receiver
* @param session the session
*/
- public JBMQueueReceiver(QueueReceiver consumer, JBMSession session)
+ public JBMQueueReceiver(final QueueReceiver consumer, final JBMSession session)
{
super(consumer, session);
if (trace)
+ {
log.trace("constructor(" + consumer + ", " + session + ")");
+ }
}
/**
@@ -63,9 +65,11 @@
public Queue getQueue() throws JMSException
{
if (trace)
+ {
log.trace("getQueue()");
+ }
checkState();
- return ((QueueReceiver) consumer).getQueue();
+ return ((QueueReceiver)consumer).getQueue();
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMQueueSender.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMQueueSender.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMQueueSender.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -39,7 +39,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMQueueSender.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
@@ -48,12 +48,14 @@
* @param producer the producer
* @param session the session
*/
- public JBMQueueSender(QueueSender producer, JBMSession session)
+ public JBMQueueSender(final QueueSender producer, final JBMSession session)
{
super(producer, session);
if (trace)
+ {
log.trace("constructor(" + producer + ", " + session + ")");
+ }
}
/**
@@ -64,9 +66,11 @@
public Queue getQueue() throws JMSException
{
if (trace)
+ {
log.trace("getQueue()");
+ }
- return ((QueueSender) producer).getQueue();
+ return ((QueueSender)producer).getQueue();
}
/**
@@ -78,19 +82,37 @@
* @param timeToLive The time to live
* @exception JMSException Thrown if an error occurs
*/
- public void send(Queue destination, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
+ public void send(final Queue destination,
+ final Message message,
+ final int deliveryMode,
+ final int priority,
+ final long timeToLive) throws JMSException
{
session.lock();
try
{
if (trace)
- log.trace("send " + this + " destination=" + destination + " message=" + message + " deliveryMode=" + deliveryMode + " priority=" + priority + " ttl=" + timeToLive);
+ {
+ log.trace("send " + this +
+ " destination=" +
+ destination +
+ " message=" +
+ message +
+ " deliveryMode=" +
+ deliveryMode +
+ " priority=" +
+ priority +
+ " ttl=" +
+ timeToLive);
+ }
checkState();
producer.send(destination, message, deliveryMode, priority, timeToLive);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
@@ -104,19 +126,23 @@
* @param message The message
* @exception JMSException Thrown if an error occurs
*/
- public void send(Queue destination, Message message) throws JMSException
+ public void send(final Queue destination, final Message message) throws JMSException
{
session.lock();
try
{
if (trace)
+ {
log.trace("send " + this + " destination=" + destination + " message=" + message);
+ }
checkState();
producer.send(destination, message);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
Modified: trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMRAProperties.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,8 +22,8 @@
package org.jboss.messaging.ra;
import java.io.Serializable;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
import org.jboss.messaging.core.logging.Logger;
@@ -42,7 +42,7 @@
/** The logger */
private static final Logger log = Logger.getLogger(JBMRAProperties.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
@@ -54,7 +54,7 @@
/** */
private Long discoveryRefreshTimeout;
-
+
/** */
private Long discoveryInitialWaitTimeout;
@@ -83,7 +83,7 @@
private Integer consumerMaxRate;
/** */
- private Integer sendWindowSize;
+ private Integer producerWindowSize;
/** */
private Integer producerMaxRate;
@@ -148,39 +148,11 @@
public JBMRAProperties()
{
if (trace)
+ {
log.trace("constructor()");
+ }
+ }
- discoveryGroupAddress = null;
- discoveryGroupPort = null;
- discoveryRefreshTimeout = null;
- discoveryInitialWaitTimeout = null;
- loadBalancingPolicyClassName = null;
- pingPeriod = null;
- connectionTTL = null;
- callTimeout = null;
- dupsOKBatchSize = null;
- transactionBatchSize = null;
- consumerWindowSize = null;
- consumerMaxRate = null;
- sendWindowSize = null;
- producerMaxRate = null;
- minLargeMessageSize = null;
- blockOnAcknowledge = null;
- blockOnNonPersistentSend = null;
- blockOnPersistentSend = null;
- autoGroup = null;
- maxConnections = null;
- preAcknowledge = null;
- retryInterval = null;
- retryIntervalMultiplier = null;
- reconnectAttempts = null;
- failoverOnServerShutdown = null;
- userName = null;
- password = null;
- clientID = null;
- useXA = null;
- }
-
/**
* Get the discovery group name
* @return The value
@@ -188,7 +160,9 @@
public String getDiscoveryGroupAddress()
{
if (trace)
+ {
log.trace("getDiscoveryGroupAddress()");
+ }
return discoveryGroupAddress;
}
@@ -197,10 +171,12 @@
* Set the discovery group name
* @param dgn The value
*/
- public void setDiscoveryGroupAddress(String dgn)
+ public void setDiscoveryGroupAddress(final String dgn)
{
if (trace)
+ {
log.trace("setDiscoveryGroupAddress(" + dgn + ")");
+ }
discoveryGroupAddress = dgn;
}
@@ -212,7 +188,9 @@
public Integer getDiscoveryGroupPort()
{
if (trace)
+ {
log.trace("getDiscoveryGroupPort()");
+ }
return discoveryGroupPort;
}
@@ -221,10 +199,12 @@
* Set the discovery group port
* @param dgp The value
*/
- public void setDiscoveryGroupPort(Integer dgp)
+ public void setDiscoveryGroupPort(final Integer dgp)
{
if (trace)
+ {
log.trace("setDiscoveryGroupPort(" + dgp + ")");
+ }
discoveryGroupPort = dgp;
}
@@ -236,7 +216,9 @@
public Long getDiscoveryRefreshTimeout()
{
if (trace)
+ {
log.trace("getDiscoveryRefreshTimeout()");
+ }
return discoveryRefreshTimeout;
}
@@ -245,10 +227,12 @@
* Set discovery refresh timeout
* @param discoveryRefreshTimeout The value
*/
- public void setDiscoveryRefreshTimeout(Long discoveryRefreshTimeout)
+ public void setDiscoveryRefreshTimeout(final Long discoveryRefreshTimeout)
{
if (trace)
+ {
log.trace("setDiscoveryRefreshTimeout(" + discoveryRefreshTimeout + ")");
+ }
this.discoveryRefreshTimeout = discoveryRefreshTimeout;
}
@@ -260,7 +244,9 @@
public Long getDiscoveryInitialWaitTimeout()
{
if (trace)
+ {
log.trace("getDiscoveryInitialWaitTimeout()");
+ }
return discoveryInitialWaitTimeout;
}
@@ -269,10 +255,12 @@
* Set discovery initial wait timeout
* @param discoveryInitialWaitTimeout The value
*/
- public void setDiscoveryInitialWaitTimeout(Long discoveryInitialWaitTimeout)
+ public void setDiscoveryInitialWaitTimeout(final Long discoveryInitialWaitTimeout)
{
if (trace)
+ {
log.trace("setDiscoveryInitialWaitTimeout(" + discoveryInitialWaitTimeout + ")");
+ }
this.discoveryInitialWaitTimeout = discoveryInitialWaitTimeout;
}
@@ -284,7 +272,9 @@
public String getLoadBalancingPolicyClassName()
{
if (trace)
+ {
log.trace("getLoadBalancingPolicyClassName()");
+ }
return loadBalancingPolicyClassName;
}
@@ -293,10 +283,12 @@
* Set load balancing policy class name
* @param loadBalancingPolicyClassName The value
*/
- public void setLoadBalancingPolicyClassName(String loadBalancingPolicyClassName)
+ public void setLoadBalancingPolicyClassName(final String loadBalancingPolicyClassName)
{
if (trace)
+ {
log.trace("setLoadBalancingPolicyClassName(" + loadBalancingPolicyClassName + ")");
+ }
this.loadBalancingPolicyClassName = loadBalancingPolicyClassName;
}
@@ -308,7 +300,9 @@
public Long getPingPeriod()
{
if (trace)
+ {
log.trace("getPingPeriod()");
+ }
return pingPeriod;
}
@@ -317,10 +311,12 @@
* Set ping period
* @param pingPeriod The value
*/
- public void setPingPeriod(Long pingPeriod)
+ public void setPingPeriod(final Long pingPeriod)
{
if (trace)
+ {
log.trace("setPingPeriod(" + pingPeriod + ")");
+ }
this.pingPeriod = pingPeriod;
}
@@ -332,7 +328,9 @@
public Long getConnectionTTL()
{
if (trace)
+ {
log.trace("getConnectionTTL()");
+ }
return connectionTTL;
}
@@ -341,10 +339,12 @@
* Set connection TTL
* @param connectionTTL The value
*/
- public void setConnectionTTL(Long connectionTTL)
+ public void setConnectionTTL(final Long connectionTTL)
{
if (trace)
+ {
log.trace("setConnectionTTL(" + connectionTTL + ")");
+ }
this.connectionTTL = connectionTTL;
}
@@ -356,7 +356,9 @@
public Long getCallTimeout()
{
if (trace)
+ {
log.trace("getCallTimeout()");
+ }
return callTimeout;
}
@@ -365,10 +367,12 @@
* Set call timeout
* @param callTimeout The value
*/
- public void setCallTimeout(Long callTimeout)
+ public void setCallTimeout(final Long callTimeout)
{
if (trace)
+ {
log.trace("setCallTimeout(" + callTimeout + ")");
+ }
this.callTimeout = callTimeout;
}
@@ -380,7 +384,9 @@
public Integer getDupsOKBatchSize()
{
if (trace)
+ {
log.trace("getDupsOKBatchSize()");
+ }
return dupsOKBatchSize;
}
@@ -389,10 +395,12 @@
* Set dups ok batch size
* @param dupsOKBatchSize The value
*/
- public void setDupsOKBatchSize(Integer dupsOKBatchSize)
+ public void setDupsOKBatchSize(final Integer dupsOKBatchSize)
{
if (trace)
+ {
log.trace("setDupsOKBatchSize(" + dupsOKBatchSize + ")");
+ }
this.dupsOKBatchSize = dupsOKBatchSize;
}
@@ -404,7 +412,9 @@
public Integer getTransactionBatchSize()
{
if (trace)
+ {
log.trace("getTransactionBatchSize()");
+ }
return transactionBatchSize;
}
@@ -413,10 +423,12 @@
* Set transaction batch size
* @param transactionBatchSize The value
*/
- public void setTransactionBatchSize(Integer transactionBatchSize)
+ public void setTransactionBatchSize(final Integer transactionBatchSize)
{
if (trace)
+ {
log.trace("setTransactionBatchSize(" + transactionBatchSize + ")");
+ }
this.transactionBatchSize = transactionBatchSize;
}
@@ -428,7 +440,9 @@
public Integer getConsumerWindowSize()
{
if (trace)
+ {
log.trace("getConsumerWindowSize()");
+ }
return consumerWindowSize;
}
@@ -437,10 +451,12 @@
* Set consumer window size
* @param consumerWindowSize The value
*/
- public void setConsumerWindowSize(Integer consumerWindowSize)
+ public void setConsumerWindowSize(final Integer consumerWindowSize)
{
if (trace)
+ {
log.trace("setConsumerWindowSize(" + consumerWindowSize + ")");
+ }
this.consumerWindowSize = consumerWindowSize;
}
@@ -452,7 +468,9 @@
public Integer getConsumerMaxRate()
{
if (trace)
+ {
log.trace("getConsumerMaxRate()");
+ }
return consumerMaxRate;
}
@@ -461,36 +479,42 @@
* Set consumer max rate
* @param consumerMaxRate The value
*/
- public void setConsumerMaxRate(Integer consumerMaxRate)
+ public void setConsumerMaxRate(final Integer consumerMaxRate)
{
if (trace)
+ {
log.trace("setConsumerMaxRate(" + consumerMaxRate + ")");
+ }
this.consumerMaxRate = consumerMaxRate;
}
/**
- * Get send window size
+ * Get producer window size
* @return The value
*/
- public Integer getSendWindowSize()
+ public Integer getProducerWindowSize()
{
if (trace)
- log.trace("getSendWindowSize()");
+ {
+ log.trace("getProducerWindowSize()");
+ }
- return sendWindowSize;
+ return producerWindowSize;
}
/**
- * Set send window size
- * @param sendWindowSize The value
+ * Set producer window size
+ * @param producerWindowSize The value
*/
- public void setSendWindowSize(Integer sendWindowSize)
+ public void setProducerWindowSize(final Integer producerWindowSize)
{
if (trace)
- log.trace("setSendWindowSize(" + sendWindowSize + ")");
+ {
+ log.trace("setProducerWindowSize(" + producerWindowSize + ")");
+ }
- this.sendWindowSize = sendWindowSize;
+ this.producerWindowSize = producerWindowSize;
}
/**
@@ -500,7 +524,9 @@
public Integer getProducerMaxRate()
{
if (trace)
+ {
log.trace("getProducerMaxRate()");
+ }
return producerMaxRate;
}
@@ -509,10 +535,12 @@
* Set producer max rate
* @param producerMaxRate The value
*/
- public void setProducerMaxRate(Integer producerMaxRate)
+ public void setProducerMaxRate(final Integer producerMaxRate)
{
if (trace)
+ {
log.trace("setProducerMaxRate(" + producerMaxRate + ")");
+ }
this.producerMaxRate = producerMaxRate;
}
@@ -524,7 +552,9 @@
public Integer getMinLargeMessageSize()
{
if (trace)
+ {
log.trace("getMinLargeMessageSize()");
+ }
return minLargeMessageSize;
}
@@ -533,10 +563,12 @@
* Set min large message size
* @param minLargeMessageSize The value
*/
- public void setMinLargeMessageSize(Integer minLargeMessageSize)
+ public void setMinLargeMessageSize(final Integer minLargeMessageSize)
{
if (trace)
+ {
log.trace("setMinLargeMessageSize(" + minLargeMessageSize + ")");
+ }
this.minLargeMessageSize = minLargeMessageSize;
}
@@ -548,7 +580,9 @@
public Boolean getBlockOnAcknowledge()
{
if (trace)
+ {
log.trace("getBlockOnAcknowledge()");
+ }
return blockOnAcknowledge;
}
@@ -557,10 +591,12 @@
* Set block on acknowledge
* @param blockOnAcknowledge The value
*/
- public void setBlockOnAcknowledge(Boolean blockOnAcknowledge)
+ public void setBlockOnAcknowledge(final Boolean blockOnAcknowledge)
{
if (trace)
+ {
log.trace("setBlockOnAcknowledge(" + blockOnAcknowledge + ")");
+ }
this.blockOnAcknowledge = blockOnAcknowledge;
}
@@ -572,7 +608,9 @@
public Boolean getBlockOnNonPersistentSend()
{
if (trace)
+ {
log.trace("getBlockOnNonPersistentSend()");
+ }
return blockOnNonPersistentSend;
}
@@ -581,10 +619,12 @@
* Set block on non persistent send
* @param blockOnNonPersistentSend The value
*/
- public void setBlockOnNonPersistentSend(Boolean blockOnNonPersistentSend)
+ public void setBlockOnNonPersistentSend(final Boolean blockOnNonPersistentSend)
{
if (trace)
+ {
log.trace("setBlockOnNonPersistentSend(" + blockOnNonPersistentSend + ")");
+ }
this.blockOnNonPersistentSend = blockOnNonPersistentSend;
}
@@ -596,7 +636,9 @@
public Boolean getBlockOnPersistentSend()
{
if (trace)
+ {
log.trace("getBlockOnPersistentSend()");
+ }
return blockOnPersistentSend;
}
@@ -605,10 +647,12 @@
* Set block on persistent send
* @param blockOnPersistentSend The value
*/
- public void setBlockOnPersistentSend(Boolean blockOnPersistentSend)
+ public void setBlockOnPersistentSend(final Boolean blockOnPersistentSend)
{
if (trace)
+ {
log.trace("setBlockOnPersistentSend(" + blockOnPersistentSend + ")");
+ }
this.blockOnPersistentSend = blockOnPersistentSend;
}
@@ -620,7 +664,9 @@
public Boolean getAutoGroup()
{
if (trace)
+ {
log.trace("getAutoGroup()");
+ }
return autoGroup;
}
@@ -629,10 +675,12 @@
* Set auto group
* @param autoGroup The value
*/
- public void setAutoGroup(Boolean autoGroup)
+ public void setAutoGroup(final Boolean autoGroup)
{
if (trace)
+ {
log.trace("setAutoGroup(" + autoGroup + ")");
+ }
this.autoGroup = autoGroup;
}
@@ -644,7 +692,9 @@
public Integer getMaxConnections()
{
if (trace)
+ {
log.trace("getMaxConnections()");
+ }
return maxConnections;
}
@@ -653,10 +703,12 @@
* Set max connections
* @param maxConnections The value
*/
- public void setMaxConnections(Integer maxConnections)
+ public void setMaxConnections(final Integer maxConnections)
{
if (trace)
+ {
log.trace("setMaxConnections(" + maxConnections + ")");
+ }
this.maxConnections = maxConnections;
}
@@ -668,7 +720,9 @@
public Boolean getPreAcknowledge()
{
if (trace)
+ {
log.trace("getPreAcknowledge()");
+ }
return preAcknowledge;
}
@@ -677,10 +731,12 @@
* Set pre acknowledge
* @param preAcknowledge The value
*/
- public void setPreAcknowledge(Boolean preAcknowledge)
+ public void setPreAcknowledge(final Boolean preAcknowledge)
{
if (trace)
+ {
log.trace("setPreAcknowledge(" + preAcknowledge + ")");
+ }
this.preAcknowledge = preAcknowledge;
}
@@ -692,7 +748,9 @@
public Long getRetryInterval()
{
if (trace)
+ {
log.trace("getRetryInterval()");
+ }
return retryInterval;
}
@@ -701,10 +759,12 @@
* Set retry interval
* @param retryInterval The value
*/
- public void setRetryInterval(Long retryInterval)
+ public void setRetryInterval(final Long retryInterval)
{
if (trace)
+ {
log.trace("setRetryInterval(" + retryInterval + ")");
+ }
this.retryInterval = retryInterval;
}
@@ -716,7 +776,9 @@
public Double getRetryIntervalMultiplier()
{
if (trace)
+ {
log.trace("getRetryIntervalMultiplier()");
+ }
return retryIntervalMultiplier;
}
@@ -725,10 +787,12 @@
* Set retry interval multiplier
* @param retryIntervalMultiplier The value
*/
- public void setRetryIntervalMultiplier(Double retryIntervalMultiplier)
+ public void setRetryIntervalMultiplier(final Double retryIntervalMultiplier)
{
if (trace)
+ {
log.trace("setRetryIntervalMultiplier(" + retryIntervalMultiplier + ")");
+ }
this.retryIntervalMultiplier = retryIntervalMultiplier;
}
@@ -740,7 +804,9 @@
public Integer getReconnectAttempts()
{
if (trace)
+ {
log.trace("getReconnectAttempts()");
+ }
return reconnectAttempts;
}
@@ -749,10 +815,12 @@
* Set reconnect attempts
* @param reconnectAttempts The value
*/
- public void setReconnectAttempts(Integer reconnectAttempts)
+ public void setReconnectAttempts(final Integer reconnectAttempts)
{
if (trace)
+ {
log.trace("setReconnectAttempts(" + reconnectAttempts + ")");
+ }
this.reconnectAttempts = reconnectAttempts;
}
@@ -764,7 +832,9 @@
public Boolean isFailoverOnServerShutdown()
{
if (trace)
+ {
log.trace("isFailoverOnServerShutdown()");
+ }
return failoverOnServerShutdown;
}
@@ -773,10 +843,12 @@
* Set failover on server shutdown
* @param failoverOnServerShutdown The value
*/
- public void setFailoverOnServerShutdown(Boolean failoverOnServerShutdown)
+ public void setFailoverOnServerShutdown(final Boolean failoverOnServerShutdown)
{
if (trace)
+ {
log.trace("setFailoverOnServerShutdown(" + failoverOnServerShutdown + ")");
+ }
this.failoverOnServerShutdown = failoverOnServerShutdown;
}
@@ -788,7 +860,9 @@
public String getUserName()
{
if (trace)
+ {
log.trace("getUserName()");
+ }
return userName;
}
@@ -797,14 +871,16 @@
* Set the user name
* @param userName The value
*/
- public void setUserName(String userName)
+ public void setUserName(final String userName)
{
if (trace)
+ {
log.trace("setUserName(" + userName + ")");
+ }
this.userName = userName;
}
-
+
/**
* Get the password
* @return The value
@@ -812,7 +888,9 @@
public String getPassword()
{
if (trace)
+ {
log.trace("getPassword()");
+ }
return password;
}
@@ -821,14 +899,16 @@
* Set the password
* @param password The value
*/
- public void setPassword(String password)
+ public void setPassword(final String password)
{
if (trace)
+ {
log.trace("setPassword(****)");
+ }
this.password = password;
}
-
+
/**
* Get the client id
* @return The value
@@ -836,7 +916,9 @@
public String getClientID()
{
if (trace)
+ {
log.trace("getClientID()");
+ }
return clientID;
}
@@ -845,14 +927,16 @@
* Set the client id
* @param clientID The value
*/
- public void setClientID(String clientID)
+ public void setClientID(final String clientID)
{
if (trace)
+ {
log.trace("setClientID(" + clientID + ")");
+ }
this.clientID = clientID;
}
-
+
/**
* Get the use XA flag
* @return The value
@@ -860,7 +944,9 @@
public Boolean getUseXA()
{
if (trace)
+ {
log.trace("getUseXA()");
+ }
return useXA;
}
@@ -869,12 +955,14 @@
* Set the use XA flag
* @param xa The value
*/
- public void setUseXA(Boolean xa)
+ public void setUseXA(final Boolean xa)
{
if (trace)
+ {
log.trace("setUseXA(" + xa + ")");
+ }
- this.useXA = xa;
+ useXA = xa;
}
/**
@@ -884,10 +972,14 @@
public boolean isUseXA()
{
if (trace)
+ {
log.trace("isUseXA()");
+ }
if (useXA == null)
+ {
return false;
+ }
return useXA.booleanValue();
}
@@ -897,59 +989,67 @@
* @param obj Object with which to compare
* @return True if this object is the same as the obj argument; false otherwise.
*/
- public boolean equals(Object obj)
+ @Override
+ public boolean equals(final Object obj)
{
if (trace)
+ {
log.trace("equals(" + obj + ")");
+ }
- if (obj == null)
+ if (obj == null)
+ {
return false;
-
+ }
+
if (obj instanceof JBMRAProperties)
{
- JBMRAProperties you = (JBMRAProperties) obj;
- return (Util.compare(discoveryGroupAddress, you.getDiscoveryGroupAddress()) &&
- Util.compare(discoveryGroupPort, you.getDiscoveryGroupPort()) &&
- Util.compare(discoveryRefreshTimeout, you.getDiscoveryRefreshTimeout()) &&
- Util.compare(discoveryInitialWaitTimeout, you.getDiscoveryInitialWaitTimeout()) &&
- Util.compare(loadBalancingPolicyClassName, you.getLoadBalancingPolicyClassName()) &&
- Util.compare(pingPeriod, you.getPingPeriod()) &&
- Util.compare(connectionTTL, you.getConnectionTTL()) &&
- Util.compare(callTimeout, you.getCallTimeout()) &&
- Util.compare(dupsOKBatchSize, you.getDupsOKBatchSize()) &&
- Util.compare(transactionBatchSize, you.getTransactionBatchSize()) &&
- Util.compare(consumerWindowSize, you.getConsumerWindowSize()) &&
- Util.compare(consumerMaxRate, you.getConsumerMaxRate()) &&
- Util.compare(sendWindowSize, you.getSendWindowSize()) &&
- Util.compare(producerMaxRate, you.getProducerMaxRate()) &&
- Util.compare(minLargeMessageSize, you.getMinLargeMessageSize()) &&
- Util.compare(blockOnAcknowledge, you.getBlockOnAcknowledge()) &&
- Util.compare(blockOnNonPersistentSend, you.getBlockOnNonPersistentSend()) &&
- Util.compare(blockOnPersistentSend, you.getBlockOnPersistentSend()) &&
- Util.compare(autoGroup, you.getAutoGroup()) &&
- Util.compare(maxConnections, you.getMaxConnections()) &&
- Util.compare(preAcknowledge, you.getPreAcknowledge()) &&
- Util.compare(retryInterval, you.getRetryInterval()) &&
- Util.compare(retryIntervalMultiplier, you.getRetryIntervalMultiplier()) &&
- Util.compare(reconnectAttempts, you.getReconnectAttempts()) &&
- Util.compare(failoverOnServerShutdown, you.isFailoverOnServerShutdown()) &&
- Util.compare(userName, you.getUserName()) &&
- Util.compare(password, you.getPassword()) &&
- Util.compare(clientID, you.getClientID()) &&
- Util.compare(useXA, you.getUseXA()));
+ JBMRAProperties you = (JBMRAProperties)obj;
+ return Util.compare(discoveryGroupAddress, you.getDiscoveryGroupAddress()) && Util.compare(discoveryGroupPort,
+ you.getDiscoveryGroupPort()) &&
+ Util.compare(discoveryRefreshTimeout, you.getDiscoveryRefreshTimeout()) &&
+ Util.compare(discoveryInitialWaitTimeout, you.getDiscoveryInitialWaitTimeout()) &&
+ Util.compare(loadBalancingPolicyClassName, you.getLoadBalancingPolicyClassName()) &&
+ Util.compare(pingPeriod, you.getPingPeriod()) &&
+ Util.compare(connectionTTL, you.getConnectionTTL()) &&
+ Util.compare(callTimeout, you.getCallTimeout()) &&
+ Util.compare(dupsOKBatchSize, you.getDupsOKBatchSize()) &&
+ Util.compare(transactionBatchSize, you.getTransactionBatchSize()) &&
+ Util.compare(consumerWindowSize, you.getConsumerWindowSize()) &&
+ Util.compare(consumerMaxRate, you.getConsumerMaxRate()) &&
+ Util.compare(producerWindowSize, you.getProducerWindowSize()) &&
+ Util.compare(producerMaxRate, you.getProducerMaxRate()) &&
+ Util.compare(minLargeMessageSize, you.getMinLargeMessageSize()) &&
+ Util.compare(blockOnAcknowledge, you.getBlockOnAcknowledge()) &&
+ Util.compare(blockOnNonPersistentSend, you.getBlockOnNonPersistentSend()) &&
+ Util.compare(blockOnPersistentSend, you.getBlockOnPersistentSend()) &&
+ Util.compare(autoGroup, you.getAutoGroup()) &&
+ Util.compare(maxConnections, you.getMaxConnections()) &&
+ Util.compare(preAcknowledge, you.getPreAcknowledge()) &&
+ Util.compare(retryInterval, you.getRetryInterval()) &&
+ Util.compare(retryIntervalMultiplier, you.getRetryIntervalMultiplier()) &&
+ Util.compare(reconnectAttempts, you.getReconnectAttempts()) &&
+ Util.compare(failoverOnServerShutdown, you.isFailoverOnServerShutdown()) &&
+ Util.compare(userName, you.getUserName()) &&
+ Util.compare(password, you.getPassword()) &&
+ Util.compare(clientID, you.getClientID()) &&
+ Util.compare(useXA, you.getUseXA());
}
-
+
return false;
}
-
+
/**
* Return the hash code for the object
* @return The hash code
*/
+ @Override
public int hashCode()
{
if (trace)
+ {
log.trace("hashCode()");
+ }
int hash = 7;
@@ -965,7 +1065,7 @@
hash += 31 * hash + (transactionBatchSize != null ? transactionBatchSize.hashCode() : 0);
hash += 31 * hash + (consumerWindowSize != null ? consumerWindowSize.hashCode() : 0);
hash += 31 * hash + (consumerMaxRate != null ? consumerMaxRate.hashCode() : 0);
- hash += 31 * hash + (sendWindowSize != null ? sendWindowSize.hashCode() : 0);
+ hash += 31 * hash + (producerWindowSize != null ? producerWindowSize.hashCode() : 0);
hash += 31 * hash + (producerMaxRate != null ? producerMaxRate.hashCode() : 0);
hash += 31 * hash + (minLargeMessageSize != null ? minLargeMessageSize.hashCode() : 0);
hash += 31 * hash + (blockOnAcknowledge != null ? blockOnAcknowledge.hashCode() : 0);
@@ -986,7 +1086,7 @@
return hash;
}
- public void setConnectorClassName(String connectorClassName)
+ public void setConnectorClassName(final String connectorClassName)
{
this.connectorClassName = connectorClassName;
}
@@ -995,10 +1095,10 @@
{
return connectorClassName;
}
-
- public void setConnectionParameters(Map<String, Object> config)
+
+ public void setConnectionParameters(final Map<String, Object> config)
{
- this.connectionParameters = config;
+ connectionParameters = config;
}
public Map<String, Object> getConnectionParameters()
@@ -1010,10 +1110,10 @@
{
return backupConnectionParameters;
}
-
- public void setBackupConnectionParameters(Map<String, Object> config)
+
+ public void setBackupConnectionParameters(final Map<String, Object> config)
{
- this.backupConnectionParameters = config;
+ backupConnectionParameters = config;
}
public String getBackupConnectorClassName()
@@ -1021,8 +1121,8 @@
return backupConnectorClassName;
}
- public void setBackupConnectorClassName(String connectorClassName)
+ public void setBackupConnectorClassName(final String connectorClassName)
{
- this.backupConnectorClassName = connectorClassName;
+ backupConnectorClassName = connectorClassName;
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMResourceAdapter.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -39,7 +39,6 @@
import org.jboss.messaging.core.client.ClientSessionFactory;
import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.impl.ConfigurationImpl;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.jms.client.JBossConnectionFactory;
@@ -75,7 +74,7 @@
/**
* The resource adapter properties
*/
- private JBMRAProperties raProperties;
+ private final JBMRAProperties raProperties;
/**
* The JBoss connection factory
@@ -85,12 +84,12 @@
/**
* Have the factory been configured
*/
- private AtomicBoolean configured;
+ private final AtomicBoolean configured;
/**
* The activations by activation spec
*/
- private Map<ActivationSpec, JBMActivation> activations;
+ private final Map<ActivationSpec, JBMActivation> activations;
private JBossConnectionFactory jBossConnectionFactory;
@@ -117,7 +116,7 @@
* @param spec The activation spec
* @throws ResourceException Thrown if an error occurs
*/
- public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException
+ public void endpointActivation(final MessageEndpointFactory endpointFactory, final ActivationSpec spec) throws ResourceException
{
if (!configured.getAndSet(true))
{
@@ -146,7 +145,7 @@
* @param endpointFactory The endpoint factory
* @param spec The activation spec
*/
- public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec)
+ public void endpointDeactivation(final MessageEndpointFactory endpointFactory, final ActivationSpec spec)
{
if (trace)
{
@@ -167,7 +166,7 @@
* @return The XA resources
* @throws ResourceException Thrown if an error occurs or unsupported
*/
- public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException
+ public XAResource[] getXAResources(final ActivationSpec[] specs) throws ResourceException
{
if (trace)
{
@@ -184,7 +183,7 @@
* @throws ResourceAdapterInternalException
* Thrown if an error occurs
*/
- public void start(BootstrapContext ctx) throws ResourceAdapterInternalException
+ public void start(final BootstrapContext ctx) throws ResourceAdapterInternalException
{
if (trace)
{
@@ -206,7 +205,7 @@
log.trace("stop()");
}
- for (Map.Entry<ActivationSpec, JBMActivation> entry: activations.entrySet())
+ for (Map.Entry<ActivationSpec, JBMActivation> entry : activations.entrySet())
{
try
{
@@ -217,13 +216,13 @@
log.debug("Ignored", ignored);
}
}
-
+
activations.clear();
log.info("JBoss Messaging resource adapter stopped");
}
- public void setConnectorClassName(String connectorClassName)
+ public void setConnectorClassName(final String connectorClassName)
{
if (trace)
{
@@ -243,7 +242,7 @@
return raProperties.getConnectionParameters();
}
- public void setConnectionParameters(String config)
+ public void setConnectionParameters(final String config)
{
if (config != null)
{
@@ -256,7 +255,7 @@
return raProperties.getBackupConnectorClassName();
}
- public void setBackupConnectorClassName(String backupConnector)
+ public void setBackupConnectorClassName(final String backupConnector)
{
if (trace)
{
@@ -270,7 +269,7 @@
return raProperties.getBackupConnectionParameters();
}
- public void setBackupTransportConfiguration(String config)
+ public void setBackupTransportConfiguration(final String config)
{
if (config != null)
{
@@ -298,7 +297,7 @@
*
* @param dgn The value
*/
- public void setDiscoveryGroupAddress(String dgn)
+ public void setDiscoveryGroupAddress(final String dgn)
{
if (trace)
{
@@ -328,7 +327,7 @@
*
* @param dgp The value
*/
- public void setDiscoveryGroupPort(Integer dgp)
+ public void setDiscoveryGroupPort(final Integer dgp)
{
if (trace)
{
@@ -358,7 +357,7 @@
*
* @param discoveryRefreshTimeout The value
*/
- public void setDiscoveryRefreshTimeout(Long discoveryRefreshTimeout)
+ public void setDiscoveryRefreshTimeout(final Long discoveryRefreshTimeout)
{
if (trace)
{
@@ -388,7 +387,7 @@
*
* @param discoveryInitialWaitTimeout The value
*/
- public void setDiscoveryInitialWaitTimeout(Long discoveryInitialWaitTimeout)
+ public void setDiscoveryInitialWaitTimeout(final Long discoveryInitialWaitTimeout)
{
if (trace)
{
@@ -418,7 +417,7 @@
*
* @param loadBalancingPolicyClassName The value
*/
- public void setLoadBalancingPolicyClassName(String loadBalancingPolicyClassName)
+ public void setLoadBalancingPolicyClassName(final String loadBalancingPolicyClassName)
{
if (trace)
{
@@ -448,7 +447,7 @@
*
* @param pingPeriod The value
*/
- public void setPingPeriod(Long pingPeriod)
+ public void setPingPeriod(final Long pingPeriod)
{
if (trace)
{
@@ -478,7 +477,7 @@
*
* @param connectionTTL The value
*/
- public void setConnectionTTL(Long connectionTTL)
+ public void setConnectionTTL(final Long connectionTTL)
{
if (trace)
{
@@ -508,7 +507,7 @@
*
* @param callTimeout The value
*/
- public void setCallTimeout(Long callTimeout)
+ public void setCallTimeout(final Long callTimeout)
{
if (trace)
{
@@ -538,7 +537,7 @@
*
* @param dupsOKBatchSize The value
*/
- public void setDupsOKBatchSize(Integer dupsOKBatchSize)
+ public void setDupsOKBatchSize(final Integer dupsOKBatchSize)
{
if (trace)
{
@@ -568,7 +567,7 @@
*
* @param transactionBatchSize The value
*/
- public void setTransactionBatchSize(Integer transactionBatchSize)
+ public void setTransactionBatchSize(final Integer transactionBatchSize)
{
if (trace)
{
@@ -598,7 +597,7 @@
*
* @param consumerWindowSize The value
*/
- public void setConsumerWindowSize(Integer consumerWindowSize)
+ public void setConsumerWindowSize(final Integer consumerWindowSize)
{
if (trace)
{
@@ -628,7 +627,7 @@
*
* @param consumerMaxRate The value
*/
- public void setConsumerMaxRate(Integer consumerMaxRate)
+ public void setConsumerMaxRate(final Integer consumerMaxRate)
{
if (trace)
{
@@ -639,33 +638,33 @@
}
/**
- * Get send window size
+ * Get producer window size
*
* @return The value
*/
- public Integer getSendWindowSize()
+ public Integer getProducerWindowSize()
{
if (trace)
{
- log.trace("getSendWindowSize()");
+ log.trace("getProducerWindowSize()");
}
- return raProperties.getSendWindowSize();
+ return raProperties.getProducerWindowSize();
}
/**
- * Set send window size
+ * Set producer window size
*
- * @param sendWindowSize The value
+ * @param producerWindowSize The value
*/
- public void setSendWindowSize(Integer sendWindowSize)
+ public void setProducerWindowSize(final Integer producerWindowSize)
{
if (trace)
{
- log.trace("setSendWindowSize(" + sendWindowSize + ")");
+ log.trace("setProducerWindowSize(" + producerWindowSize + ")");
}
- raProperties.setSendWindowSize(sendWindowSize);
+ raProperties.setProducerWindowSize(producerWindowSize);
}
/**
@@ -688,7 +687,7 @@
*
* @param producerMaxRate The value
*/
- public void setProducerMaxRate(Integer producerMaxRate)
+ public void setProducerMaxRate(final Integer producerMaxRate)
{
if (trace)
{
@@ -718,7 +717,7 @@
*
* @param minLargeMessageSize The value
*/
- public void setMinLargeMessageSize(Integer minLargeMessageSize)
+ public void setMinLargeMessageSize(final Integer minLargeMessageSize)
{
if (trace)
{
@@ -748,7 +747,7 @@
*
* @param blockOnAcknowledge The value
*/
- public void setBlockOnAcknowledge(Boolean blockOnAcknowledge)
+ public void setBlockOnAcknowledge(final Boolean blockOnAcknowledge)
{
if (trace)
{
@@ -778,7 +777,7 @@
*
* @param blockOnNonPersistentSend The value
*/
- public void setBlockOnNonPersistentSend(Boolean blockOnNonPersistentSend)
+ public void setBlockOnNonPersistentSend(final Boolean blockOnNonPersistentSend)
{
if (trace)
{
@@ -808,7 +807,7 @@
*
* @param blockOnPersistentSend The value
*/
- public void setBlockOnPersistentSend(Boolean blockOnPersistentSend)
+ public void setBlockOnPersistentSend(final Boolean blockOnPersistentSend)
{
if (trace)
{
@@ -838,7 +837,7 @@
*
* @param autoGroup The value
*/
- public void setAutoGroup(Boolean autoGroup)
+ public void setAutoGroup(final Boolean autoGroup)
{
if (trace)
{
@@ -868,7 +867,7 @@
*
* @param maxConnections The value
*/
- public void setMaxConnections(Integer maxConnections)
+ public void setMaxConnections(final Integer maxConnections)
{
if (trace)
{
@@ -898,7 +897,7 @@
*
* @param preAcknowledge The value
*/
- public void setPreAcknowledge(Boolean preAcknowledge)
+ public void setPreAcknowledge(final Boolean preAcknowledge)
{
if (trace)
{
@@ -928,7 +927,7 @@
*
* @param retryInterval The value
*/
- public void setRetryInterval(Long retryInterval)
+ public void setRetryInterval(final Long retryInterval)
{
if (trace)
{
@@ -958,7 +957,7 @@
*
* @param retryIntervalMultiplier The value
*/
- public void setRetryIntervalMultiplier(Double retryIntervalMultiplier)
+ public void setRetryIntervalMultiplier(final Double retryIntervalMultiplier)
{
if (trace)
{
@@ -988,7 +987,7 @@
*
* @param reconnectAttempts The value
*/
- public void setReconnectAttempts(Integer reconnectAttempts)
+ public void setReconnectAttempts(final Integer reconnectAttempts)
{
if (trace)
{
@@ -1028,7 +1027,7 @@
*
* @param failoverOnServerShutdown The value
*/
- public void setFailoverOnServerShutdown(Boolean failoverOnServerShutdown)
+ public void setFailoverOnServerShutdown(final Boolean failoverOnServerShutdown)
{
if (trace)
{
@@ -1058,7 +1057,7 @@
*
* @param userName The value
*/
- public void setUserName(String userName)
+ public void setUserName(final String userName)
{
if (trace)
{
@@ -1088,7 +1087,7 @@
*
* @param password The value
*/
- public void setPassword(String password)
+ public void setPassword(final String password)
{
if (trace)
{
@@ -1118,7 +1117,7 @@
*
* @param clientID The client id
*/
- public void setClientID(String clientID)
+ public void setClientID(final String clientID)
{
if (trace)
{
@@ -1148,7 +1147,7 @@
*
* @param xa The value
*/
- public void setUseXA(Boolean xa)
+ public void setUseXA(final Boolean xa)
{
if (trace)
{
@@ -1164,7 +1163,7 @@
* @param obj Object with which to compare
* @return True if this object is the same as the obj argument; false otherwise.
*/
- public boolean equals(Object obj)
+ public boolean equals(final Object obj)
{
if (trace)
{
@@ -1221,15 +1220,15 @@
return ctx.getWorkManager();
}
- public ClientSession createSession(int ackMode,
- String user,
- String pass,
- Boolean preAck,
- Integer dupsOkBatchSize,
- Integer transactionBatchSize,
- boolean deliveryTransacted) throws Exception
+ public ClientSession createSession(final int ackMode,
+ final String user,
+ final String pass,
+ final Boolean preAck,
+ final Integer dupsOkBatchSize,
+ final Integer transactionBatchSize,
+ final boolean deliveryTransacted) throws Exception
{
- return createSession(this.sessionFactory,
+ return createSession(sessionFactory,
ackMode,
user,
pass,
@@ -1239,14 +1238,14 @@
deliveryTransacted);
}
- public ClientSession createSession(ClientSessionFactory parameterFactory,
- int ackMode,
- String user,
- String pass,
- Boolean preAck,
- Integer dupsOkBatchSize,
- Integer transactionBatchSize,
- boolean deliveryTransacted) throws Exception
+ public ClientSession createSession(final ClientSessionFactory parameterFactory,
+ final int ackMode,
+ final String user,
+ final String pass,
+ final Boolean preAck,
+ final Integer dupsOkBatchSize,
+ final Integer transactionBatchSize,
+ final boolean deliveryTransacted) throws Exception
{
ClientSession result;
@@ -1259,25 +1258,49 @@
switch (ackMode)
{
case Session.SESSION_TRANSACTED:
- result = parameterFactory.createSession(user, pass, deliveryTransacted, false, false, actPreAck, actTxBatchSize);
+ result = parameterFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ false,
+ false,
+ actPreAck,
+ actTxBatchSize);
break;
case Session.AUTO_ACKNOWLEDGE:
- result = parameterFactory.createSession(user, pass, deliveryTransacted, true, false, actPreAck, actTxBatchSize);
+ result = parameterFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ true,
+ false,
+ actPreAck,
+ actTxBatchSize);
break;
case Session.DUPS_OK_ACKNOWLEDGE:
result = parameterFactory.createSession(user,
- pass,
- deliveryTransacted,
- true,
- false,
- actPreAck,
- actDupsOkBatchSize);
+ pass,
+ deliveryTransacted,
+ true,
+ false,
+ actPreAck,
+ actDupsOkBatchSize);
break;
case Session.CLIENT_ACKNOWLEDGE:
- result = parameterFactory.createSession(user, pass, deliveryTransacted, false, false, actPreAck, actTxBatchSize);
+ result = parameterFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ false,
+ false,
+ actPreAck,
+ actTxBatchSize);
break;
case JBossSession.PRE_ACKNOWLEDGE:
- result = parameterFactory.createSession(user, pass, deliveryTransacted, false, true, actPreAck, actTxBatchSize);
+ result = parameterFactory.createSession(user,
+ pass,
+ deliveryTransacted,
+ false,
+ true,
+ actPreAck,
+ actTxBatchSize);
break;
default:
throw new IllegalArgumentException("Invalid ackmode: " + ackMode);
@@ -1289,119 +1312,150 @@
}
+ private void setParams(final JBossConnectionFactory cf)
+ {
+ if (getLoadBalancingPolicyClassName() != null)
+ {
+ cf.setConnectionLoadBalancingPolicyClassName(getLoadBalancingPolicyClassName());
+ }
+
+ if (getPingPeriod() != null)
+ {
+ cf.setPingPeriod(getPingPeriod());
+ }
+
+ if (getConnectionTTL() != null)
+ {
+ cf.setConnectionTTL(getConnectionTTL());
+ }
+
+ if (getCallTimeout() != null)
+ {
+ cf.setCallTimeout(getCallTimeout());
+ }
+
+ if (getClientID() != null)
+ {
+ cf.setClientID(getClientID());
+ }
+
+ if (getDupsOKBatchSize() != null)
+ {
+ cf.setDupsOKBatchSize(getDupsOKBatchSize());
+ }
+
+ if (getTransactionBatchSize() != null)
+ {
+ cf.setTransactionBatchSize(getTransactionBatchSize());
+ }
+
+ if (getConsumerWindowSize() != null)
+ {
+ cf.setConsumerWindowSize(getConsumerWindowSize());
+ }
+
+ if (getConsumerMaxRate() != null)
+ {
+ cf.setConsumerMaxRate(getConsumerMaxRate());
+ }
+
+ if (getProducerWindowSize() != null)
+ {
+ cf.setProducerWindowSize(getProducerWindowSize());
+ }
+
+ if (getProducerMaxRate() != null)
+ {
+ cf.setProducerMaxRate(getProducerMaxRate());
+ }
+
+ if (getMinLargeMessageSize() != null)
+ {
+ cf.setMinLargeMessageSize(getMinLargeMessageSize());
+ }
+
+ if (getBlockOnAcknowledge() != null)
+ {
+ cf.setBlockOnAcknowledge(getBlockOnAcknowledge());
+ }
+
+ if (getBlockOnNonPersistentSend() != null)
+ {
+ cf.setBlockOnNonPersistentSend(getBlockOnNonPersistentSend());
+ }
+
+ if (getBlockOnPersistentSend() != null)
+ {
+ cf.setBlockOnPersistentSend(getBlockOnPersistentSend());
+ }
+
+ if (getAutoGroup() != null)
+ {
+ cf.setAutoGroup(getAutoGroup());
+ }
+
+ if (getMaxConnections() != null)
+ {
+ cf.setMaxConnections(getMaxConnections());
+ }
+
+ if (getPreAcknowledge() != null)
+ {
+ cf.setPreAcknowledge(getPreAcknowledge());
+ }
+
+ if (getRetryInterval() != null)
+ {
+ cf.setRetryInterval(getRetryInterval());
+ }
+
+ if (getRetryIntervalMultiplier() != null)
+ {
+ cf.setRetryIntervalMultiplier(getRetryIntervalMultiplier());
+ }
+
+ if (getReconnectAttempts() != null)
+ {
+ cf.setReconnectAttempts(getReconnectAttempts());
+ }
+
+ if (getFailoverOnServerShutdown() != null)
+ {
+ cf.setFailoverOnServerShutdown(getFailoverOnServerShutdown());
+ }
+ }
+
/**
* @param connectorClassName
* @param connectionParameters
*/
- public JBossConnectionFactory createRemoteFactory(String connectorClassName, Map<String, Object> connectionParameters)
+ public JBossConnectionFactory createRemoteFactory(final String connectorClassName,
+ final Map<String, Object> connectionParameters)
{
TransportConfiguration transportConf = new TransportConfiguration(connectorClassName, connectionParameters);
TransportConfiguration backup = getBackupConnectorClassName() == null ? null
- : new TransportConfiguration(getBackupConnectorClassName(),
- getBackupConnectionParameters());
- return new JBossConnectionFactory(transportConf,
- backup,
- getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME
- : getLoadBalancingPolicyClassName(),
- getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD
- : getPingPeriod(),
- getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL
- : getConnectionTTL(),
- getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT
- : getCallTimeout(),
- getClientID(),
- getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
- : getDupsOKBatchSize(),
- getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
- : getTransactionBatchSize(),
- getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE
- : getConsumerWindowSize(),
- getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE
- : getConsumerMaxRate(),
- getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE
- : getSendWindowSize(),
- getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE
- : getProducerMaxRate(),
- getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE
- : getMinLargeMessageSize(),
- getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE
- : getBlockOnAcknowledge(),
- getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND
- : getBlockOnNonPersistentSend(),
- getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND
- : getBlockOnPersistentSend(),
- getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP
- : getAutoGroup(),
- getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS
- : getMaxConnections(),
- getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE
- : getPreAcknowledge(),
- getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL
- : getRetryInterval(),
- getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER
- : getRetryIntervalMultiplier(),
- getReconnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS
- : getReconnectAttempts(),
- isFailoverOnServerShutdown() == null ? ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN
- : isFailoverOnServerShutdown());
+ : new TransportConfiguration(getBackupConnectorClassName(),
+ getBackupConnectionParameters());
+
+ JBossConnectionFactory cf = new JBossConnectionFactory(transportConf, backup);
+
+ setParams(cf);
+
+ return cf;
}
/**
* @param discoveryGroup
* @param discoveryGroupPort
*/
- public JBossConnectionFactory createDiscoveryFactory(String discoveryGroup, Integer discoveryGroupPort)
+ public JBossConnectionFactory createDiscoveryFactory(final String discoveryGroup, final Integer discoveryGroupPort)
{
- return new JBossConnectionFactory(discoveryGroup,
- discoveryGroupPort,
- getDiscoveryRefreshTimeout() == null ? ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT
- : getDiscoveryRefreshTimeout(),
- getDiscoveryInitialWaitTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT
- : getDiscoveryInitialWaitTimeout(),
- getLoadBalancingPolicyClassName() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME
- : getLoadBalancingPolicyClassName(),
- getPingPeriod() == null ? ClientSessionFactoryImpl.DEFAULT_PING_PERIOD
- : getPingPeriod(),
- getConnectionTTL() == null ? ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL
- : getConnectionTTL(),
- getCallTimeout() == null ? ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT
- : getCallTimeout(),
- getClientID(),
- getDupsOKBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
- : getDupsOKBatchSize(),
- getTransactionBatchSize() == null ? ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE
- : getTransactionBatchSize(),
- getConsumerWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE
- : getConsumerWindowSize(),
- getConsumerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE
- : getConsumerMaxRate(),
- getSendWindowSize() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE
- : getSendWindowSize(),
- getProducerMaxRate() == null ? ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE
- : getProducerMaxRate(),
- getMinLargeMessageSize() == null ? ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE
- : getMinLargeMessageSize(),
- getBlockOnAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE
- : getBlockOnAcknowledge(),
- getBlockOnNonPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND
- : getBlockOnNonPersistentSend(),
- getBlockOnPersistentSend() == null ? ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND
- : getBlockOnPersistentSend(),
- getAutoGroup() == null ? ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP
- : getAutoGroup(),
- getMaxConnections() == null ? ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS
- : getMaxConnections(),
- getPreAcknowledge() == null ? ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE
- : getPreAcknowledge(),
- getRetryInterval() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL
- : getRetryInterval(),
- getRetryIntervalMultiplier() == null ? ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER
- : getRetryIntervalMultiplier(),
- getReconnectAttempts() == null ? ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS
- : getReconnectAttempts(),
- isFailoverOnServerShutdown() == null ? ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN
- : isFailoverOnServerShutdown());
+ JBossConnectionFactory cf = new JBossConnectionFactory(discoveryGroup, discoveryGroupPort);
+
+ setParams(cf);
+
+ return cf;
}
/**
Modified: trunk/src/main/org/jboss/messaging/ra/JBMSession.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMSession.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMSession.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -71,7 +71,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMSession.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
@@ -79,42 +79,46 @@
private JBMManagedConnection mc;
/** The connection request info */
- private JBMConnectionRequestInfo cri;
+ private final JBMConnectionRequestInfo cri;
/** The session factory */
private JBMSessionFactory sf;
-
+
/** The message consumers */
- private Set consumers;
-
+ private final Set consumers;
+
/** The message producers */
- private Set producers;
-
+ private final Set producers;
+
/**
* Constructor
* @param mc The managed connection
* @param cri The connection request info
*/
- public JBMSession(JBMManagedConnection mc, JBMConnectionRequestInfo cri)
+ public JBMSession(final JBMManagedConnection mc, final JBMConnectionRequestInfo cri)
{
if (trace)
+ {
log.trace("constructor(" + mc + ", " + cri + ")");
+ }
this.mc = mc;
this.cri = cri;
- this.sf = null;
- this.consumers = new HashSet();
- this.producers = new HashSet();
+ sf = null;
+ consumers = new HashSet();
+ producers = new HashSet();
}
/**
* Set the session factory
* @param sf The session factory
*/
- public void setJBMSessionFactory(JBMSessionFactory sf)
+ public void setJBMSessionFactory(final JBMSessionFactory sf)
{
if (trace)
+ {
log.trace("setJBMSessionFactory(" + sf + ")");
+ }
this.sf = sf;
}
@@ -127,13 +131,19 @@
protected void lock() throws JMSException
{
if (trace)
+ {
log.trace("lock()");
+ }
JBMManagedConnection mc = this.mc;
if (mc != null)
+ {
mc.tryLock();
+ }
else
+ {
throw new IllegalStateException("Connection is not associated with a managed connection. " + this);
+ }
}
/**
@@ -142,16 +152,20 @@
protected void unlock()
{
if (trace)
+ {
log.trace("unlock()");
+ }
JBMManagedConnection mc = this.mc;
if (mc != null)
+ {
mc.unlock();
+ }
// We recreate the lock when returned to the pool
// so missing the unlock after disassociation is not important
}
-
+
/**
* Create a bytes message
* @return The message
@@ -162,7 +176,9 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createBytesMessage" + session);
+ }
return session.createBytesMessage();
}
@@ -177,7 +193,9 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createMapMessage" + session);
+ }
return session.createMapMessage();
}
@@ -192,7 +210,9 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createMessage" + session);
+ }
return session.createMessage();
}
@@ -207,7 +227,9 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createObjectMessage" + session);
+ }
return session.createObjectMessage();
}
@@ -218,12 +240,14 @@
* @return The message
* @exception JMSException Thrown if an error occurs
*/
- public ObjectMessage createObjectMessage(Serializable object) throws JMSException
+ public ObjectMessage createObjectMessage(final Serializable object) throws JMSException
{
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createObjectMessage(" + object + ")" + session);
+ }
return session.createObjectMessage(object);
}
@@ -238,7 +262,9 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createStreamMessage" + session);
+ }
return session.createStreamMessage();
}
@@ -253,7 +279,9 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createTextMessage" + session);
+ }
return session.createTextMessage();
}
@@ -264,12 +292,14 @@
* @return The message
* @exception JMSException Thrown if an error occurs
*/
- public TextMessage createTextMessage(String string) throws JMSException
+ public TextMessage createTextMessage(final String string) throws JMSException
{
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createTextMessage(" + string + ")" + session);
+ }
return session.createTextMessage(string);
}
@@ -282,7 +312,9 @@
public boolean getTransacted() throws JMSException
{
if (trace)
+ {
log.trace("getTransacted()");
+ }
getSessionInternal();
return cri.isTransacted();
@@ -296,7 +328,9 @@
public MessageListener getMessageListener() throws JMSException
{
if (trace)
+ {
log.trace("getMessageListener()");
+ }
throw new IllegalStateException("Method not allowed");
}
@@ -306,10 +340,12 @@
* @param listener The message listener
* @exception JMSException Thrown if an error occurs
*/
- public void setMessageListener(MessageListener listener) throws JMSException
+ public void setMessageListener(final MessageListener listener) throws JMSException
{
if (trace)
+ {
log.trace("setMessageListener(" + listener + ")");
+ }
throw new IllegalStateException("Method not allowed");
}
@@ -321,7 +357,9 @@
public void run()
{
if (trace)
+ {
log.trace("run()");
+ }
throw new Error("Method not allowed");
}
@@ -334,7 +372,9 @@
public void close() throws JMSException
{
if (trace)
+ {
log.trace("close()");
+ }
sf.closeSession(this);
closeSession();
@@ -346,8 +386,7 @@
*/
public void commit() throws JMSException
{
- if (cri.getType() == JBMConnectionFactory.XA_CONNECTION ||
- cri.getType() == JBMConnectionFactory.XA_QUEUE_CONNECTION ||
+ if (cri.getType() == JBMConnectionFactory.XA_CONNECTION || cri.getType() == JBMConnectionFactory.XA_QUEUE_CONNECTION ||
cri.getType() == JBMConnectionFactory.XA_TOPIC_CONNECTION)
{
throw new TransactionInProgressException("XA connection");
@@ -359,10 +398,14 @@
Session session = getSessionInternal();
if (cri.isTransacted() == false)
+ {
throw new IllegalStateException("Session is not transacted");
+ }
if (trace)
+ {
log.trace("Commit session " + this);
+ }
session.commit();
}
@@ -378,8 +421,7 @@
*/
public void rollback() throws JMSException
{
- if (cri.getType() == JBMConnectionFactory.XA_CONNECTION ||
- cri.getType() == JBMConnectionFactory.XA_QUEUE_CONNECTION ||
+ if (cri.getType() == JBMConnectionFactory.XA_CONNECTION || cri.getType() == JBMConnectionFactory.XA_QUEUE_CONNECTION ||
cri.getType() == JBMConnectionFactory.XA_TOPIC_CONNECTION)
{
throw new TransactionInProgressException("XA connection");
@@ -391,10 +433,14 @@
Session session = getSessionInternal();
if (cri.isTransacted() == false)
+ {
throw new IllegalStateException("Session is not transacted");
+ }
if (trace)
+ {
log.trace("Rollback session " + this);
+ }
session.rollback();
}
@@ -416,10 +462,14 @@
Session session = getSessionInternal();
if (cri.isTransacted())
+ {
throw new IllegalStateException("Session is transacted");
+ }
if (trace)
+ {
log.trace("Recover session " + this);
+ }
session.recover();
}
@@ -435,22 +485,26 @@
* @return The topic
* @exception JMSException Thrown if an error occurs
*/
- public Topic createTopic(String topicName) throws JMSException
+ public Topic createTopic(final String topicName) throws JMSException
{
if (cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION || cri.getType() == JBMConnectionFactory.XA_QUEUE_CONNECTION)
{
- throw new IllegalStateException("Cannot create topic for javax.jms.QueueSession");
+ throw new IllegalStateException("Cannot create topic for javax.jms.QueueSession");
}
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createTopic " + session + " topicName=" + topicName);
+ }
Topic result = session.createTopic(topicName);
if (trace)
+ {
log.trace("createdTopic " + session + " topic=" + result);
+ }
return result;
}
@@ -461,7 +515,7 @@
* @return The subscriber
* @exception JMSException Thrown if an error occurs
*/
- public TopicSubscriber createSubscriber(Topic topic) throws JMSException
+ public TopicSubscriber createSubscriber(final Topic topic) throws JMSException
{
lock();
try
@@ -469,13 +523,17 @@
TopicSession session = getTopicSessionInternal();
if (trace)
+ {
log.trace("createSubscriber " + session + " topic=" + topic);
+ }
TopicSubscriber result = session.createSubscriber(topic);
result = new JBMTopicSubscriber(result, this);
if (trace)
+ {
log.trace("createdSubscriber " + session + " JBMTopicSubscriber=" + result);
+ }
addConsumer(result);
@@ -495,7 +553,7 @@
* @return The subscriber
* @exception JMSException Thrown if an error occurs
*/
- public TopicSubscriber createSubscriber(Topic topic, String messageSelector, boolean noLocal) throws JMSException
+ public TopicSubscriber createSubscriber(final Topic topic, final String messageSelector, final boolean noLocal) throws JMSException
{
lock();
try
@@ -503,13 +561,23 @@
TopicSession session = getTopicSessionInternal();
if (trace)
- log.trace("createSubscriber " + session + " topic=" + topic + " selector=" + messageSelector + " noLocal=" + noLocal);
+ {
+ log.trace("createSubscriber " + session +
+ " topic=" +
+ topic +
+ " selector=" +
+ messageSelector +
+ " noLocal=" +
+ noLocal);
+ }
TopicSubscriber result = session.createSubscriber(topic, messageSelector, noLocal);
result = new JBMTopicSubscriber(result, this);
if (trace)
+ {
log.trace("createdSubscriber " + session + " JBMTopicSubscriber=" + result);
+ }
addConsumer(result);
@@ -528,26 +596,30 @@
* @return The subscriber
* @exception JMSException Thrown if an error occurs
*/
- public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException
+ public TopicSubscriber createDurableSubscriber(final Topic topic, final String name) throws JMSException
{
if (cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION || cri.getType() == JBMConnectionFactory.XA_QUEUE_CONNECTION)
{
- throw new IllegalStateException("Cannot create durable subscriber from javax.jms.QueueSession");
+ throw new IllegalStateException("Cannot create durable subscriber from javax.jms.QueueSession");
}
-
+
lock();
try
{
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createDurableSubscriber " + session + " topic=" + topic + " name=" + name);
+ }
TopicSubscriber result = session.createDurableSubscriber(topic, name);
result = new JBMTopicSubscriber(result, this);
if (trace)
+ {
log.trace("createdDurableSubscriber " + session + " JBMTopicSubscriber=" + result);
+ }
addConsumer(result);
@@ -568,7 +640,10 @@
* @return The subscriber
* @exception JMSException Thrown if an error occurs
*/
- public TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal) throws JMSException
+ public TopicSubscriber createDurableSubscriber(final Topic topic,
+ final String name,
+ final String messageSelector,
+ final boolean noLocal) throws JMSException
{
lock();
try
@@ -576,13 +651,25 @@
Session session = getSessionInternal();
if (trace)
- log.trace("createDurableSubscriber " + session + " topic=" + topic + " name=" + name + " selector=" + messageSelector + " noLocal=" + noLocal);
+ {
+ log.trace("createDurableSubscriber " + session +
+ " topic=" +
+ topic +
+ " name=" +
+ name +
+ " selector=" +
+ messageSelector +
+ " noLocal=" +
+ noLocal);
+ }
TopicSubscriber result = session.createDurableSubscriber(topic, name, messageSelector, noLocal);
result = new JBMTopicSubscriber(result, this);
if (trace)
+ {
log.trace("createdDurableSubscriber " + session + " JBMTopicSubscriber=" + result);
+ }
addConsumer(result);
@@ -600,7 +687,7 @@
* @return The publisher
* @exception JMSException Thrown if an error occurs
*/
- public TopicPublisher createPublisher(Topic topic) throws JMSException
+ public TopicPublisher createPublisher(final Topic topic) throws JMSException
{
lock();
try
@@ -608,13 +695,17 @@
TopicSession session = getTopicSessionInternal();
if (trace)
+ {
log.trace("createPublisher " + session + " topic=" + topic);
+ }
TopicPublisher result = session.createPublisher(topic);
result = new JBMTopicPublisher(result, this);
if (trace)
+ {
log.trace("createdPublisher " + session + " publisher=" + result);
+ }
addProducer(result);
@@ -635,21 +726,25 @@
{
if (cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION || cri.getType() == JBMConnectionFactory.XA_QUEUE_CONNECTION)
{
- throw new IllegalStateException("Cannot create temporary topic for javax.jms.QueueSession");
+ throw new IllegalStateException("Cannot create temporary topic for javax.jms.QueueSession");
}
-
+
lock();
try
{
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createTemporaryTopic " + session);
+ }
TemporaryTopic temp = session.createTemporaryTopic();
if (trace)
+ {
log.trace("createdTemporaryTopic " + session + " temp=" + temp);
+ }
sf.addTemporaryTopic(temp);
@@ -666,11 +761,11 @@
* @param name The name
* @exception JMSException Thrown if an error occurs
*/
- public void unsubscribe(String name) throws JMSException
+ public void unsubscribe(final String name) throws JMSException
{
if (cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION || cri.getType() == JBMConnectionFactory.XA_QUEUE_CONNECTION)
{
- throw new IllegalStateException("Cannot unsubscribe for javax.jms.QueueSession");
+ throw new IllegalStateException("Cannot unsubscribe for javax.jms.QueueSession");
}
lock();
@@ -679,7 +774,9 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("unsubscribe " + session + " name=" + name);
+ }
session.unsubscribe(name);
}
@@ -695,7 +792,7 @@
* @return The browser
* @exception JMSException Thrown if an error occurs
*/
- public QueueBrowser createBrowser(Queue queue) throws JMSException
+ public QueueBrowser createBrowser(final Queue queue) throws JMSException
{
if (cri.getType() == JBMConnectionFactory.TOPIC_CONNECTION || cri.getType() == JBMConnectionFactory.XA_TOPIC_CONNECTION)
{
@@ -705,12 +802,16 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createBrowser " + session + " queue=" + queue);
+ }
QueueBrowser result = session.createBrowser(queue);
if (trace)
+ {
log.trace("createdBrowser " + session + " browser=" + result);
+ }
return result;
}
@@ -722,7 +823,7 @@
* @return The browser
* @exception JMSException Thrown if an error occurs
*/
- public QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException
+ public QueueBrowser createBrowser(final Queue queue, final String messageSelector) throws JMSException
{
if (cri.getType() == JBMConnectionFactory.TOPIC_CONNECTION || cri.getType() == JBMConnectionFactory.XA_TOPIC_CONNECTION)
{
@@ -732,12 +833,16 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createBrowser " + session + " queue=" + queue + " selector=" + messageSelector);
+ }
QueueBrowser result = session.createBrowser(queue, messageSelector);
if (trace)
+ {
log.trace("createdBrowser " + session + " browser=" + result);
+ }
return result;
}
@@ -748,7 +853,7 @@
* @return The queue
* @exception JMSException Thrown if an error occurs
*/
- public Queue createQueue(String queueName) throws JMSException
+ public Queue createQueue(final String queueName) throws JMSException
{
if (cri.getType() == JBMConnectionFactory.TOPIC_CONNECTION || cri.getType() == JBMConnectionFactory.XA_TOPIC_CONNECTION)
{
@@ -758,12 +863,16 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createQueue " + session + " queueName=" + queueName);
+ }
Queue result = session.createQueue(queueName);
if (trace)
+ {
log.trace("createdQueue " + session + " queue=" + result);
+ }
return result;
}
@@ -774,7 +883,7 @@
* @return The queue receiver
* @exception JMSException Thrown if an error occurs
*/
- public QueueReceiver createReceiver(Queue queue) throws JMSException
+ public QueueReceiver createReceiver(final Queue queue) throws JMSException
{
lock();
try
@@ -782,13 +891,17 @@
QueueSession session = getQueueSessionInternal();
if (trace)
+ {
log.trace("createReceiver " + session + " queue=" + queue);
+ }
QueueReceiver result = session.createReceiver(queue);
result = new JBMQueueReceiver(result, this);
if (trace)
+ {
log.trace("createdReceiver " + session + " receiver=" + result);
+ }
addConsumer(result);
@@ -807,7 +920,7 @@
* @return The queue receiver
* @exception JMSException Thrown if an error occurs
*/
- public QueueReceiver createReceiver(Queue queue, String messageSelector) throws JMSException
+ public QueueReceiver createReceiver(final Queue queue, final String messageSelector) throws JMSException
{
lock();
try
@@ -815,13 +928,17 @@
QueueSession session = getQueueSessionInternal();
if (trace)
+ {
log.trace("createReceiver " + session + " queue=" + queue + " selector=" + messageSelector);
+ }
QueueReceiver result = session.createReceiver(queue, messageSelector);
result = new JBMQueueReceiver(result, this);
if (trace)
+ {
log.trace("createdReceiver " + session + " receiver=" + result);
+ }
addConsumer(result);
@@ -839,7 +956,7 @@
* @return The queue sender
* @exception JMSException Thrown if an error occurs
*/
- public QueueSender createSender(Queue queue) throws JMSException
+ public QueueSender createSender(final Queue queue) throws JMSException
{
lock();
try
@@ -847,13 +964,17 @@
QueueSession session = getQueueSessionInternal();
if (trace)
+ {
log.trace("createSender " + session + " queue=" + queue);
+ }
QueueSender result = session.createSender(queue);
result = new JBMQueueSender(result, this);
if (trace)
+ {
log.trace("createdSender " + session + " sender=" + result);
+ }
addProducer(result);
@@ -883,12 +1004,16 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createTemporaryQueue " + session);
+ }
TemporaryQueue temp = session.createTemporaryQueue();
if (trace)
+ {
log.trace("createdTemporaryQueue " + session + " temp=" + temp);
+ }
sf.addTemporaryQueue(temp);
@@ -906,7 +1031,7 @@
* @return The message consumer
* @exception JMSException Thrown if an error occurs
*/
- public MessageConsumer createConsumer(Destination destination) throws JMSException
+ public MessageConsumer createConsumer(final Destination destination) throws JMSException
{
lock();
try
@@ -914,13 +1039,17 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createConsumer " + session + " dest=" + destination);
+ }
MessageConsumer result = session.createConsumer(destination);
result = new JBMMessageConsumer(result, this);
if (trace)
+ {
log.trace("createdConsumer " + session + " consumer=" + result);
+ }
addConsumer(result);
@@ -939,7 +1068,7 @@
* @return The message consumer
* @exception JMSException Thrown if an error occurs
*/
- public MessageConsumer createConsumer(Destination destination, String messageSelector) throws JMSException
+ public MessageConsumer createConsumer(final Destination destination, final String messageSelector) throws JMSException
{
lock();
try
@@ -947,13 +1076,17 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createConsumer " + session + " dest=" + destination + " messageSelector=" + messageSelector);
+ }
MessageConsumer result = session.createConsumer(destination, messageSelector);
result = new JBMMessageConsumer(result, this);
if (trace)
+ {
log.trace("createdConsumer " + session + " consumer=" + result);
+ }
addConsumer(result);
@@ -973,7 +1106,9 @@
* @return The message consumer
* @exception JMSException Thrown if an error occurs
*/
- public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal) throws JMSException
+ public MessageConsumer createConsumer(final Destination destination,
+ final String messageSelector,
+ final boolean noLocal) throws JMSException
{
lock();
try
@@ -981,13 +1116,23 @@
Session session = getSessionInternal();
if (trace)
- log.trace("createConsumer " + session + " dest=" + destination + " messageSelector=" + messageSelector + " noLocal=" + noLocal);
+ {
+ log.trace("createConsumer " + session +
+ " dest=" +
+ destination +
+ " messageSelector=" +
+ messageSelector +
+ " noLocal=" +
+ noLocal);
+ }
MessageConsumer result = session.createConsumer(destination, messageSelector, noLocal);
result = new JBMMessageConsumer(result, this);
if (trace)
+ {
log.trace("createdConsumer " + session + " consumer=" + result);
+ }
addConsumer(result);
@@ -1005,7 +1150,7 @@
* @return The message producer
* @exception JMSException Thrown if an error occurs
*/
- public MessageProducer createProducer(Destination destination) throws JMSException
+ public MessageProducer createProducer(final Destination destination) throws JMSException
{
lock();
try
@@ -1013,13 +1158,17 @@
Session session = getSessionInternal();
if (trace)
+ {
log.trace("createProducer " + session + " dest=" + destination);
+ }
MessageProducer result = session.createProducer(destination);
result = new JBMMessageProducer(result, this);
if (trace)
+ {
log.trace("createdProducer " + session + " producer=" + result);
+ }
addProducer(result);
@@ -1039,7 +1188,9 @@
public int getAcknowledgeMode() throws JMSException
{
if (trace)
+ {
log.trace("getAcknowledgeMode()");
+ }
getSessionInternal();
return cri.getAcknowledgeMode();
@@ -1053,10 +1204,11 @@
public XAResource getXAResource()
{
if (trace)
+ {
log.trace("getXAResource()");
+ }
- if (cri.getType() == JBMConnectionFactory.CONNECTION ||
- cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION ||
+ if (cri.getType() == JBMConnectionFactory.CONNECTION || cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION ||
cri.getType() == JBMConnectionFactory.TOPIC_CONNECTION)
{
return null;
@@ -1088,10 +1240,11 @@
public Session getSession() throws JMSException
{
if (trace)
+ {
log.trace("getSession()");
+ }
- if (cri.getType() == JBMConnectionFactory.CONNECTION ||
- cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION ||
+ if (cri.getType() == JBMConnectionFactory.CONNECTION || cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION ||
cri.getType() == JBMConnectionFactory.TOPIC_CONNECTION)
{
throw new IllegalStateException("Non XA connection");
@@ -1116,10 +1269,11 @@
public QueueSession getQueueSession() throws JMSException
{
if (trace)
+ {
log.trace("getQueueSession()");
+ }
- if (cri.getType() == JBMConnectionFactory.CONNECTION ||
- cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION ||
+ if (cri.getType() == JBMConnectionFactory.CONNECTION || cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION ||
cri.getType() == JBMConnectionFactory.TOPIC_CONNECTION)
{
throw new IllegalStateException("Non XA connection");
@@ -1144,10 +1298,11 @@
public TopicSession getTopicSession() throws JMSException
{
if (trace)
+ {
log.trace("getTopicSession()");
+ }
- if (cri.getType() == JBMConnectionFactory.CONNECTION ||
- cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION ||
+ if (cri.getType() == JBMConnectionFactory.CONNECTION || cri.getType() == JBMConnectionFactory.QUEUE_CONNECTION ||
cri.getType() == JBMConnectionFactory.TOPIC_CONNECTION)
{
throw new IllegalStateException("Non XA connection");
@@ -1168,15 +1323,19 @@
* Set the managed connection
* @param managedConnection The managed connection
*/
- void setManagedConnection(JBMManagedConnection managedConnection)
+ void setManagedConnection(final JBMManagedConnection managedConnection)
{
if (trace)
+ {
log.trace("setManagedConnection(" + managedConnection + ")");
+ }
if (mc != null)
+ {
mc.removeHandle(this);
+ }
- this.mc = managedConnection;
+ mc = managedConnection;
}
/**
@@ -1185,7 +1344,9 @@
void destroy()
{
if (trace)
+ {
log.trace("destroy()");
+ }
mc = null;
}
@@ -1197,10 +1358,14 @@
void start() throws JMSException
{
if (trace)
+ {
log.trace("start()");
+ }
if (mc != null)
+ {
mc.start();
+ }
}
/**
@@ -1210,10 +1375,14 @@
void stop() throws JMSException
{
if (trace)
+ {
log.trace("stop()");
+ }
if (mc != null)
+ {
mc.stop();
+ }
}
/**
@@ -1223,12 +1392,16 @@
void checkStrict() throws JMSException
{
if (trace)
+ {
log.trace("checkStrict()");
+ }
if (mc != null)
+ {
throw new IllegalStateException(JBMSessionFactory.ISE);
+ }
}
-
+
/**
* Close session
* @exception JMSException Thrown if an error occurs
@@ -1247,12 +1420,12 @@
{
log.trace("Error stopping managed connection", t);
}
-
+
synchronized (consumers)
{
for (Iterator i = consumers.iterator(); i.hasNext();)
{
- JBMMessageConsumer consumer = (JBMMessageConsumer) i.next();
+ JBMMessageConsumer consumer = (JBMMessageConsumer)i.next();
try
{
consumer.closeConsumer();
@@ -1269,7 +1442,7 @@
{
for (Iterator i = producers.iterator(); i.hasNext();)
{
- JBMMessageProducer producer = (JBMMessageProducer) i.next();
+ JBMMessageProducer producer = (JBMMessageProducer)i.next();
try
{
producer.closeProducer();
@@ -1281,7 +1454,7 @@
i.remove();
}
}
-
+
mc.removeHandle(this);
ConnectionEvent ev = new ConnectionEvent(mc, ConnectionEvent.CONNECTION_CLOSED);
ev.setConnectionHandle(this);
@@ -1289,67 +1462,75 @@
mc = null;
}
}
-
+
/**
* Add consumer
* @param consumer The consumer
*/
- void addConsumer(MessageConsumer consumer)
+ void addConsumer(final MessageConsumer consumer)
{
if (trace)
+ {
log.trace("addConsumer(" + consumer + ")");
+ }
synchronized (consumers)
{
consumers.add(consumer);
}
}
-
+
/**
* Remove consumer
* @param consumer The consumer
*/
- void removeConsumer(MessageConsumer consumer)
+ void removeConsumer(final MessageConsumer consumer)
{
if (trace)
+ {
log.trace("removeConsumer(" + consumer + ")");
+ }
synchronized (consumers)
{
consumers.remove(consumer);
}
}
-
+
/**
* Add producer
* @param producer The producer
*/
- void addProducer(MessageProducer producer)
+ void addProducer(final MessageProducer producer)
{
if (trace)
+ {
log.trace("addProducer(" + producer + ")");
+ }
synchronized (producers)
{
producers.add(producer);
}
}
-
+
/**
* Remove producer
* @param producer The producer
*/
- void removeProducer(MessageProducer producer)
+ void removeProducer(final MessageProducer producer)
{
if (trace)
+ {
log.trace("removeProducer(" + producer + ")");
+ }
synchronized (producers)
{
producers.remove(producer);
}
}
-
+
/**
* Get the session and ensure that it is open
* @return The session
@@ -1359,12 +1540,16 @@
Session getSessionInternal() throws JMSException
{
if (mc == null)
+ {
throw new IllegalStateException("The session is closed");
-
+ }
+
Session session = mc.getSession();
if (trace)
+ {
log.trace("getSessionInternal " + session + " for " + this);
+ }
return session;
}
@@ -1378,12 +1563,16 @@
XASession getXASessionInternal() throws JMSException
{
if (mc == null)
+ {
throw new IllegalStateException("The session is closed");
-
+ }
+
XASession session = mc.getXASession();
if (trace)
+ {
log.trace("getXASessionInternal " + session + " for " + this);
+ }
return session;
}
@@ -1397,11 +1586,13 @@
QueueSession getQueueSessionInternal() throws JMSException
{
Session s = getSessionInternal();
- if( !(s instanceof QueueSession) )
+ if (!(s instanceof QueueSession))
+ {
throw new InvalidDestinationException("Attempting to use QueueSession methods on: " + this);
- return (QueueSession) s;
+ }
+ return (QueueSession)s;
}
-
+
/**
* Get the topic session
* @return The topic session
@@ -1411,8 +1602,10 @@
TopicSession getTopicSessionInternal() throws JMSException
{
Session s = getSessionInternal();
- if( !(s instanceof TopicSession) )
+ if (!(s instanceof TopicSession))
+ {
throw new InvalidDestinationException("Attempting to use TopicSession methods on: " + this);
- return (TopicSession) s;
+ }
+ return (TopicSession)s;
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMSessionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMSessionFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMSessionFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -38,7 +38,8 @@
* @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
* @version $Revision: 71554 $
*/
-public interface JBMSessionFactory extends Connection, TopicConnection, QueueConnection, XAConnection, XATopicConnection, XAQueueConnection
+public interface JBMSessionFactory extends Connection, TopicConnection, QueueConnection, XAConnection,
+ XATopicConnection, XAQueueConnection
{
/** Error message for strict behaviour */
String ISE = "This method is not applicable inside the application server. See the J2EE spec, e.g. J2EE1.4 Section 6.6";
@@ -54,7 +55,7 @@
* @param temp The temporary topic
*/
void addTemporaryTopic(TemporaryTopic temp);
-
+
/**
* Notification that a session is closed
* @param session The session
Modified: trunk/src/main/org/jboss/messaging/ra/JBMSessionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMSessionFactoryImpl.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMSessionFactoryImpl.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -59,7 +59,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMSessionFactoryImpl.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
@@ -79,59 +79,67 @@
private String clientID;
/** The connection type */
- private int type;
+ private final int type;
/** Whether we are started */
private boolean started = false;
-
+
/** The managed connection factory */
- private JBMManagedConnectionFactory mcf;
+ private final JBMManagedConnectionFactory mcf;
/** The connection manager */
private ConnectionManager cm;
/** The sessions */
- private Set sessions = new HashSet();
+ private final Set sessions = new HashSet();
/** The temporary queues */
- private Set tempQueues = new HashSet();
+ private final Set tempQueues = new HashSet();
/** The temporary topics */
- private Set tempTopics = new HashSet();
-
+ private final Set tempTopics = new HashSet();
+
/**
* Constructor
* @param mcf The managed connection factory
* @param cm The connection manager
* @param type The connection type
*/
- public JBMSessionFactoryImpl(JBMManagedConnectionFactory mcf, ConnectionManager cm, int type)
+ public JBMSessionFactoryImpl(final JBMManagedConnectionFactory mcf, final ConnectionManager cm, final int type)
{
this.mcf = mcf;
if (cm == null)
+ {
this.cm = new JBMConnectionManager();
- else
+ }
+ else
+ {
this.cm = cm;
+ }
this.type = type;
if (trace)
+ {
log.trace("constructor(" + mcf + ", " + cm + ", " + type);
+ }
}
/**
* Set the naming reference
* @param reference The reference
*/
- public void setReference(Reference reference)
+ public void setReference(final Reference reference)
{
if (trace)
+ {
log.trace("setReference(" + reference + ")");
+ }
this.reference = reference;
}
-
+
/**
* Get the naming reference
* @return The reference
@@ -139,31 +147,37 @@
public Reference getReference()
{
if (trace)
+ {
log.trace("getReference()");
+ }
return reference;
}
-
+
/**
* Set the user name
* @param name The user name
*/
- public void setUserName(String name)
+ public void setUserName(final String name)
{
if (trace)
+ {
log.trace("setUserName(" + name + ")");
+ }
- this.userName = name;
+ userName = name;
}
-
+
/**
* Set the password
* @param password The password
*/
- public void setPassword(String password)
+ public void setPassword(final String password)
{
if (trace)
+ {
log.trace("setPassword(****)");
+ }
this.password = password;
}
@@ -176,29 +190,35 @@
public String getClientID() throws JMSException
{
if (trace)
+ {
log.trace("getClientID()");
+ }
checkClosed();
if (clientID == null)
+ {
return ((JBMResourceAdapter)mcf.getResourceAdapter()).getProperties().getClientID();
+ }
return clientID;
}
-
+
/**
* Set the client ID -- throws IllegalStateException
* @param cID The client ID
* @exception JMSException Thrown if an error occurs
*/
- public void setClientID(String cID) throws JMSException
+ public void setClientID(final String cID) throws JMSException
{
if (trace)
+ {
log.trace("setClientID(" + cID + ")");
+ }
throw new IllegalStateException(ISE);
}
-
+
/**
* Create a queue session
* @param transacted Use transactions
@@ -206,33 +226,42 @@
* @return The queue session
* @exception JMSException Thrown if an error occurs
*/
- public QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws JMSException
+ public QueueSession createQueueSession(final boolean transacted, final int acknowledgeMode) throws JMSException
{
if (trace)
+ {
log.trace("createQueueSession(" + transacted + ", " + acknowledgeMode + ")");
+ }
checkClosed();
if (type == JBMConnectionFactory.TOPIC_CONNECTION || type == JBMConnectionFactory.XA_TOPIC_CONNECTION)
+ {
throw new IllegalStateException("Can not get a queue session from a topic connection");
+ }
return allocateConnection(transacted, acknowledgeMode, type);
}
-
+
/**
* Create a XA queue session
* @return The XA queue session
* @exception JMSException Thrown if an error occurs
*/
public XAQueueSession createXAQueueSession() throws JMSException
- {
+ {
if (trace)
+ {
log.trace("createXAQueueSession()");
+ }
checkClosed();
- if (type == JBMConnectionFactory.CONNECTION || type == JBMConnectionFactory.TOPIC_CONNECTION || type == JBMConnectionFactory.XA_TOPIC_CONNECTION)
+ if (type == JBMConnectionFactory.CONNECTION || type == JBMConnectionFactory.TOPIC_CONNECTION ||
+ type == JBMConnectionFactory.XA_TOPIC_CONNECTION)
+ {
throw new IllegalStateException("Can not get a topic session from a queue connection");
+ }
return allocateConnection(type);
}
@@ -246,14 +275,26 @@
* @return The connection consumer
* @exception JMSException Thrown if an error occurs
*/
- public ConnectionConsumer createConnectionConsumer(Queue queue, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
+ public ConnectionConsumer createConnectionConsumer(final Queue queue,
+ final String messageSelector,
+ final ServerSessionPool sessionPool,
+ final int maxMessages) throws JMSException
{
if (trace)
- log.trace("createConnectionConsumer(" + queue + ", " + messageSelector + ", " + sessionPool + ", " + maxMessages + ")");
+ {
+ log.trace("createConnectionConsumer(" + queue +
+ ", " +
+ messageSelector +
+ ", " +
+ sessionPool +
+ ", " +
+ maxMessages +
+ ")");
+ }
throw new IllegalStateException(ISE);
}
-
+
/**
* Create a topic session
* @param transacted Use transactions
@@ -261,15 +302,19 @@
* @return The topic session
* @exception JMSException Thrown if an error occurs
*/
- public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException
- {
+ public TopicSession createTopicSession(final boolean transacted, final int acknowledgeMode) throws JMSException
+ {
if (trace)
+ {
log.trace("createTopicSession(" + transacted + ", " + acknowledgeMode + ")");
+ }
checkClosed();
if (type == JBMConnectionFactory.QUEUE_CONNECTION || type == JBMConnectionFactory.XA_QUEUE_CONNECTION)
+ {
throw new IllegalStateException("Can not get a topic session from a queue connection");
+ }
return allocateConnection(transacted, acknowledgeMode, type);
}
@@ -280,14 +325,19 @@
* @exception JMSException Thrown if an error occurs
*/
public XATopicSession createXATopicSession() throws JMSException
- {
+ {
if (trace)
+ {
log.trace("createXATopicSession()");
+ }
checkClosed();
- if (type == JBMConnectionFactory.CONNECTION || type == JBMConnectionFactory.QUEUE_CONNECTION || type == JBMConnectionFactory.XA_QUEUE_CONNECTION)
+ if (type == JBMConnectionFactory.CONNECTION || type == JBMConnectionFactory.QUEUE_CONNECTION ||
+ type == JBMConnectionFactory.XA_QUEUE_CONNECTION)
+ {
throw new IllegalStateException("Can not get a topic session from a queue connection");
+ }
return allocateConnection(type);
}
@@ -301,13 +351,25 @@
* @return The connection consumer
* @exception JMSException Thrown if an error occurs
*/
- public ConnectionConsumer createConnectionConsumer(Topic topic, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
+ public ConnectionConsumer createConnectionConsumer(final Topic topic,
+ final String messageSelector,
+ final ServerSessionPool sessionPool,
+ final int maxMessages) throws JMSException
{
if (trace)
- log.trace("createConnectionConsumer(" + topic + ", " + messageSelector + ", " + sessionPool + ", " + maxMessages + ")");
+ {
+ log.trace("createConnectionConsumer(" + topic +
+ ", " +
+ messageSelector +
+ ", " +
+ sessionPool +
+ ", " +
+ maxMessages +
+ ")");
+ }
throw new IllegalStateException(ISE);
- }
+ }
/**
* Create a durable connection consumer -- throws IllegalStateException
@@ -319,10 +381,25 @@
* @return The connection consumer
* @exception JMSException Thrown if an error occurs
*/
- public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
+ public ConnectionConsumer createDurableConnectionConsumer(final Topic topic,
+ final String subscriptionName,
+ final String messageSelector,
+ final ServerSessionPool sessionPool,
+ final int maxMessages) throws JMSException
{
if (trace)
- log.trace("createConnectionConsumer(" + topic + ", " + subscriptionName + ", " + messageSelector + ", " + sessionPool + ", " + maxMessages + ")");
+ {
+ log.trace("createConnectionConsumer(" + topic +
+ ", " +
+ subscriptionName +
+ ", " +
+ messageSelector +
+ ", " +
+ sessionPool +
+ ", " +
+ maxMessages +
+ ")");
+ }
throw new IllegalStateException(ISE);
}
@@ -335,10 +412,14 @@
* @return The connection consumer
* @exception JMSException Thrown if an error occurs
*/
- public ConnectionConsumer createConnectionConsumer(Destination destination, ServerSessionPool pool, int maxMessages) throws JMSException
+ public ConnectionConsumer createConnectionConsumer(final Destination destination,
+ final ServerSessionPool pool,
+ final int maxMessages) throws JMSException
{
if (trace)
+ {
log.trace("createConnectionConsumer(" + destination + ", " + pool + ", " + maxMessages + ")");
+ }
throw new IllegalStateException(ISE);
}
@@ -352,10 +433,15 @@
* @return The connection consumer
* @exception JMSException Thrown if an error occurs
*/
- public ConnectionConsumer createConnectionConsumer(Destination destination, String name, ServerSessionPool pool, int maxMessages) throws JMSException
+ public ConnectionConsumer createConnectionConsumer(final Destination destination,
+ final String name,
+ final ServerSessionPool pool,
+ final int maxMessages) throws JMSException
{
if (trace)
+ {
log.trace("createConnectionConsumer(" + destination + ", " + name + ", " + pool + ", " + maxMessages + ")");
+ }
throw new IllegalStateException(ISE);
}
@@ -367,10 +453,12 @@
* @return The session
* @exception JMSException Thrown if an error occurs
*/
- public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
+ public Session createSession(final boolean transacted, final int acknowledgeMode) throws JMSException
{
if (trace)
+ {
log.trace("createSession(" + transacted + ", " + acknowledgeMode + ")");
+ }
checkClosed();
return allocateConnection(transacted, acknowledgeMode, type);
@@ -384,7 +472,9 @@
public XASession createXASession() throws JMSException
{
if (trace)
+ {
log.trace("createXASession()");
+ }
checkClosed();
return allocateConnection(type);
@@ -398,12 +488,14 @@
public ConnectionMetaData getMetaData() throws JMSException
{
if (trace)
+ {
log.trace("getMetaData()");
+ }
checkClosed();
return mcf.getMetaData();
}
-
+
/**
* Get the exception listener -- throws IllegalStateException
* @return The exception listener
@@ -412,20 +504,24 @@
public ExceptionListener getExceptionListener() throws JMSException
{
if (trace)
+ {
log.trace("getExceptionListener()");
+ }
throw new IllegalStateException(ISE);
}
-
+
/**
* Set the exception listener -- throws IllegalStateException
* @param listener The exception listener
* @exception JMSException Thrown if an error occurs
*/
- public void setExceptionListener(ExceptionListener listener) throws JMSException
+ public void setExceptionListener(final ExceptionListener listener) throws JMSException
{
if (trace)
+ {
log.trace("setExceptionListener(" + listener + ")");
+ }
throw new IllegalStateException(ISE);
}
@@ -439,21 +535,25 @@
checkClosed();
if (trace)
+ {
log.trace("start() " + this);
+ }
synchronized (sessions)
{
if (started)
+ {
return;
+ }
started = true;
for (Iterator i = sessions.iterator(); i.hasNext();)
{
- JBMSession session = (JBMSession) i.next();
+ JBMSession session = (JBMSession)i.next();
session.start();
}
}
}
-
+
/**
* Stop -- throws IllegalStateException
* @exception JMSException Thrown if an error occurs
@@ -461,7 +561,9 @@
public void stop() throws JMSException
{
if (trace)
+ {
log.trace("stop() " + this);
+ }
throw new IllegalStateException(ISE);
}
@@ -473,10 +575,14 @@
public void close() throws JMSException
{
if (trace)
+ {
log.trace("close() " + this);
-
+ }
+
if (closed)
+ {
return;
+ }
closed = true;
@@ -484,7 +590,7 @@
{
for (Iterator i = sessions.iterator(); i.hasNext();)
{
- JBMSession session = (JBMSession) i.next();
+ JBMSession session = (JBMSession)i.next();
try
{
session.closeSession();
@@ -496,16 +602,18 @@
i.remove();
}
}
-
+
synchronized (tempQueues)
{
for (Iterator i = tempQueues.iterator(); i.hasNext();)
{
- TemporaryQueue temp = (TemporaryQueue) i.next();
+ TemporaryQueue temp = (TemporaryQueue)i.next();
try
{
if (trace)
+ {
log.trace("Closing temporary queue " + temp + " for " + this);
+ }
temp.delete();
}
catch (Throwable t)
@@ -515,16 +623,18 @@
i.remove();
}
}
-
+
synchronized (tempTopics)
{
for (Iterator i = tempTopics.iterator(); i.hasNext();)
{
- TemporaryTopic temp = (TemporaryTopic) i.next();
+ TemporaryTopic temp = (TemporaryTopic)i.next();
try
{
if (trace)
+ {
log.trace("Closing temporary topic " + temp + " for " + this);
+ }
temp.delete();
}
catch (Throwable t)
@@ -541,42 +651,48 @@
* @param session The session
* @exception JMSException Thrown if an error occurs
*/
- public void closeSession(JBMSession session) throws JMSException
+ public void closeSession(final JBMSession session) throws JMSException
{
if (trace)
+ {
log.trace("closeSession(" + session + ")");
-
+ }
+
synchronized (sessions)
{
sessions.remove(session);
}
}
-
+
/**
* Add temporary queue
* @param temp The temporary queue
*/
- public void addTemporaryQueue(TemporaryQueue temp)
+ public void addTemporaryQueue(final TemporaryQueue temp)
{
if (trace)
+ {
log.trace("addTemporaryQueue(" + temp + ")");
-
- synchronized(tempQueues)
+ }
+
+ synchronized (tempQueues)
{
tempQueues.add(temp);
}
}
-
+
/**
* Add temporary topic
* @param temp The temporary topic
*/
- public void addTemporaryTopic(TemporaryTopic temp)
+ public void addTemporaryTopic(final TemporaryTopic temp)
{
if (trace)
+ {
log.trace("addTemporaryTopic(" + temp + ")");
-
- synchronized(tempTopics)
+ }
+
+ synchronized (tempTopics)
{
tempTopics.add(temp);
}
@@ -588,17 +704,21 @@
* @return The session
* @exception JMSException Thrown if an error occurs
*/
- protected JBMSession allocateConnection(int sessionType) throws JMSException
+ protected JBMSession allocateConnection(final int sessionType) throws JMSException
{
if (trace)
+ {
log.trace("allocateConnection(" + sessionType + ")");
+ }
try
{
synchronized (sessions)
{
if (sessions.isEmpty() == false)
+ {
throw new IllegalStateException("Only allowed one session per connection. See the J2EE spec, e.g. J2EE1.4 Section 6.6");
+ }
JBMConnectionRequestInfo info = new JBMConnectionRequestInfo(sessionType);
info.setUserName(userName);
@@ -607,19 +727,25 @@
info.setDefaults(((JBMResourceAdapter)mcf.getResourceAdapter()).getProperties());
if (trace)
+ {
log.trace("Allocating session for " + this + " with request info=" + info);
+ }
- JBMSession session = (JBMSession) cm.allocateConnection(mcf, info);
+ JBMSession session = (JBMSession)cm.allocateConnection(mcf, info);
try
{
if (trace)
+ {
log.trace("Allocated " + this + " session=" + session);
+ }
session.setJBMSessionFactory(this);
if (started)
+ {
session.start();
+ }
sessions.add(session);
@@ -635,16 +761,20 @@
{
}
if (t instanceof Exception)
- throw (Exception) t;
+ {
+ throw (Exception)t;
+ }
else
+ {
throw new RuntimeException("Unexpected error: ", t);
+ }
}
}
}
catch (Exception e)
{
log.error("Could not create session", e);
-
+
JMSException je = new JMSException("Could not create a session: " + e.getMessage());
je.setLinkedException(e);
throw je;
@@ -659,20 +789,26 @@
* @return The session
* @exception JMSException Thrown if an error occurs
*/
- protected JBMSession allocateConnection(boolean transacted, int acknowledgeMode, int sessionType) throws JMSException
+ protected JBMSession allocateConnection(final boolean transacted, int acknowledgeMode, final int sessionType) throws JMSException
{
if (trace)
+ {
log.trace("allocateConnection(" + transacted + ", " + acknowledgeMode + ", " + sessionType + ")");
+ }
try
{
synchronized (sessions)
{
if (sessions.isEmpty() == false)
+ {
throw new IllegalStateException("Only allowed one session per connection. See the J2EE spec, e.g. J2EE1.4 Section 6.6");
+ }
if (transacted)
+ {
acknowledgeMode = Session.SESSION_TRANSACTED;
+ }
JBMConnectionRequestInfo info = new JBMConnectionRequestInfo(transacted, acknowledgeMode, sessionType);
info.setUserName(userName);
@@ -680,19 +816,25 @@
info.setClientID(clientID);
if (trace)
+ {
log.trace("Allocating session for " + this + " with request info=" + info);
+ }
- JBMSession session = (JBMSession) cm.allocateConnection(mcf, info);
+ JBMSession session = (JBMSession)cm.allocateConnection(mcf, info);
try
{
if (trace)
+ {
log.trace("Allocated " + this + " session=" + session);
+ }
session.setJBMSessionFactory(this);
if (started)
+ {
session.start();
+ }
sessions.add(session);
@@ -708,16 +850,20 @@
{
}
if (t instanceof Exception)
- throw (Exception) t;
+ {
+ throw (Exception)t;
+ }
else
+ {
throw new RuntimeException("Unexpected error: ", t);
+ }
}
}
}
catch (Exception e)
{
log.error("Could not create session", e);
-
+
JMSException je = new JMSException("Could not create a session: " + e.getMessage());
je.setLinkedException(e);
throw je;
@@ -731,9 +877,13 @@
protected void checkClosed() throws IllegalStateException
{
if (trace)
+ {
log.trace("checkClosed()" + this);
+ }
if (closed)
+ {
throw new IllegalStateException("The connection is closed");
+ }
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMStreamMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMStreamMessage.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMStreamMessage.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -37,7 +37,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMStreamMessage.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
@@ -46,14 +46,16 @@
* @param message the message
* @param session the session
*/
- public JBMStreamMessage(StreamMessage message, JBMSession session)
+ public JBMStreamMessage(final StreamMessage message, final JBMSession session)
{
super(message, session);
if (trace)
+ {
log.trace("constructor(" + message + ", " + session + ")");
+ }
}
-
+
/**
* Read
* @return The value
@@ -62,11 +64,13 @@
public boolean readBoolean() throws JMSException
{
if (trace)
+ {
log.trace("readBoolean()");
+ }
- return ((StreamMessage) message).readBoolean();
+ return ((StreamMessage)message).readBoolean();
}
-
+
/**
* Read
* @return The value
@@ -75,25 +79,29 @@
public byte readByte() throws JMSException
{
if (trace)
+ {
log.trace("readByte()");
+ }
- return ((StreamMessage) message).readByte();
+ return ((StreamMessage)message).readByte();
}
-
+
/**
* Read
* @param value The value
* @return The value
* @exception JMSException Thrown if an error occurs
*/
- public int readBytes(byte[] value) throws JMSException
+ public int readBytes(final byte[] value) throws JMSException
{
if (trace)
+ {
log.trace("readBytes(" + value + ")");
+ }
- return ((StreamMessage) message).readBytes(value);
+ return ((StreamMessage)message).readBytes(value);
}
-
+
/**
* Read
* @return The value
@@ -102,11 +110,13 @@
public char readChar() throws JMSException
{
if (trace)
+ {
log.trace("readChar()");
+ }
- return ((StreamMessage) message).readChar();
+ return ((StreamMessage)message).readChar();
}
-
+
/**
* Read
* @return The value
@@ -115,11 +125,13 @@
public double readDouble() throws JMSException
{
if (trace)
+ {
log.trace("readDouble()");
+ }
- return ((StreamMessage) message).readDouble();
+ return ((StreamMessage)message).readDouble();
}
-
+
/**
* Read
* @return The value
@@ -128,11 +140,13 @@
public float readFloat() throws JMSException
{
if (trace)
+ {
log.trace("readFloat()");
+ }
- return ((StreamMessage) message).readFloat();
+ return ((StreamMessage)message).readFloat();
}
-
+
/**
* Read
* @return The value
@@ -141,11 +155,13 @@
public int readInt() throws JMSException
{
if (trace)
+ {
log.trace("readInt()");
+ }
- return ((StreamMessage) message).readInt();
+ return ((StreamMessage)message).readInt();
}
-
+
/**
* Read
* @return The value
@@ -154,11 +170,13 @@
public long readLong() throws JMSException
{
if (trace)
+ {
log.trace("readLong()");
+ }
- return ((StreamMessage) message).readLong();
+ return ((StreamMessage)message).readLong();
}
-
+
/**
* Read
* @return The value
@@ -167,11 +185,13 @@
public Object readObject() throws JMSException
{
if (trace)
+ {
log.trace("readObject()");
+ }
- return ((StreamMessage) message).readObject();
+ return ((StreamMessage)message).readObject();
}
-
+
/**
* Read
* @return The value
@@ -180,11 +200,13 @@
public short readShort() throws JMSException
{
if (trace)
+ {
log.trace("readShort()");
+ }
- return ((StreamMessage) message).readShort();
+ return ((StreamMessage)message).readShort();
}
-
+
/**
* Read
* @return The value
@@ -193,11 +215,13 @@
public String readString() throws JMSException
{
if (trace)
+ {
log.trace("readString()");
+ }
- return ((StreamMessage) message).readString();
+ return ((StreamMessage)message).readString();
}
-
+
/**
* Reset
* @exception JMSException Thrown if an error occurs
@@ -205,37 +229,43 @@
public void reset() throws JMSException
{
if (trace)
+ {
log.trace("reset()");
+ }
- ((StreamMessage) message).reset();
+ ((StreamMessage)message).reset();
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeBoolean(boolean value) throws JMSException
+ public void writeBoolean(final boolean value) throws JMSException
{
if (trace)
+ {
log.trace("writeBoolean(" + value + ")");
+ }
- ((StreamMessage) message).writeBoolean(value);
+ ((StreamMessage)message).writeBoolean(value);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeByte(byte value) throws JMSException
+ public void writeByte(final byte value) throws JMSException
{
if (trace)
+ {
log.trace("writeByte(" + value + ")");
+ }
- ((StreamMessage) message).writeByte(value);
+ ((StreamMessage)message).writeByte(value);
}
-
+
/**
* Write
* @param value The value
@@ -243,51 +273,59 @@
* @param length The length
* @exception JMSException Thrown if an error occurs
*/
- public void writeBytes(byte[] value, int offset, int length) throws JMSException
+ public void writeBytes(final byte[] value, final int offset, final int length) throws JMSException
{
if (trace)
+ {
log.trace("writeBytes(" + value + ", " + offset + ", " + length + ")");
+ }
- ((StreamMessage) message).writeBytes(value, offset, length);
+ ((StreamMessage)message).writeBytes(value, offset, length);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeBytes(byte[] value) throws JMSException
+ public void writeBytes(final byte[] value) throws JMSException
{
if (trace)
+ {
log.trace("writeBytes(" + value + ")");
+ }
- ((StreamMessage) message).writeBytes(value);
+ ((StreamMessage)message).writeBytes(value);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeChar(char value) throws JMSException
+ public void writeChar(final char value) throws JMSException
{
if (trace)
+ {
log.trace("writeChar(" + value + ")");
+ }
- ((StreamMessage) message).writeChar(value);
+ ((StreamMessage)message).writeChar(value);
}
-
+
/**
* Write
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeDouble(double value) throws JMSException
+ public void writeDouble(final double value) throws JMSException
{
if (trace)
+ {
log.trace("writeDouble(" + value + ")");
+ }
- ((StreamMessage) message).writeDouble(value);
+ ((StreamMessage)message).writeDouble(value);
}
/**
@@ -295,12 +333,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeFloat(float value) throws JMSException
+ public void writeFloat(final float value) throws JMSException
{
if (trace)
+ {
log.trace("writeFloat(" + value + ")");
+ }
- ((StreamMessage) message).writeFloat(value);
+ ((StreamMessage)message).writeFloat(value);
}
/**
@@ -308,12 +348,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeInt(int value) throws JMSException
+ public void writeInt(final int value) throws JMSException
{
if (trace)
+ {
log.trace("writeInt(" + value + ")");
+ }
- ((StreamMessage) message).writeInt(value);
+ ((StreamMessage)message).writeInt(value);
}
/**
@@ -321,12 +363,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeLong(long value) throws JMSException
+ public void writeLong(final long value) throws JMSException
{
if (trace)
+ {
log.trace("writeLong(" + value + ")");
+ }
- ((StreamMessage) message).writeLong(value);
+ ((StreamMessage)message).writeLong(value);
}
/**
@@ -334,12 +378,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeObject(Object value) throws JMSException
+ public void writeObject(final Object value) throws JMSException
{
if (trace)
+ {
log.trace("writeObject(" + value + ")");
+ }
- ((StreamMessage) message).writeObject(value);
+ ((StreamMessage)message).writeObject(value);
}
/**
@@ -347,12 +393,14 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeShort(short value) throws JMSException
+ public void writeShort(final short value) throws JMSException
{
if (trace)
+ {
log.trace("writeShort(" + value + ")");
+ }
- ((StreamMessage) message).writeShort(value);
+ ((StreamMessage)message).writeShort(value);
}
/**
@@ -360,11 +408,13 @@
* @param value The value
* @exception JMSException Thrown if an error occurs
*/
- public void writeString(String value) throws JMSException
+ public void writeString(final String value) throws JMSException
{
if (trace)
+ {
log.trace("writeString(" + value + ")");
+ }
- ((StreamMessage) message).writeString(value);
+ ((StreamMessage)message).writeString(value);
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMTextMessage.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMTextMessage.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMTextMessage.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -37,7 +37,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMTextMessage.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
@@ -46,12 +46,14 @@
* @param message the message
* @param session the session
*/
- public JBMTextMessage(TextMessage message, JBMSession session)
+ public JBMTextMessage(final TextMessage message, final JBMSession session)
{
super(message, session);
if (trace)
+ {
log.trace("constructor(" + message + ", " + session + ")");
+ }
}
/**
@@ -62,21 +64,25 @@
public String getText() throws JMSException
{
if (trace)
+ {
log.trace("getText()");
+ }
- return ((TextMessage) message).getText();
+ return ((TextMessage)message).getText();
}
-
+
/**
* Set text
* @param string The text
* @exception JMSException Thrown if an error occurs
*/
- public void setText(String string) throws JMSException
+ public void setText(final String string) throws JMSException
{
if (trace)
+ {
log.trace("setText(" + string + ")");
+ }
- ((TextMessage) message).setText(string);
+ ((TextMessage)message).setText(string);
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMTopicPublisher.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMTopicPublisher.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMTopicPublisher.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -39,7 +39,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMTopicPublisher.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
@@ -48,12 +48,14 @@
* @param producer the producer
* @param session the session
*/
- public JBMTopicPublisher(TopicPublisher producer, JBMSession session)
+ public JBMTopicPublisher(final TopicPublisher producer, final JBMSession session)
{
super(producer, session);
if (trace)
+ {
log.trace("constructor(" + producer + ", " + session + ")");
+ }
}
/**
@@ -64,9 +66,11 @@
public Topic getTopic() throws JMSException
{
if (trace)
+ {
log.trace("getTopic()");
+ }
- return ((TopicPublisher) producer).getTopic();
+ return ((TopicPublisher)producer).getTopic();
}
/**
@@ -77,20 +81,32 @@
* @param timeToLive The time to live
* @exception JMSException Thrown if an error occurs
*/
- public void publish(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
+ public void publish(final Message message, final int deliveryMode, final int priority, final long timeToLive) throws JMSException
{
session.lock();
try
{
if (trace)
- log.trace("send " + this + " message=" + message + " deliveryMode=" + deliveryMode + " priority=" + priority + " ttl=" + timeToLive);
+ {
+ log.trace("send " + this +
+ " message=" +
+ message +
+ " deliveryMode=" +
+ deliveryMode +
+ " priority=" +
+ priority +
+ " ttl=" +
+ timeToLive);
+ }
checkState();
- ((TopicPublisher) producer).publish(message, deliveryMode, priority, timeToLive);
+ ((TopicPublisher)producer).publish(message, deliveryMode, priority, timeToLive);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
@@ -103,20 +119,24 @@
* @param message The message
* @exception JMSException Thrown if an error occurs
*/
- public void publish(Message message) throws JMSException
+ public void publish(final Message message) throws JMSException
{
session.lock();
try
{
if (trace)
+ {
log.trace("send " + this + " message=" + message);
+ }
checkState();
- ((TopicPublisher) producer).publish(message);
+ ((TopicPublisher)producer).publish(message);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
@@ -133,20 +153,38 @@
* @param timeToLive The time to live
* @exception JMSException Thrown if an error occurs
*/
- public void publish(Topic destination, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException
+ public void publish(final Topic destination,
+ final Message message,
+ final int deliveryMode,
+ final int priority,
+ final long timeToLive) throws JMSException
{
session.lock();
try
{
if (trace)
- log.trace("send " + this + " destination=" + destination + " message=" + message + " deliveryMode=" + deliveryMode + " priority=" + priority + " ttl=" + timeToLive);
+ {
+ log.trace("send " + this +
+ " destination=" +
+ destination +
+ " message=" +
+ message +
+ " deliveryMode=" +
+ deliveryMode +
+ " priority=" +
+ priority +
+ " ttl=" +
+ timeToLive);
+ }
checkState();
- ((TopicPublisher) producer).publish(destination, message, deliveryMode, priority, timeToLive);
+ ((TopicPublisher)producer).publish(destination, message, deliveryMode, priority, timeToLive);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
@@ -160,20 +198,24 @@
* @param message The message
* @exception JMSException Thrown if an error occurs
*/
- public void publish(Topic destination, Message message) throws JMSException
+ public void publish(final Topic destination, final Message message) throws JMSException
{
session.lock();
try
{
if (trace)
+ {
log.trace("send " + this + " destination=" + destination + " message=" + message);
+ }
checkState();
- ((TopicPublisher) producer).publish(destination, message);
+ ((TopicPublisher)producer).publish(destination, message);
if (trace)
+ {
log.trace("sent " + this + " result=" + message);
+ }
}
finally
{
Modified: trunk/src/main/org/jboss/messaging/ra/JBMTopicSubscriber.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMTopicSubscriber.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMTopicSubscriber.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -38,7 +38,7 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMTopicSubscriber.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
@@ -47,12 +47,14 @@
* @param consumer the topic subscriber
* @param session the session
*/
- public JBMTopicSubscriber(TopicSubscriber consumer, JBMSession session)
+ public JBMTopicSubscriber(final TopicSubscriber consumer, final JBMSession session)
{
super(consumer, session);
if (trace)
+ {
log.trace("constructor(" + consumer + ", " + session + ")");
+ }
}
/**
@@ -63,10 +65,12 @@
public boolean getNoLocal() throws JMSException
{
if (trace)
+ {
log.trace("getNoLocal()");
+ }
checkState();
- return ((TopicSubscriber) consumer).getNoLocal();
+ return ((TopicSubscriber)consumer).getNoLocal();
}
/**
@@ -77,9 +81,11 @@
public Topic getTopic() throws JMSException
{
if (trace)
+ {
log.trace("getTopic()");
+ }
checkState();
- return ((TopicSubscriber) consumer).getTopic();
+ return ((TopicSubscriber)consumer).getTopic();
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/JBMXAResource.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/JBMXAResource.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/JBMXAResource.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -38,25 +38,27 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMXAResource.class);
-
+
/** Trace enabled */
private static boolean trace = log.isTraceEnabled();
/** The managed connection */
- private JBMManagedConnection managedConnection;
-
+ private final JBMManagedConnection managedConnection;
+
/** The resource */
- private XAResource xaResource;
+ private final XAResource xaResource;
/**
* Create a new JBMXAResource.
* @param managedConnection the managed connection
* @param xaResource the xa resource
*/
- public JBMXAResource(JBMManagedConnection managedConnection, XAResource xaResource)
+ public JBMXAResource(final JBMManagedConnection managedConnection, final XAResource xaResource)
{
if (trace)
+ {
log.trace("constructor(" + managedConnection + ", " + xaResource + ")");
+ }
this.managedConnection = managedConnection;
this.xaResource = xaResource;
@@ -68,10 +70,12 @@
* @param flags One of TMNOFLAGS, TMJOIN, or TMRESUME
* @exception XAException An error has occurred
*/
- public void start(Xid xid, int flags) throws XAException
+ public void start(final Xid xid, final int flags) throws XAException
{
if (trace)
+ {
log.trace("start(" + xid + ", " + flags + ")");
+ }
managedConnection.lock();
try
@@ -90,10 +94,12 @@
* @param flags One of TMSUCCESS, TMFAIL, or TMSUSPEND.
* @exception XAException An error has occurred
*/
- public void end(Xid xid, int flags) throws XAException
+ public void end(final Xid xid, final int flags) throws XAException
{
if (trace)
+ {
log.trace("end(" + xid + ", " + flags + ")");
+ }
managedConnection.lock();
try
@@ -112,10 +118,12 @@
* @return XA_RDONLY or XA_OK
* @exception XAException An error has occurred
*/
- public int prepare(Xid xid) throws XAException
+ public int prepare(final Xid xid) throws XAException
{
if (trace)
+ {
log.trace("prepare(" + xid + ")");
+ }
return xaResource.prepare(xid);
}
@@ -126,10 +134,12 @@
* @param onePhase If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of xid.
* @exception XAException An error has occurred
*/
- public void commit(Xid xid, boolean onePhase) throws XAException
+ public void commit(final Xid xid, final boolean onePhase) throws XAException
{
if (trace)
+ {
log.trace("commit(" + xid + ", " + onePhase + ")");
+ }
xaResource.commit(xid, onePhase);
}
@@ -139,10 +149,12 @@
* @param xid A global transaction identifier
* @exception XAException An error has occurred
*/
- public void rollback(Xid xid) throws XAException
+ public void rollback(final Xid xid) throws XAException
{
if (trace)
+ {
log.trace("rollback(" + xid + ")");
+ }
xaResource.rollback(xid);
}
@@ -152,10 +164,12 @@
* @param xid A global transaction identifier
* @exception XAException An error has occurred
*/
- public void forget(Xid xid) throws XAException
+ public void forget(final Xid xid) throws XAException
{
if (trace)
+ {
log.trace("forget(" + xid + ")");
+ }
managedConnection.lock();
try
@@ -174,10 +188,12 @@
* @return True if its the same RM instance; otherwise false.
* @exception XAException An error has occurred
*/
- public boolean isSameRM(XAResource xaRes) throws XAException
+ public boolean isSameRM(final XAResource xaRes) throws XAException
{
if (trace)
+ {
log.trace("isSameRM(" + xaRes + ")");
+ }
return xaResource.isSameRM(xaRes);
}
@@ -188,10 +204,12 @@
* @return Zero or more XIDs
* @exception XAException An error has occurred
*/
- public Xid[] recover(int flag) throws XAException
+ public Xid[] recover(final int flag) throws XAException
{
if (trace)
+ {
log.trace("recover(" + flag + ")");
+ }
return xaResource.recover(flag);
}
@@ -204,7 +222,9 @@
public int getTransactionTimeout() throws XAException
{
if (trace)
+ {
log.trace("getTransactionTimeout()");
+ }
return xaResource.getTransactionTimeout();
}
@@ -215,10 +235,12 @@
* @return True if the transaction timeout value is set successfully; otherwise false.
* @exception XAException An error has occurred
*/
- public boolean setTransactionTimeout(int seconds) throws XAException
+ public boolean setTransactionTimeout(final int seconds) throws XAException
{
if (trace)
+ {
log.trace("setTransactionTimeout(" + seconds + ")");
+ }
return xaResource.setTransactionTimeout(seconds);
}
Modified: trunk/src/main/org/jboss/messaging/ra/Util.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/Util.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/Util.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -33,7 +33,8 @@
* @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
* @version $Revision: $
*/
-public class Util {
+public class Util
+{
/**
* Private constructor
@@ -52,12 +53,16 @@
{
// If both null or intern equals
if (me == you)
+ {
return true;
-
+ }
+
// if me null and you are not
if (me == null && you != null)
+ {
return false;
-
+ }
+
// me will not be null, test for equality
return me.equals(you);
}
@@ -72,12 +77,16 @@
{
// If both null or intern equals
if (me == you)
+ {
return true;
-
+ }
+
// if me null and you are not
if (me == null && you != null)
+ {
return false;
-
+ }
+
// me will not be null, test for equality
return me.equals(you);
}
@@ -92,12 +101,16 @@
{
// If both null or intern equals
if (me == you)
+ {
return true;
-
+ }
+
// if me null and you are not
if (me == null && you != null)
+ {
return false;
-
+ }
+
// me will not be null, test for equality
return me.equals(you);
}
@@ -112,12 +125,16 @@
{
// If both null or intern equals
if (me == you)
+ {
return true;
-
+ }
+
// if me null and you are not
if (me == null && you != null)
+ {
return false;
-
+ }
+
// me will not be null, test for equality
return me.equals(you);
}
@@ -132,12 +149,16 @@
{
// If both null or intern equals
if (me == you)
+ {
return true;
-
+ }
+
// if me null and you are not
if (me == null && you != null)
+ {
return false;
-
+ }
+
// me will not be null, test for equality
return me.equals(you);
}
@@ -150,29 +171,29 @@
* @return the object
* @throws Exception for any error
*/
- public static Object lookup(Context context, String name, Class clazz) throws Exception
+ public static Object lookup(final Context context, final String name, final Class clazz) throws Exception
{
return context.lookup(name);
}
-
- public static Map<String, Object> parseConfig(String config)
+
+ public static Map<String, Object> parseConfig(final String config)
{
HashMap<String, Object> result = new HashMap<String, Object>();
-
+
String elements[] = config.split(";");
-
- for (String element: elements)
+
+ for (String element : elements)
{
String expression[] = element.split("=");
-
+
if (expression.length != 2)
{
- throw new IllegalArgumentException("Invalid expression " + element + " at " + config);
+ throw new IllegalArgumentException("Invalid expression " + element + " at " + config);
}
-
+
result.put(expression[0].trim(), expression[1].trim());
}
-
+
return result;
}
}
Modified: trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivation.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -77,41 +77,41 @@
/**
* The resource adapter
*/
- protected JBMResourceAdapter ra;
+ private final JBMResourceAdapter ra;
/**
* The activation spec
*/
- protected JBMActivationSpec spec;
+ private final JBMActivationSpec spec;
/**
* The message endpoint factory
*/
- protected MessageEndpointFactory endpointFactory;
+ private final MessageEndpointFactory endpointFactory;
/**
* Whether delivery is active
*/
- protected AtomicBoolean deliveryActive = new AtomicBoolean(false);
+ private final AtomicBoolean deliveryActive = new AtomicBoolean(false);
/**
* The destination type
*/
- protected boolean isTopic = false;
+ private boolean isTopic = false;
/**
* Is the delivery transacted
*/
- protected boolean isDeliveryTransacted;
+ private boolean isDeliveryTransacted;
- JBossDestination destination;
+ private JBossDestination destination;
/**
* The TransactionManager
*/
- protected TransactionManager tm;
+ private TransactionManager tm;
- private List<JBMMessageHandler> handlers = new ArrayList<JBMMessageHandler>();
+ private final List<JBMMessageHandler> handlers = new ArrayList<JBMMessageHandler>();
private JBossConnectionFactory factory;
@@ -135,7 +135,9 @@
* @param spec The activation spec
* @throws ResourceException Thrown if an error occurs
*/
- public JBMActivation(JBMResourceAdapter ra, MessageEndpointFactory endpointFactory, JBMActivationSpec spec) throws ResourceException
+ public JBMActivation(final JBMResourceAdapter ra,
+ final MessageEndpointFactory endpointFactory,
+ final JBMActivationSpec spec) throws ResourceException
{
if (trace)
{
@@ -147,7 +149,7 @@
this.spec = spec;
try
{
- this.isDeliveryTransacted = endpointFactory.isDeliveryTransacted(ONMESSAGE);
+ isDeliveryTransacted = endpointFactory.isDeliveryTransacted(ONMESSAGE);
}
catch (Exception e)
{
@@ -297,12 +299,12 @@
log.debug("Setting up " + spec);
setupCF();
-
+
setupDestination();
for (int i = 0; i < spec.getMaxSessionInt(); i++)
{
ClientSession session = setupSession();
-
+
JBMMessageHandler handler = new JBMMessageHandler(this, session);
handler.setup();
session.start();
@@ -331,14 +333,14 @@
{
if (spec.getConnectorClassName() == null)
{
- this.factory = ra.getJBossConnectionFactory();
+ factory = ra.getJBossConnectionFactory();
}
else
{
- this.factory = ra.createRemoteFactory(spec.getConnectorClassName(), spec.getParsedConnectionParameters());
+ factory = ra.createRemoteFactory(spec.getConnectorClassName(), spec.getParsedConnectionParameters());
}
}
-
+
/**
* Setup a session
*
@@ -354,7 +356,7 @@
try
{
- result = ra.createSession(this.factory.getCoreFactory(),
+ result = ra.createSession(factory.getCoreFactory(),
spec.getAcknowledgeModeInt(),
spec.getUser(),
spec.getPassword(),
@@ -395,7 +397,7 @@
protected void setupDestination() throws Exception
{
-
+
String destinationName = spec.getDestination();
if (spec.isUseJNDI())
@@ -403,13 +405,15 @@
Context ctx = new InitialContext();
log.debug("Using context " + ctx.getEnvironment() + " for " + spec);
if (trace)
+ {
log.trace("setupDestination(" + ctx + ")");
-
+ }
+
String destinationTypeString = spec.getDestinationType();
if (destinationTypeString != null && !destinationTypeString.trim().equals(""))
{
log.debug("Destination type defined as " + destinationTypeString);
-
+
Class<?> destinationType;
if (Topic.class.getName().equals(destinationTypeString))
{
@@ -420,7 +424,7 @@
{
destinationType = Queue.class;
}
-
+
log.debug("Retrieving destination " + destinationName + " of type " + destinationType.getName());
try
{
@@ -448,7 +452,7 @@
{
log.debug("Destination type not defined");
log.debug("Retrieving destination " + destinationName + " of type " + Destination.class.getName());
-
+
destination = (JBossDestination)Util.lookup(ctx, destinationName, Destination.class);
if (destination instanceof Topic)
{
@@ -476,6 +480,7 @@
*
* @return The value
*/
+ @Override
public String toString()
{
StringBuffer buffer = new StringBuffer();
Modified: trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivationSpec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivationSpec.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/inflow/JBMActivationSpec.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -24,16 +24,16 @@
import java.util.HashMap;
import java.util.Map;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.ra.JBMResourceAdapter;
-import org.jboss.messaging.ra.Util;
-
import javax.jms.Session;
import javax.resource.ResourceException;
import javax.resource.spi.ActivationSpec;
import javax.resource.spi.InvalidPropertyException;
import javax.resource.spi.ResourceAdapter;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.ra.JBMResourceAdapter;
+import org.jboss.messaging.ra.Util;
+
/**
* The activation spec
* These properties are set on the MDB ActivactionProperties
@@ -48,13 +48,13 @@
{
/** The logger */
private static final Logger log = Logger.getLogger(JBMActivationSpec.class);
-
+
/** Whether trace is enabled */
private static boolean trace = log.isTraceEnabled();
-
+
/** The transport config, changing the default configured from the RA */
private Map<String, Object> connectionParameters = new HashMap<String, Object>();
-
+
public String strConnectionParameters;
/** The transport type, changing the default configured from the RA */
@@ -107,31 +107,33 @@
/** Unspecified redelivery */
private Boolean redeliverUnspecified;
-
+
/** Transaction timeout */
private Integer transactionTimeout;
-
+
/** Is same RM override */
private Boolean isSameRMOverrideValue;
-
+
private boolean useJNDI = true;
-
+
/** Force clear on shutdown */
private Boolean forceClearOnShutdown;
-
+
/** Force clear internal */
private Long forceClearOnShutdownInterval;
-
+
/** Force clear attempts */
private Integer forceClearAttempts;
-
+
/**
* Constructor
*/
public JBMActivationSpec()
{
if (trace)
+ {
log.trace("constructor()");
+ }
ra = null;
destination = null;
@@ -163,13 +165,13 @@
public ResourceAdapter getResourceAdapter()
{
if (trace)
+ {
log.trace("getResourceAdapter()");
+ }
return ra;
}
-
-
/**
* @return the useJNDI
*/
@@ -181,9 +183,9 @@
/**
* @param useJNDI the useJNDI to set
*/
- public void setUseJNDI(boolean value)
+ public void setUseJNDI(final boolean value)
{
- this.useJNDI = value;
+ useJNDI = value;
}
/**
@@ -191,12 +193,15 @@
* @param ra The resource adapter
* @exception ResourceException Thrown if incorrect resource adapter
*/
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException
+ public void setResourceAdapter(final ResourceAdapter ra) throws ResourceException
{
if (trace)
+ {
log.trace("setResourceAdapter(" + ra + ")");
+ }
- if (ra == null || !(ra instanceof JBMResourceAdapter)) {
+ if (ra == null || !(ra instanceof JBMResourceAdapter))
+ {
throw new ResourceException("Resource adapter is " + ra);
}
@@ -210,7 +215,9 @@
public String getDestination()
{
if (trace)
+ {
log.trace("getDestination()");
+ }
return destination;
}
@@ -219,12 +226,14 @@
* Set the destination
* @param value The value
*/
- public void setDestination(String value)
+ public void setDestination(final String value)
{
if (trace)
+ {
log.trace("setDestination(" + value + ")");
+ }
- this.destination = value;
+ destination = value;
}
/**
@@ -234,7 +243,9 @@
public String getDestinationType()
{
if (trace)
+ {
log.trace("getDestinationType()");
+ }
return destinationType;
}
@@ -243,12 +254,14 @@
* Set the destination type
* @param value The value
*/
- public void setDestinationType(String value)
+ public void setDestinationType(final String value)
{
if (trace)
+ {
log.trace("setDestinationType(" + value + ")");
+ }
- this.destinationType = value;
+ destinationType = value;
}
/**
@@ -258,7 +271,9 @@
public String getMessageSelector()
{
if (trace)
+ {
log.trace("getMessageSelector()");
+ }
return messageSelector;
}
@@ -267,12 +282,14 @@
* Set the message selector
* @param value The value
*/
- public void setMessageSelector(String value)
+ public void setMessageSelector(final String value)
{
if (trace)
+ {
log.trace("setMessageSelector(" + value + ")");
+ }
- this.messageSelector = value;
+ messageSelector = value;
}
/**
@@ -282,33 +299,51 @@
public String getAcknowledgeMode()
{
if (trace)
+ {
log.trace("getAcknowledgeMode()");
+ }
if (sessionTransacted.booleanValue())
+ {
return "Transacted";
+ }
else if (Session.DUPS_OK_ACKNOWLEDGE == acknowledgeMode)
+ {
return "Dups-ok-acknowledge";
+ }
else
+ {
return "Auto-acknowledge";
+ }
}
/**
* Set the acknowledge mode
* @param value The value
*/
- public void setAcknowledgeMode(String value)
+ public void setAcknowledgeMode(final String value)
{
if (trace)
+ {
log.trace("setAcknowledgeMode(" + value + ")");
+ }
if ("DUPS_OK_ACKNOWLEDGE".equals(value) || "Dups-ok-acknowledge".equals(value))
- this.acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
+ {
+ acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
+ }
else if ("AUTO_ACKNOWLEDGE".equals(value) || "Auto-acknowledge".equals(value))
- this.acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
+ {
+ acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
+ }
else if ("SESSION_TRANSACTED".equals(value))
- this.acknowledgeMode = Session.SESSION_TRANSACTED;
+ {
+ acknowledgeMode = Session.SESSION_TRANSACTED;
+ }
else
+ {
throw new IllegalArgumentException("Unsupported acknowledgement mode " + value);
+ }
}
/**
@@ -317,10 +352,14 @@
public int getAcknowledgeModeInt()
{
if (trace)
+ {
log.trace("getAcknowledgeMode()");
+ }
if (sessionTransacted.booleanValue())
+ {
return Session.SESSION_TRANSACTED;
+ }
return acknowledgeMode;
}
@@ -332,24 +371,32 @@
public String getSubscriptionDurability()
{
if (trace)
+ {
log.trace("getSubscriptionDurability()");
+ }
if (subscriptionDurability)
+ {
return "Durable";
+ }
else
+ {
return "NonDurable";
+ }
}
/**
* Set the subscription durability
* @param value The value
*/
- public void setSubscriptionDurability(String value)
+ public void setSubscriptionDurability(final String value)
{
if (trace)
+ {
log.trace("setSubscriptionDurability(" + value + ")");
+ }
- this.subscriptionDurability = "Durable".equals(value);
+ subscriptionDurability = "Durable".equals(value);
}
/**
@@ -359,7 +406,9 @@
public boolean isSubscriptionDurable()
{
if (trace)
+ {
log.trace("isSubscriptionDurable()");
+ }
return subscriptionDurability;
}
@@ -371,7 +420,9 @@
public String getSubscriptionName()
{
if (trace)
+ {
log.trace("getSubscriptionName()");
+ }
return subscriptionName;
}
@@ -380,12 +431,14 @@
* Set the subscription name
* @param value The value
*/
- public void setSubscriptionName(String value)
+ public void setSubscriptionName(final String value)
{
if (trace)
+ {
log.trace("setSubscriptionName(" + value + ")");
+ }
- this.subscriptionName = value;
+ subscriptionName = value;
}
/**
@@ -395,7 +448,9 @@
public String getClientId()
{
if (trace)
+ {
log.trace("getClientId()");
+ }
if (clientId == null)
{
@@ -408,12 +463,14 @@
* Set the client id
* @param value The value
*/
- public void setClientId(String value)
+ public void setClientId(final String value)
{
if (trace)
+ {
log.trace("setClientId(" + value + ")");
+ }
- this.clientId = value;
+ clientId = value;
}
/**
@@ -423,8 +480,10 @@
public String getUser()
{
if (trace)
+ {
log.trace("getUser()");
-
+ }
+
if (user == null)
{
return ra.getUserName();
@@ -439,12 +498,14 @@
* Set the user
* @param value The value
*/
- public void setUser(String value)
+ public void setUser(final String value)
{
if (trace)
+ {
log.trace("setUser(" + value + ")");
+ }
- this.user = value;
+ user = value;
}
/**
@@ -454,8 +515,10 @@
public String getPassword()
{
if (trace)
+ {
log.trace("getPassword()");
-
+ }
+
if (password == null)
{
return ra.getPassword();
@@ -470,12 +533,14 @@
* Set the password
* @param value The value
*/
- public void setPassword(String value)
+ public void setPassword(final String value)
{
if (trace)
+ {
log.trace("setPassword(" + value + ")");
+ }
- this.password = value;
+ password = value;
}
/**
@@ -485,7 +550,9 @@
public Integer getMaxMessages()
{
if (trace)
+ {
log.trace("getMaxMessages()");
+ }
return maxMessages;
}
@@ -494,12 +561,14 @@
* Set the numer of max messages
* @param value The value
*/
- public void setMaxMessages(Integer value)
+ public void setMaxMessages(final Integer value)
{
if (trace)
+ {
log.trace("setMaxMessages(" + value + ")");
+ }
- this.maxMessages = value;
+ maxMessages = value;
}
/**
@@ -509,10 +578,14 @@
public int getMaxMessagesInt()
{
if (trace)
+ {
log.trace("getMaxMessagesInt()");
+ }
if (maxMessages == null)
+ {
return 0;
+ }
return maxMessages.intValue();
}
@@ -524,7 +597,9 @@
public Integer getMinSession()
{
if (trace)
+ {
log.trace("getMinSession()");
+ }
return minSession;
}
@@ -533,12 +608,14 @@
* Set the number of min session
* @param value The value
*/
- public void setMinSession(Integer value)
+ public void setMinSession(final Integer value)
{
if (trace)
+ {
log.trace("setMinSession(" + value + ")");
+ }
- this.minSession = value;
+ minSession = value;
}
/**
@@ -548,10 +625,14 @@
public int getMinSessionInt()
{
if (trace)
+ {
log.trace("getMinSessionInt()");
+ }
if (minSession == null)
+ {
return 0;
+ }
return minSession.intValue();
}
@@ -563,7 +644,9 @@
public Integer getMaxSession()
{
if (trace)
+ {
log.trace("getMaxSession()");
+ }
return maxSession;
}
@@ -572,10 +655,12 @@
* Set the number of max session
* @param value The value
*/
- public void setMaxSession(Integer value)
+ public void setMaxSession(final Integer value)
{
if (trace)
+ {
log.trace("setMaxSession(" + value + ")");
+ }
maxSession = value;
}
@@ -587,10 +672,14 @@
public int getMaxSessionInt()
{
if (trace)
+ {
log.trace("getMaxSessionInt()");
+ }
if (maxSession == null)
+ {
return 0;
+ }
return maxSession.intValue();
}
@@ -602,7 +691,9 @@
public Long getKeepAlive()
{
if (trace)
+ {
log.trace("getKeepAlive()");
+ }
return keepAlive;
}
@@ -611,12 +702,14 @@
* Set the keep alive
* @param value The value
*/
- public void setKeepAlive(Long value)
+ public void setKeepAlive(final Long value)
{
if (trace)
+ {
log.trace("setKeepAlive(" + value + ")");
+ }
- this.keepAlive = value;
+ keepAlive = value;
}
/**
@@ -626,10 +719,14 @@
public long getKeepAliveLong()
{
if (trace)
+ {
log.trace("getKeepAliveLong()");
+ }
if (keepAlive == null)
+ {
return 0;
+ }
return keepAlive.longValue();
}
@@ -641,7 +738,9 @@
public Boolean getSessionTransacted()
{
if (trace)
+ {
log.trace("getSessionTransacted()");
+ }
return sessionTransacted;
}
@@ -650,12 +749,14 @@
* Set the session transacted
* @param value The value
*/
- public void setSessionTransacted(Boolean value)
+ public void setSessionTransacted(final Boolean value)
{
if (trace)
+ {
log.trace("setTransactionTimeout(" + value + ")");
+ }
- this.sessionTransacted = value;
+ sessionTransacted = value;
}
/**
@@ -665,13 +766,18 @@
public boolean isSessionTransacted()
{
if (trace)
+ {
log.trace("isSessionTransacted()");
+ }
if (sessionTransacted == null)
+ {
return false;
+ }
return sessionTransacted.booleanValue();
}
+
/**
* Get the redeliver upspecified
* @return The value
@@ -679,7 +785,9 @@
public Boolean getRedeliverUnspecified()
{
if (trace)
+ {
log.trace("getRedeliverUnspecified()");
+ }
return redeliverUnspecified;
}
@@ -688,14 +796,16 @@
* Set the redeliver unspecified
* @param value The value
*/
- public void setRedeliverUnspecified(Boolean value)
+ public void setRedeliverUnspecified(final Boolean value)
{
if (trace)
+ {
log.trace("setRedeliverUnspecified(" + value + ")");
+ }
- this.redeliverUnspecified = value;
+ redeliverUnspecified = value;
}
-
+
/**
* Get the transaction timeout
* @return The value
@@ -703,7 +813,9 @@
public Integer getTransactionTimeout()
{
if (trace)
+ {
log.trace("getTransactionTimeout()");
+ }
return transactionTimeout;
}
@@ -712,14 +824,16 @@
* Set the transaction timeout
* @param value The value
*/
- public void setTransactionTimeout(Integer value)
+ public void setTransactionTimeout(final Integer value)
{
if (trace)
+ {
log.trace("setTransactionTimeout(" + value + ")");
+ }
transactionTimeout = value;
}
-
+
/**
* Get the is same rm override
* @return The value
@@ -727,7 +841,9 @@
public Boolean getIsSameRMOverrideValue()
{
if (trace)
+ {
log.trace("getIsSameRMOverrideValue()");
+ }
return isSameRMOverrideValue;
}
@@ -736,10 +852,12 @@
* Set the is same RM override
* @param value The value
*/
- public void setIsSameRMOverrideValue(Boolean value)
+ public void setIsSameRMOverrideValue(final Boolean value)
{
if (trace)
+ {
log.trace("setIsSameRMOverrideValue(" + value + ")");
+ }
isSameRMOverrideValue = value;
}
@@ -751,7 +869,9 @@
public Boolean getForceClearOnShutdown()
{
if (trace)
+ {
log.trace("getForceClearOnShutdown()");
+ }
return forceClearOnShutdown;
}
@@ -760,14 +880,16 @@
* Set the force clear on shutdown
* @param value The value
*/
- public void setForceClearOnShutdown(Boolean value)
+ public void setForceClearOnShutdown(final Boolean value)
{
if (trace)
+ {
log.trace("setForceClearOnShutdown(" + value + ")");
+ }
- this.forceClearOnShutdown = value;
- }
-
+ forceClearOnShutdown = value;
+ }
+
/**
* Get force clear on shutdown
* @return The value
@@ -775,10 +897,14 @@
public boolean isForceClearOnShutdown()
{
if (trace)
+ {
log.trace("isForceClearOnShutdown()");
+ }
if (forceClearOnShutdown == null)
+ {
return false;
+ }
return forceClearOnShutdown.booleanValue();
}
@@ -790,23 +916,27 @@
public Long getForceClearOnShutdownInterval()
{
if (trace)
+ {
log.trace("getForceClearOnShutdownInterval()");
+ }
return forceClearOnShutdownInterval;
}
-
+
/**
* Set the force clear on shutdown interval
* @param value The value
*/
- public void setForceClearOnShutdownInterval(Long value)
+ public void setForceClearOnShutdownInterval(final Long value)
{
if (trace)
+ {
log.trace("setForceClearOnShutdownInterval(" + value + ")");
+ }
forceClearOnShutdownInterval = value;
}
-
+
/**
* Get force clear attempts
* @return The value
@@ -814,19 +944,23 @@
public Integer getForceClearAttempts()
{
if (trace)
+ {
log.trace("getForceClearAttempts()");
+ }
return forceClearAttempts;
}
-
+
/**
* Set the force clear attempts
* @param value The value
*/
- public void setForceClearAttempts(Integer value)
+ public void setForceClearAttempts(final Integer value)
{
if (trace)
+ {
log.trace("setForceClearAttempts(" + value + ")");
+ }
forceClearAttempts = value;
}
@@ -838,10 +972,14 @@
public void validate() throws InvalidPropertyException
{
if (trace)
+ {
log.trace("validate()");
+ }
if (destination == null || destination.trim().equals(""))
+ {
throw new InvalidPropertyException("Destination is mandatory");
+ }
}
/**
@@ -851,18 +989,18 @@
{
return strConnectionParameters;
}
-
+
public Map<String, Object> getParsedConnectionParameters()
{
return connectionParameters;
}
- public void setConnectionParameters(String configuration)
+ public void setConnectionParameters(final String configuration)
{
- this.strConnectionParameters = configuration;
- this.connectionParameters = Util.parseConfig(configuration);
+ strConnectionParameters = configuration;
+ connectionParameters = Util.parseConfig(configuration);
}
-
+
/**
* @return the connectorClassName
*/
@@ -870,10 +1008,10 @@
{
return connectorClassName;
}
-
- public void setConnectorClassName(String value)
+
+ public void setConnectorClassName(final String value)
{
- this.connectorClassName = value;
+ connectorClassName = value;
}
/**
@@ -888,18 +1026,28 @@
buffer.append(" destination=").append(destination);
buffer.append(" destinationType=").append(destinationType);
if (messageSelector != null)
+ {
buffer.append(" selector=").append(messageSelector);
+ }
buffer.append(" tx=").append(sessionTransacted);
if (sessionTransacted == false)
+ {
buffer.append(" ack=").append(getAcknowledgeMode());
+ }
buffer.append(" durable=").append(subscriptionDurability);
if (clientId != null)
+ {
buffer.append(" clientID=").append(clientId);
+ }
if (subscriptionName != null)
+ {
buffer.append(" subscription=").append(subscriptionName);
+ }
buffer.append(" user=").append(user);
if (password != null)
+ {
buffer.append(" password=").append("****");
+ }
buffer.append(" maxMessages=").append(maxMessages);
buffer.append(" minSession=").append(minSession);
buffer.append(" maxSession=").append(maxSession);
@@ -907,24 +1055,24 @@
buffer.append(')');
return buffer.toString();
}
-
- //here for backwards compatibilty
- public void setUseDLQ(boolean b)
+
+ // here for backwards compatibilty
+ public void setUseDLQ(final boolean b)
{
-
+
}
- public void setDLQJNDIName(String name)
+ public void setDLQJNDIName(final String name)
{
}
- public void setDLQMaxResent(int maxResent)
+ public void setDLQMaxResent(final int maxResent)
{
}
- public void setProviderAdapterJNDI(String jndi)
+ public void setProviderAdapterJNDI(final String jndi)
{
}
Modified: trunk/src/main/org/jboss/messaging/ra/inflow/JBMMessageHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/ra/inflow/JBMMessageHandler.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/ra/inflow/JBMMessageHandler.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -21,6 +21,18 @@
*/
package org.jboss.messaging.ra.inflow;
+import java.util.UUID;
+
+import javax.jms.InvalidClientIDException;
+import javax.jms.JMSException;
+import javax.jms.MessageListener;
+import javax.jms.Session;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.transaction.Status;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
import org.jboss.messaging.core.client.ClientConsumer;
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientSession;
@@ -32,17 +44,6 @@
import org.jboss.messaging.jms.client.JBossMessage;
import org.jboss.messaging.utils.SimpleString;
-import javax.jms.InvalidClientIDException;
-import javax.jms.JMSException;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-import javax.resource.spi.endpoint.MessageEndpoint;
-import javax.resource.spi.endpoint.MessageEndpointFactory;
-import javax.transaction.Status;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.util.UUID;
-
/**
* The message handler
*
@@ -78,9 +79,9 @@
/**
* The transaction demarcation strategy factory
*/
- private DemarcationStrategyFactory strategyFactory = new DemarcationStrategyFactory();
+ private final DemarcationStrategyFactory strategyFactory = new DemarcationStrategyFactory();
- public JBMMessageHandler(JBMActivation activation, ClientSession session)
+ public JBMMessageHandler(final JBMActivation activation, final ClientSession session)
{
this.activation = activation;
this.session = session;
@@ -110,7 +111,8 @@
throw new InvalidClientIDException("Cannot create durable subscription - client ID has not been set");
}
- SimpleString queueName = new SimpleString(JBossTopic.createQueueNameForDurableSubscription(activation.getActivationSpec().getClientId(),
+ SimpleString queueName = new SimpleString(JBossTopic.createQueueNameForDurableSubscription(activation.getActivationSpec()
+ .getClientId(),
subscriptionName));
SessionQueueQueryResponseMessage subResponse = session.queueQuery(queueName);
@@ -129,8 +131,12 @@
SimpleString oldFilterString = subResponse.getFilterString();
- boolean selectorChanged = (selector == null && oldFilterString != null) || (oldFilterString == null && selector != null) ||
- (oldFilterString != null && selector != null && !oldFilterString.equals(selector));
+ boolean selectorChanged = selector == null && oldFilterString != null ||
+ oldFilterString == null &&
+ selector != null ||
+ oldFilterString != null &&
+ selector != null &&
+ !oldFilterString.equals(selector);
SimpleString oldTopicName = subResponse.getAddress();
@@ -210,10 +216,12 @@
}
}
- public void onMessage(ClientMessage message)
+ public void onMessage(final ClientMessage message)
{
if (trace)
+ {
log.trace("onMessage(" + message + ")");
+ }
TransactionDemarcationStrategy txnStrategy = strategyFactory.getStrategy();
try
@@ -239,8 +247,8 @@
return;
}
- if (activation.getActivationSpec().getAcknowledgeModeInt() == Session.SESSION_TRANSACTED ||
- activation.getActivationSpec().getAcknowledgeModeInt() == Session.CLIENT_ACKNOWLEDGE)
+ if (activation.getActivationSpec().getAcknowledgeModeInt() == Session.SESSION_TRANSACTED || activation.getActivationSpec()
+ .getAcknowledgeModeInt() == Session.CLIENT_ACKNOWLEDGE)
{
try
{
@@ -256,7 +264,7 @@
endpoint.beforeDelivery(JBMActivation.ONMESSAGE);
try
{
- MessageListener listener = (MessageListener) endpoint;
+ MessageListener listener = (MessageListener)endpoint;
listener.onMessage(jbm);
}
finally
@@ -347,8 +355,8 @@
private class LocalDemarcationStrategy implements TransactionDemarcationStrategy
{
/*
- * Start
- */
+ * Start
+ */
public void start()
{
@@ -431,7 +439,7 @@
{
private Transaction trans = null;
- private TransactionManager tm = activation.getTransactionManager();
+ private final TransactionManager tm = activation.getTransactionManager();
public void start() throws Throwable
{
@@ -549,4 +557,3 @@
}
}
}
-
Modified: trunk/src/main/org/jboss/messaging/utils/JBMThreadFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/utils/JBMThreadFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/utils/JBMThreadFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -38,15 +38,21 @@
private final AtomicInteger threadCount = new AtomicInteger(0);
private final int threadPriority;
- public JBMThreadFactory(final String groupName)
+
+ private final boolean daemon;
+
+ public JBMThreadFactory(final String groupName, final boolean daemon)
{
- this(groupName, Thread.NORM_PRIORITY);
+ this(groupName, Thread.NORM_PRIORITY, daemon);
}
- public JBMThreadFactory(String groupName, int priority)
+ public JBMThreadFactory(String groupName, int threadPriority, final boolean daemon)
{
- group = new ThreadGroup(groupName + "-" + System.identityHashCode(this));
- threadPriority = priority;
+ this.group = new ThreadGroup(groupName + "-" + System.identityHashCode(this));
+
+ this.threadPriority = threadPriority;
+
+ this.daemon = daemon;
}
public Thread newThread(final Runnable command)
@@ -56,8 +62,7 @@
group.getName() +
")");
- // Don't want to prevent VM from exiting
- t.setDaemon(true);
+ t.setDaemon(daemon);
t.setPriority(threadPriority);
return t;
}
Modified: trunk/src/main/org/jboss/messaging/utils/OrderedExecutorFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/utils/OrderedExecutorFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/main/org/jboss/messaging/utils/OrderedExecutorFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -47,7 +47,7 @@
{
this.parent = parent;
}
-
+
/**
* Get an executor that always executes tasks in order.
*
Modified: trunk/src/schemas/jbm-jms.xsd
===================================================================
--- trunk/src/schemas/jbm-jms.xsd 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/src/schemas/jbm-jms.xsd 2009-05-01 17:43:25 UTC (rev 6646)
@@ -105,6 +105,15 @@
<xsd:element name="load-balancing-policy-class-name" type="xsd:string"
maxOccurs="1" minOccurs="0">
</xsd:element>
+ <xsd:element name="use-global-pools" type="xsd:boolean"
+ maxOccurs="1" minOccurs="0">
+ </xsd:element>
+ <xsd:element name="scheduled-thread-pool-max-size" type="xsd:positiveInteger"
+ maxOccurs="1" minOccurs="0">
+ </xsd:element>
+ <xsd:element name="thread-pool-max-size" type="xsd:positiveInteger"
+ maxOccurs="1" minOccurs="0">
+ </xsd:element>
</xsd:all>
<xsd:attribute name="name" type="xsd:string"></xsd:attribute>
</xsd:complexType>
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/AcknowledgementTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -48,6 +48,11 @@
// Public --------------------------------------------------------
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
/* Topics shouldn't hold on to messages if there are no subscribers */
public void testPersistentMessagesForTopicDropped() throws Exception
@@ -503,7 +508,6 @@
try
{
-
conn = cf.createConnection();
Session producerSess = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/CTSMiscellaneousTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -21,11 +21,26 @@
*/
package org.jboss.test.messaging.jms;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS;
import java.util.ArrayList;
import java.util.List;
@@ -82,24 +97,27 @@
getJmsServerManager().createConnectionFactory("StrictTCKConnectionFactory",
connectorConfigs,
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ null,
+ DEFAULT_PING_PERIOD,
DEFAULT_CONNECTION_TTL,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- null,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ DEFAULT_CALL_TIMEOUT,
+ DEFAULT_MAX_CONNECTIONS,
+ DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ DEFAULT_CONSUMER_WINDOW_SIZE,
+ DEFAULT_CONSUMER_MAX_RATE,
+ DEFAULT_PRODUCER_WINDOW_SIZE,
+ DEFAULT_PRODUCER_MAX_RATE,
true,
true,
true,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
- ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_AUTO_GROUP,
+ DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_USE_GLOBAL_POOLS,
+ DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ DEFAULT_THREAD_POOL_MAX_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
DEFAULT_RECONNECT_ATTEMPTS,
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -225,7 +225,7 @@
public void onMessage(Message msg)
{
processed++;
-
+
if (processed == numMessages - 2)
{
synchronized (waitLock)
@@ -245,7 +245,7 @@
public void onMessage(Message msg)
{
processed++;
-
+
synchronized (waitLock)
{
//Should really cope with spurious wakeups
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/ConnectionTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -48,7 +48,7 @@
*
* $Id$
*/
-public class ConnectionTest extends TestCase // JMSTestCase
+public class ConnectionTest extends JMSTestCase
{
// Constants -----------------------------------------------------
@@ -65,287 +65,291 @@
// Public --------------------------------------------------------
// Disabled - http://www.jboss.org/index.html?module=bb&op=viewtopic&t=154603
- public void testFoo()
+// public void testFoo()
+// {
+//
+// }
+//
+
+ public void testManyConnections() throws Exception
{
+ for (int i = 0; i < 100; i++)
+ {
+ Connection conn = cf.createConnection();
+ conn.close();
+ }
+ }
+
+
+ //
+ // Note: All tests related to closing a Connection should go to ConnectionClosedTest
+ //
+
+ public void testGetClientID() throws Exception
+ {
+ Connection connection = cf.createConnection();
+ String clientID = connection.getClientID();
+
+ //We don't currently set client ids on the server, so this should be null.
+ //In the future we may provide conection factories that set a specific client id
+ //so this may change
+ assertNull(clientID);
+
+ connection.close();
+ }
+
+ public void testSetClientID() throws Exception
+ {
+ Connection connection = cf.createConnection();
+
+ final String clientID = "my-test-client-id";
+
+ connection.setClientID(clientID);
+
+ assertEquals(clientID, connection.getClientID());
+
+ connection.close();
+ }
+
+ public void testSetClientAfterStart() throws Exception
+ {
+ Connection connection = null;
+ try
+ {
+ connection = cf.createConnection();
+
+ //we startthe connection
+ connection.start();
+
+ // an attempt to set the client ID now should throw a IllegalStateException
+ connection.setClientID("testSetClientID_2");
+ fail("Should throw a javax.jms.IllegalStateException");
+ }
+ catch (javax.jms.IllegalStateException e)
+ {
+ }
+ catch (JMSException e)
+ {
+ fail("Should raise a javax.jms.IllegalStateException, not a " + e);
+ }
+ catch (java.lang.IllegalStateException e)
+ {
+ fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException");
+ }
+ finally
+ {
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
}
-
+
+ public void testSetClientIDFail() throws Exception
+ {
+ final String clientID = "my-test-client-id";
+
+ //Setting a client id must be the first thing done to the connection
+ //otherwise a javax.jms.IllegalStateException must be thrown
+
+ Connection connection = cf.createConnection();
+ connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try
+ {
+ connection.setClientID(clientID);
+ fail();
+ }
+ catch (javax.jms.IllegalStateException e)
+ {
+ log.trace("Caught exception ok");
+ }
+
+ connection.close();
+
+
+ connection = cf.createConnection();
+ connection.getClientID();
+ try
+ {
+ connection.setClientID(clientID);
+ fail();
+ }
+ catch (javax.jms.IllegalStateException e)
+ {
+ }
+ connection.close();
+
+ connection = cf.createConnection();
+ ExceptionListener listener = connection.getExceptionListener();
+ try
+ {
+ connection.setClientID(clientID);
+ fail();
+ }
+ catch (javax.jms.IllegalStateException e)
+ {
+ }
+ connection.close();
+
+ connection = cf.createConnection();
+ connection.setExceptionListener(listener);
+ try
+ {
+ connection.setClientID(clientID);
+ fail();
+ }
+ catch (javax.jms.IllegalStateException e)
+ {
+ }
+ connection.close();
+ }
+
+ public void testGetMetadata() throws Exception
+ {
+ Connection connection = cf.createConnection();
+
+ ConnectionMetaData metaData = (ConnectionMetaData)connection.getMetaData();
+
+ //TODO - need to check whether these are same as current version
+ metaData.getJMSMajorVersion();
+ metaData.getJMSMinorVersion();
+ metaData.getJMSProviderName();
+ metaData.getJMSVersion();
+ metaData.getJMSXPropertyNames();
+ metaData.getProviderMajorVersion();
+ metaData.getProviderMinorVersion();
+ metaData.getProviderVersion();
+
+ connection.close();
+ }
+
+
+ /**
+ * Test creation of QueueSession
+ */
+ public void testQueueConnection1() throws Exception
+ {
+ QueueConnectionFactory qcf = (QueueConnectionFactory)cf;
+
+ QueueConnection qc = qcf.createQueueConnection();
+
+ qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ qc.close();
+ }
+
+ /**
+ * Test creation of TopicSession
+ */
+ public void testQueueConnection2() throws Exception
+ {
+ TopicConnectionFactory tcf = (TopicConnectionFactory)cf;
+
+ TopicConnection tc = tcf.createTopicConnection();
+
+ tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ tc.close();
+
+ }
+
+ /**
+ * Test ExceptionListener stuff
+ */
+ public void testExceptionListener() throws Exception
+ {
+ Connection conn = cf.createConnection();
+
+ ExceptionListener listener1 = new MyExceptionListener();
+
+ conn.setExceptionListener(listener1);
+
+ ExceptionListener listener2 = conn.getExceptionListener();
+
+ assertNotNull(listener2);
+
+ assertEquals(listener1, listener2);
+
+ conn.close();
+
+ }
-// public void testManyConnections() throws Exception
-// {
-// for (int i = 0; i < 100; i++)
-// {
-// Connection conn = cf.createConnection();
-// conn.close();
-// }
-// }
-//
-//
-// //
-// // Note: All tests related to closing a Connection should go to ConnectionClosedTest
-// //
-//
-// public void testGetClientID() throws Exception
-// {
-// Connection connection = cf.createConnection();
-// String clientID = connection.getClientID();
-//
-// //We don't currently set client ids on the server, so this should be null.
-// //In the future we may provide conection factories that set a specific client id
-// //so this may change
-// assertNull(clientID);
-//
-// connection.close();
-// }
-//
-// public void testSetClientID() throws Exception
-// {
-// Connection connection = cf.createConnection();
-//
-// final String clientID = "my-test-client-id";
-//
-// connection.setClientID(clientID);
-//
-// assertEquals(clientID, connection.getClientID());
-//
-// connection.close();
-// }
-//
-// public void testSetClientAfterStart() throws Exception
-// {
-// Connection connection = null;
-// try
-// {
-// connection = cf.createConnection();
-//
-// //we startthe connection
-// connection.start();
-//
-// // an attempt to set the client ID now should throw a IllegalStateException
-// connection.setClientID("testSetClientID_2");
-// fail("Should throw a javax.jms.IllegalStateException");
-// }
-// catch (javax.jms.IllegalStateException e)
-// {
-// }
-// catch (JMSException e)
-// {
-// fail("Should raise a javax.jms.IllegalStateException, not a " + e);
-// }
-// catch (java.lang.IllegalStateException e)
-// {
-// fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException");
-// }
-// finally
-// {
-// if (connection != null)
-// {
-// connection.close();
-// }
-// }
-//
-// }
-//
-// public void testSetClientIDFail() throws Exception
-// {
-// final String clientID = "my-test-client-id";
-//
-// //Setting a client id must be the first thing done to the connection
-// //otherwise a javax.jms.IllegalStateException must be thrown
-//
-// Connection connection = cf.createConnection();
-// connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-// try
-// {
-// connection.setClientID(clientID);
-// fail();
-// }
-// catch (javax.jms.IllegalStateException e)
-// {
-// log.trace("Caught exception ok");
-// }
-//
-// connection.close();
-//
-//
-// connection = cf.createConnection();
-// connection.getClientID();
-// try
-// {
-// connection.setClientID(clientID);
-// fail();
-// }
-// catch (javax.jms.IllegalStateException e)
-// {
-// }
-// connection.close();
-//
-// connection = cf.createConnection();
-// ExceptionListener listener = connection.getExceptionListener();
-// try
-// {
-// connection.setClientID(clientID);
-// fail();
-// }
-// catch (javax.jms.IllegalStateException e)
-// {
-// }
-// connection.close();
-//
-// connection = cf.createConnection();
-// connection.setExceptionListener(listener);
-// try
-// {
-// connection.setClientID(clientID);
-// fail();
-// }
-// catch (javax.jms.IllegalStateException e)
-// {
-// }
-// connection.close();
-// }
-//
-// public void testGetMetadata() throws Exception
-// {
-// Connection connection = cf.createConnection();
-//
-// ConnectionMetaData metaData = (ConnectionMetaData)connection.getMetaData();
-//
-// //TODO - need to check whether these are same as current version
-// metaData.getJMSMajorVersion();
-// metaData.getJMSMinorVersion();
-// metaData.getJMSProviderName();
-// metaData.getJMSVersion();
-// metaData.getJMSXPropertyNames();
-// metaData.getProviderMajorVersion();
-// metaData.getProviderMinorVersion();
-// metaData.getProviderVersion();
-//
-// connection.close();
-// }
-//
-//
-// /**
-// * Test creation of QueueSession
-// */
-// public void testQueueConnection1() throws Exception
-// {
-// QueueConnectionFactory qcf = (QueueConnectionFactory)cf;
-//
-// QueueConnection qc = qcf.createQueueConnection();
-//
-// qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
-//
-// qc.close();
-// }
-//
-// /**
-// * Test creation of TopicSession
-// */
-// public void testQueueConnection2() throws Exception
-// {
-// TopicConnectionFactory tcf = (TopicConnectionFactory)cf;
-//
-// TopicConnection tc = tcf.createTopicConnection();
-//
-// tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-//
-// tc.close();
-//
-// }
-//
-// /**
-// * Test ExceptionListener stuff
-// */
-// public void testExceptionListener() throws Exception
-// {
-// Connection conn = cf.createConnection();
-//
-// ExceptionListener listener1 = new MyExceptionListener();
-//
-// conn.setExceptionListener(listener1);
-//
-// ExceptionListener listener2 = conn.getExceptionListener();
-//
-// assertNotNull(listener2);
-//
-// assertEquals(listener1, listener2);
-//
-// conn.close();
-//
-// }
-//
-// /*
-// * See http://jira.jboss.com/jira/browse/JBMESSAGING-635
-// *
-// * This needs to be run remotely to see the exception
-// */
-// public void testConnectionListenerBug() throws Exception
-// {
-// for (int i = 0; i < 100; i++)
-// {
-// Connection conn = cf.createConnection();
-//
-// MyExceptionListener listener = new MyExceptionListener();
-//
-// conn.setExceptionListener(listener);
-//
-// conn.close();
-//
-// //The problem with this test is I would need to capture the output and search
-// //for NullPointerException!!!
-// }
-// }
-//
-// /**
-// * This test is similar to a JORAM Test...
-// * (UnifiedTest::testCreateDurableConnectionConsumerOnQueueConnection)
-// *
-// * @throws Exception
-// */
-// public void testDurableSubscriberOnQueueConnection() throws Exception
-// {
-// QueueConnection queueConnection = ((QueueConnectionFactory)cf).createQueueConnection();
-//
-// try
-// {
-// queueConnection.createDurableConnectionConsumer((Topic)topic1, "subscriptionName", "",
-// (ServerSessionPool) null, 1);
-// fail("Should throw a javax.jms.IllegalStateException");
-// }
-// catch (javax.jms.IllegalStateException e)
-// {
-// }
-// catch (java.lang.IllegalStateException e)
-// {
-// fail ("Should throw a javax.jms.IllegalStateException");
-// }
-// catch (JMSException e)
-// {
-// fail("Should throw a javax.jms.IllegalStateException, not a " + e);
-// }
-// finally
-// {
-// queueConnection.close();
-// }
-// }
-//
-// // Package protected ---------------------------------------------
-//
-// // Protected -----------------------------------------------------
-//
-// // Private -------------------------------------------------------
-//
-// // Inner classes -------------------------------------------------
-//
-// static class MyExceptionListener implements ExceptionListener
-// {
-// JMSException exceptionReceived;
-//
-// public void onException(JMSException exception)
-// {
-// this.exceptionReceived = exception;
-// log.trace("Received exception");
-// }
-// }
+ /*
+ * See http://jira.jboss.com/jira/browse/JBMESSAGING-635
+ *
+ * This needs to be run remotely to see the exception
+ */
+ public void testConnectionListenerBug() throws Exception
+ {
+ for (int i = 0; i < 1000; i++)
+ {
+ log.info("********************************************");
+
+ Connection conn = cf.createConnection();
+
+ MyExceptionListener listener = new MyExceptionListener();
+
+ conn.setExceptionListener(listener);
+
+ conn.close();
+
+ //The problem with this test is I would need to capture the output and search
+ //for NullPointerException!!!
+
+ //Thread.sleep(100);
+ }
+ }
+
+ /**
+ * This test is similar to a JORAM Test...
+ * (UnifiedTest::testCreateDurableConnectionConsumerOnQueueConnection)
+ *
+ * @throws Exception
+ */
+ public void testDurableSubscriberOnQueueConnection() throws Exception
+ {
+ QueueConnection queueConnection = ((QueueConnectionFactory)cf).createQueueConnection();
+
+ try
+ {
+ queueConnection.createDurableConnectionConsumer((Topic)topic1, "subscriptionName", "",
+ (ServerSessionPool) null, 1);
+ fail("Should throw a javax.jms.IllegalStateException");
+ }
+ catch (javax.jms.IllegalStateException e)
+ {
+ }
+ catch (java.lang.IllegalStateException e)
+ {
+ fail ("Should throw a javax.jms.IllegalStateException");
+ }
+ catch (JMSException e)
+ {
+ fail("Should throw a javax.jms.IllegalStateException, not a " + e);
+ }
+ finally
+ {
+ queueConnection.close();
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+ static class MyExceptionListener implements ExceptionListener
+ {
+ JMSException exceptionReceived;
+
+ public void onException(JMSException exception)
+ {
+ this.exceptionReceived = exception;
+ log.trace("Received exception");
+ }
+ }
}
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -1,10 +1,25 @@
package org.jboss.test.messaging.jms;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS;
import java.util.ArrayList;
import java.util.List;
@@ -57,24 +72,27 @@
getJmsServerManager().createConnectionFactory("testsuitecf",
connectorConfigs,
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ null,
+ DEFAULT_PING_PERIOD,
DEFAULT_CONNECTION_TTL,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- null,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ DEFAULT_CALL_TIMEOUT,
+ DEFAULT_MAX_CONNECTIONS,
+ DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ DEFAULT_CONSUMER_WINDOW_SIZE,
+ DEFAULT_CONSUMER_MAX_RATE,
+ DEFAULT_PRODUCER_WINDOW_SIZE,
+ DEFAULT_PRODUCER_MAX_RATE,
true,
true,
true,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
- ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_AUTO_GROUP,
+ DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_USE_GLOBAL_POOLS,
+ DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ DEFAULT_THREAD_POOL_MAX_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
DEFAULT_RECONNECT_ATTEMPTS,
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -21,11 +21,26 @@
*/
package org.jboss.test.messaging.tools.container;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE;
+import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS;
import java.io.File;
import java.lang.management.ManagementFactory;
@@ -309,24 +324,27 @@
getJMSServerManager().createConnectionFactory(objectName,
connectorConfigs,
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ clientId,
+ DEFAULT_PING_PERIOD,
DEFAULT_CONNECTION_TTL,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- clientId,
- dupsOkBatchSize,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_CALL_TIMEOUT,
+ DEFAULT_MAX_CONNECTIONS,
+ DEFAULT_MIN_LARGE_MESSAGE_SIZE,
prefetchSize,
- -1,
- -1,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ DEFAULT_CONSUMER_MAX_RATE,
+ DEFAULT_PRODUCER_WINDOW_SIZE,
+ DEFAULT_PRODUCER_MAX_RATE,
blockOnAcknowledge,
true,
true,
- false,
- 8,
- false,
+ DEFAULT_AUTO_GROUP,
+ DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ DEFAULT_ACK_BATCH_SIZE,
+ dupsOkBatchSize,
+ DEFAULT_USE_GLOBAL_POOLS,
+ DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ DEFAULT_THREAD_POOL_MAX_SIZE,
DEFAULT_RETRY_INTERVAL,
DEFAULT_RETRY_INTERVAL_MULTIPLIER,
DEFAULT_RECONNECT_ATTEMPTS,
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientAckBatchSizeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientAckBatchSizeTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientAckBatchSizeTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -49,6 +49,19 @@
/*
* tests that wed don't acknowledge until the correct ackBatchSize is reached
* */
+
+ private int getMessageEncodeSize(final SimpleString address) throws Exception
+ {
+ ClientSessionFactory cf = createInVMFactory();
+ ClientSession session = cf.createSession(false, true, true);
+ ClientMessage message = session.createClientMessage(false);
+ // we need to set the destination so we can calculate the encodesize correctly
+ message.setDestination(address);
+ int encodeSize = message.getEncodeSize();
+ session.close();
+ cf.close();
+ return encodeSize;
+ }
public void testAckBatchSize() throws Exception
{
@@ -58,14 +71,11 @@
{
server.start();
ClientSessionFactory cf = createInVMFactory();
+ int numMessages = 100;
+ cf.setAckBatchSize(numMessages * getMessageEncodeSize(addressA));
+ cf.setBlockOnAcknowledge(true);
ClientSession sendSession = cf.createSession(false, true, true);
- ClientMessage message = sendSession.createClientMessage(false);
- // we need to set the destination so we can calculate the encodesize correctly
- message.setDestination(addressA);
- int encodeSize = message.getEncodeSize();
- int numMessages = 100;
- cf.setAckBatchSize(numMessages * encodeSize);
- cf.setBlockOnAcknowledge(true);
+
ClientSession session = cf.createSession(false, true, true);
session.createQueue(addressA, queueA, false);
ClientProducer cp = sendSession.createProducer(addressA);
@@ -110,12 +120,11 @@
{
server.start();
ClientSessionFactory cf = createInVMFactory();
+ cf.setAckBatchSize(0);
+ cf.setBlockOnAcknowledge(true);
ClientSession sendSession = cf.createSession(false, true, true);
- ClientMessage message = sendSession.createClientMessage(false);
- message.setDestination(addressA);
int numMessages = 100;
- cf.setAckBatchSize(0);
- cf.setBlockOnAcknowledge(true);
+
ClientSession session = cf.createSession(false, true, true);
session.createQueue(addressA, queueA, false);
ClientProducer cp = sendSession.createProducer(addressA);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionFactoryTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionFactoryTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -21,26 +21,28 @@
*/
package org.jboss.messaging.tests.integration.client;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.jboss.messaging.core.client.ClientSessionFactory;
import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
-import org.jboss.messaging.core.client.impl.ClientSessionFactoryInternal;
import org.jboss.messaging.core.client.impl.ClientSessionImpl;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.config.cluster.BroadcastGroupConfiguration;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.remoting.impl.invm.TransportConstants;
import org.jboss.messaging.core.server.Messaging;
import org.jboss.messaging.core.server.MessagingServer;
-import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
+import org.jboss.messaging.tests.util.RandomUtil;
import org.jboss.messaging.tests.util.ServiceTestBase;
import org.jboss.messaging.utils.Pair;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
*/
@@ -58,30 +60,59 @@
private TransportConfiguration backupTC;
- public void testConstructor1() throws Exception
+ public void testDefaultConstructor() throws Exception
{
try
{
startLiveAndBackup();
- ClientSessionFactory cf = new ClientSessionFactoryImpl(groupAddress, groupPort);
+ ClientSessionFactory cf = new ClientSessionFactoryImpl();
assertFactoryParams(cf,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ null,
+ null,
+ 0,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_REFRESH_TIMEOUT,
+ ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
+ ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
+ ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
+ ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS,
+ ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS,
+ ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ try
+ {
+ ClientSessionImpl session = (ClientSessionImpl)cf.createSession(false, true, true);
+ fail("Should throw exception");
+ }
+ catch (MessagingException e)
+ {
+ // Ok
+ }
+ final List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ Pair<TransportConfiguration, TransportConfiguration> pair0 = new Pair<TransportConfiguration, TransportConfiguration>(this.liveTC,
+ this.backupTC);
+ staticConnectors.add(pair0);
+ cf.setStaticConnectors(staticConnectors);
+ ClientSessionImpl session = (ClientSessionImpl)cf.createSession(false, true, true);
assertNotNull(session);
session.close();
+ testSettersThrowException(cf);
}
finally
{
@@ -89,31 +120,45 @@
}
}
-
- public void testConstructor2() throws Exception
+ public void testDiscoveryConstructor() throws Exception
{
try
{
startLiveAndBackup();
- ClientSessionFactory cf = new ClientSessionFactoryImpl(groupAddress, groupPort, 9999, 5555);
+ ClientSessionFactory cf = new ClientSessionFactoryImpl(groupAddress, groupPort);
assertFactoryParams(cf,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ null,
+ groupAddress,
+ groupPort,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_REFRESH_TIMEOUT,
+ ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
+ ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
+ ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
+ ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS,
+ ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS,
+ ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ ClientSessionImpl session = (ClientSessionImpl)cf.createSession(false, true, true);
assertNotNull(session);
session.close();
+ testSettersThrowException(cf);
}
finally
{
@@ -121,144 +166,50 @@
}
}
- public void testConstructor3() throws Exception
+ public void testStaticConnectorListConstructor() throws Exception
{
try
{
startLiveAndBackup();
- int batchSize = 33;
- long interval = 44l;
- double intervalMultiplier = 6.0;
- int reconnectAttempts = 8;
- boolean failoverOnServerShutdown = true;
- int maxConnections = 2;
- int minLargeMessageSize = 101;
- int producerMaxRate = 99;
- int windowSize = 88;
- int consumerMaxRate = 77;
- int windowSize1 = 66;
- long callTimeout = 55l;
- long ttl = 44l;
- long period = 33l;
- boolean onAcknowledge = true;
- boolean blockOnNonPersistentSend = true;
- boolean blockOnPersistentSend = true;
- boolean autoGroup = true;
- boolean preAcknowledge = true;
- ClientSessionFactory cf = new ClientSessionFactoryImpl(groupAddress, groupPort, 999, 555, org.jboss.messaging.core.client.impl.RandomConnectionLoadBalancingPolicy.class.getName(),
- period, ttl, callTimeout, windowSize1,
- consumerMaxRate, windowSize, producerMaxRate, minLargeMessageSize,
- onAcknowledge, blockOnNonPersistentSend, blockOnPersistentSend, autoGroup, maxConnections, preAcknowledge, batchSize, interval,
- intervalMultiplier, reconnectAttempts, failoverOnServerShutdown);
- assertFactoryParams(cf,
- batchSize,
- callTimeout,
- consumerMaxRate,
- windowSize1,
- maxConnections,
- minLargeMessageSize,
- period,
- producerMaxRate,
- windowSize,
- autoGroup,
- onAcknowledge,
- blockOnPersistentSend,
- blockOnNonPersistentSend,
- preAcknowledge);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
- assertNotNull(session);
- session.close();
- }
- finally
- {
- stopLiveAndBackup();
- }
- }
+ final List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ Pair<TransportConfiguration, TransportConfiguration> pair0 = new Pair<TransportConfiguration, TransportConfiguration>(this.liveTC,
+ this.backupTC);
+ staticConnectors.add(pair0);
- public void testConstructor4() throws Exception
- {
- int batchSize = 33;
- long interval = 44l;
- double intervalMultiplier = 6.0;
- int reconnectAttempts = 8;
- boolean failoverOnServerShutdown = true;
- int maxConnections = 2;
- int minLargeMessageSize = 101;
- int producerMaxRate = 99;
- int windowSize = 88;
- int consumerMaxRate = 77;
- int windowSize1 = 66;
- long callTimeout = 55l;
- long ttl = 44l;
- long period = 33l;
- boolean onAcknowledge = true;
- boolean blockOnNonPersistentSend = true;
- boolean blockOnPersistentSend = true;
- boolean autoGroup = true;
- boolean preAcknowledge = true;
- ArrayList<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
- try
- {
- startLiveAndBackup();
- connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(liveTC, backupTC));
- ClientSessionFactory cf = new ClientSessionFactoryImpl(connectorConfigs, org.jboss.messaging.core.client.impl.RandomConnectionLoadBalancingPolicy.class.getName(),
- period, ttl, callTimeout, windowSize1,
- consumerMaxRate, windowSize, producerMaxRate, minLargeMessageSize,
- onAcknowledge, blockOnNonPersistentSend, blockOnPersistentSend, autoGroup, maxConnections, preAcknowledge, batchSize, interval,
- intervalMultiplier, reconnectAttempts, failoverOnServerShutdown);
+ ClientSessionFactory cf = new ClientSessionFactoryImpl(staticConnectors);
assertFactoryParams(cf,
- batchSize,
- callTimeout,
- consumerMaxRate,
- windowSize1,
- maxConnections,
- minLargeMessageSize,
- period,
- producerMaxRate,
- windowSize,
- autoGroup,
- onAcknowledge,
- blockOnPersistentSend,
- blockOnNonPersistentSend,
- preAcknowledge);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
- assertNotNull(session);
- session.close();
- }
- finally
- {
- stopLiveAndBackup();
- }
- }
-
- public void testConstructor5() throws Exception
- {
- try
- {
- startLiveAndBackup();
- long interval = 66l;
- double intervalMultiplier = 7.0;
- int reconnectAttempts = 44;
- boolean failoverOnServerShutdown = true;
- ClientSessionFactory cf = new ClientSessionFactoryImpl(liveTC, backupTC, failoverOnServerShutdown, interval, intervalMultiplier, reconnectAttempts);
- assertFactoryParams(cf,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ staticConnectors,
+ null,
+ 0,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_REFRESH_TIMEOUT,
+ ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
+ ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
+ ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
+ ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS,
+ ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS,
+ ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ ClientSessionImpl session = (ClientSessionImpl)cf.createSession(false, true, true);
assertNotNull(session);
session.close();
+ testSettersThrowException(cf);
}
finally
{
@@ -266,33 +217,50 @@
}
}
- public void testConstructor6() throws Exception
+ public void testStaticConnectorLiveAndBackupConstructor() throws Exception
{
try
{
startLiveAndBackup();
- long interval = 66l;
- double intervalMultiplier = 7.0;
- int reconnectAttempts = 44;
- ClientSessionFactory cf = new ClientSessionFactoryImpl(liveTC, interval, intervalMultiplier, reconnectAttempts);
+ final List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ Pair<TransportConfiguration, TransportConfiguration> pair0 = new Pair<TransportConfiguration, TransportConfiguration>(this.liveTC,
+ this.backupTC);
+ staticConnectors.add(pair0);
+
+ ClientSessionFactory cf = new ClientSessionFactoryImpl(this.liveTC, this.backupTC);
assertFactoryParams(cf,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ staticConnectors,
+ null,
+ 0,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_REFRESH_TIMEOUT,
+ ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
+ ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
+ ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
+ ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS,
+ ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS,
+ ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ ClientSessionImpl session = (ClientSessionImpl)cf.createSession(false, true, true);
assertNotNull(session);
session.close();
+ testSettersThrowException(cf);
}
finally
{
@@ -300,30 +268,50 @@
}
}
- public void testConstructor7() throws Exception
+ public void testStaticConnectorLiveConstructor() throws Exception
{
try
{
startLiveAndBackup();
- ClientSessionFactory cf = new ClientSessionFactoryImpl(liveTC, backupTC);
+ final List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ Pair<TransportConfiguration, TransportConfiguration> pair0 = new Pair<TransportConfiguration, TransportConfiguration>(this.liveTC,
+ null);
+ staticConnectors.add(pair0);
+
+ ClientSessionFactory cf = new ClientSessionFactoryImpl(this.liveTC);
assertFactoryParams(cf,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ staticConnectors,
+ null,
+ 0,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_REFRESH_TIMEOUT,
+ ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
+ ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
+ ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
+ ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS,
+ ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS,
+ ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ ClientSessionImpl session = (ClientSessionImpl)cf.createSession(false, true, true);
assertNotNull(session);
session.close();
+ testSettersThrowException(cf);
}
finally
{
@@ -331,290 +319,493 @@
}
}
- public void testConstructor8() throws Exception
+ public void testGettersAndSetters()
{
+ ClientSessionFactory cf = new ClientSessionFactoryImpl();
+
+ List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ Pair<TransportConfiguration, TransportConfiguration> pair0 = new Pair<TransportConfiguration, TransportConfiguration>(this.liveTC,
+ this.backupTC);
+ staticConnectors.add(pair0);
+
+ String discoveryAddress = randomString();
+ int discoveryPort = RandomUtil.randomPositiveInt();
+ long discoveryRefreshTimeout = RandomUtil.randomPositiveLong();
+ long pingPeriod = RandomUtil.randomPositiveLong();
+ long connectionTTL = RandomUtil.randomPositiveLong();
+ long callTimeout = RandomUtil.randomPositiveLong();
+ int maxConnections = RandomUtil.randomPositiveInt();
+ int minLargeMessageSize = RandomUtil.randomPositiveInt();
+ int consumerWindowSize = RandomUtil.randomPositiveInt();
+ int consumerMaxRate = RandomUtil.randomPositiveInt();
+ int producerWindowSize = RandomUtil.randomPositiveInt();
+ int producerMaxRate = RandomUtil.randomPositiveInt();
+ boolean blockOnAcknowledge = RandomUtil.randomBoolean();
+ boolean blockOnPersistentSend = RandomUtil.randomBoolean();
+ boolean blockOnNonPersistentSend = RandomUtil.randomBoolean();
+ boolean autoGroup = RandomUtil.randomBoolean();
+ boolean preAcknowledge = RandomUtil.randomBoolean();
+ String loadBalancingPolicyClassName = RandomUtil.randomString();
+ int ackBatchSize = RandomUtil.randomPositiveInt();
+ long initialWaitTimeout = RandomUtil.randomPositiveLong();
+ boolean useGlobalPools = RandomUtil.randomBoolean();
+ int scheduledThreadPoolMaxSize = RandomUtil.randomPositiveInt();
+ int threadPoolMaxSize = RandomUtil.randomPositiveInt();
+ long retryInterval = RandomUtil.randomPositiveLong();
+ double retryIntervalMultiplier = RandomUtil.randomDouble();
+ int reconnectAttempts = RandomUtil.randomPositiveInt();
+ boolean failoverOnServerShutdown = RandomUtil.randomBoolean();
+
+ cf.setStaticConnectors(staticConnectors);
+ cf.setDiscoveryAddress(discoveryAddress);
+ cf.setDiscoveryPort(discoveryPort);
+ cf.setDiscoveryRefreshTimeout(discoveryRefreshTimeout);
+ cf.setPingPeriod(pingPeriod);
+ cf.setConnectionTTL(connectionTTL);
+ cf.setCallTimeout(callTimeout);
+ cf.setMaxConnections(maxConnections);
+ cf.setMinLargeMessageSize(minLargeMessageSize);
+ cf.setConsumerWindowSize(consumerWindowSize);
+ cf.setConsumerMaxRate(consumerMaxRate);
+ cf.setProducerWindowSize(producerWindowSize);
+ cf.setProducerMaxRate(producerMaxRate);
+ cf.setBlockOnAcknowledge(blockOnAcknowledge);
+ cf.setBlockOnPersistentSend(blockOnPersistentSend);
+ cf.setBlockOnNonPersistentSend(blockOnNonPersistentSend);
+ cf.setAutoGroup(autoGroup);
+ cf.setPreAcknowledge(preAcknowledge);
+ cf.setLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
+ cf.setAckBatchSize(ackBatchSize);
+ cf.setInitialWaitTimeout(initialWaitTimeout);
+ cf.setUseGlobalPools(useGlobalPools);
+ cf.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
+ cf.setThreadPoolMaxSize(threadPoolMaxSize);
+ cf.setRetryInterval(retryInterval);
+ cf.setRetryIntervalMultiplier(retryIntervalMultiplier);
+ cf.setReconnectAttempts(reconnectAttempts);
+ cf.setFailoverOnServerShutdown(failoverOnServerShutdown);
+
+ assertEquals(staticConnectors, cf.getStaticConnectors());
+ assertEquals(discoveryAddress, cf.getDiscoveryAddress());
+ assertEquals(discoveryPort, cf.getDiscoveryPort());
+ assertEquals(discoveryRefreshTimeout, cf.getDiscoveryRefreshTimeout());
+ assertEquals(pingPeriod, cf.getPingPeriod());
+ assertEquals(connectionTTL, cf.getConnectionTTL());
+ assertEquals(callTimeout, cf.getCallTimeout());
+ assertEquals(maxConnections, cf.getMaxConnections());
+ assertEquals(minLargeMessageSize, cf.getMinLargeMessageSize());
+ assertEquals(consumerWindowSize, cf.getConsumerWindowSize());
+ assertEquals(consumerMaxRate, cf.getConsumerMaxRate());
+ assertEquals(producerWindowSize, cf.getProducerWindowSize());
+ assertEquals(producerMaxRate, cf.getProducerMaxRate());
+ assertEquals(blockOnAcknowledge, cf.isBlockOnAcknowledge());
+ assertEquals(blockOnPersistentSend, cf.isBlockOnPersistentSend());
+ assertEquals(blockOnNonPersistentSend, cf.isBlockOnNonPersistentSend());
+ assertEquals(autoGroup, cf.isAutoGroup());
+ assertEquals(preAcknowledge, cf.isPreAcknowledge());
+ assertEquals(loadBalancingPolicyClassName, cf.getLoadBalancingPolicyClassName());
+ assertEquals(ackBatchSize, cf.getAckBatchSize());
+ assertEquals(initialWaitTimeout, cf.getInitialWaitTimeout());
+ assertEquals(useGlobalPools, cf.isUseGlobalPools());
+ assertEquals(scheduledThreadPoolMaxSize, cf.getScheduledThreadPoolMaxSize());
+ assertEquals(threadPoolMaxSize, cf.getThreadPoolMaxSize());
+ assertEquals(retryInterval, cf.getRetryInterval());
+ assertEquals(retryIntervalMultiplier, cf.getRetryIntervalMultiplier());
+ assertEquals(reconnectAttempts, cf.getReconnectAttempts());
+ assertEquals(failoverOnServerShutdown, cf.isFailoverOnServerShutdown());
+
+ }
+
+ private void testSettersThrowException(ClientSessionFactory cf)
+ {
+ List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ Pair<TransportConfiguration, TransportConfiguration> pair0 = new Pair<TransportConfiguration, TransportConfiguration>(this.liveTC,
+ this.backupTC);
+ staticConnectors.add(pair0);
+
+ String discoveryAddress = randomString();
+ int discoveryPort = RandomUtil.randomPositiveInt();
+ long discoveryRefreshTimeout = RandomUtil.randomPositiveLong();
+ long pingPeriod = RandomUtil.randomPositiveLong();
+ long connectionTTL = RandomUtil.randomPositiveLong();
+ long callTimeout = RandomUtil.randomPositiveLong();
+ int maxConnections = RandomUtil.randomPositiveInt();
+ int minLargeMessageSize = RandomUtil.randomPositiveInt();
+ int consumerWindowSize = RandomUtil.randomPositiveInt();
+ int consumerMaxRate = RandomUtil.randomPositiveInt();
+ int producerWindowSize = RandomUtil.randomPositiveInt();
+ int producerMaxRate = RandomUtil.randomPositiveInt();
+ boolean blockOnAcknowledge = RandomUtil.randomBoolean();
+ boolean blockOnPersistentSend = RandomUtil.randomBoolean();
+ boolean blockOnNonPersistentSend = RandomUtil.randomBoolean();
+ boolean autoGroup = RandomUtil.randomBoolean();
+ boolean preAcknowledge = RandomUtil.randomBoolean();
+ String loadBalancingPolicyClassName = RandomUtil.randomString();
+ int ackBatchSize = RandomUtil.randomPositiveInt();
+ long initialWaitTimeout = RandomUtil.randomPositiveLong();
+ boolean useGlobalPools = RandomUtil.randomBoolean();
+ int scheduledThreadPoolMaxSize = RandomUtil.randomPositiveInt();
+ int threadPoolMaxSize = RandomUtil.randomPositiveInt();
+ long retryInterval = RandomUtil.randomPositiveLong();
+ double retryIntervalMultiplier = RandomUtil.randomDouble();
+ int reconnectAttempts = RandomUtil.randomPositiveInt();
+ boolean failoverOnServerShutdown = RandomUtil.randomBoolean();
+
try
{
- int batchSize = 33;
- long interval = 44l;
- double intervalMultiplier = 6.0;
- int reconnectAttempts = 8;
- int maxConnections = 2;
- int minLargeMessageSize = 101;
- int producerMaxRate = 99;
- int windowSize = 88;
- int consumerMaxRate = 77;
- int windowSize1 = 66;
- long callTimeout = 55l;
- long ttl = 44l;
- long period = 33l;
- boolean onAcknowledge = true;
- boolean blockOnNonPersistentSend = true;
- boolean blockOnPersistentSend = true;
- boolean autoGroup = true;
- boolean preAcknowledge = true;
- boolean failoverOnServerShutdown = true;
-
- startLiveAndBackup();
- ClientSessionFactory cf = new ClientSessionFactoryImpl(liveTC, backupTC,
- failoverOnServerShutdown,
- org.jboss.messaging.core.client.impl.RandomConnectionLoadBalancingPolicy.class.getName(),
- period, ttl, callTimeout, windowSize1,
- consumerMaxRate, windowSize, producerMaxRate, minLargeMessageSize,
- onAcknowledge, blockOnNonPersistentSend, blockOnPersistentSend, autoGroup, maxConnections, preAcknowledge, batchSize, interval,
- intervalMultiplier, reconnectAttempts);
-
- assertFactoryParams(cf,
- batchSize,
- callTimeout,
- consumerMaxRate,
- windowSize1,
- maxConnections,
- minLargeMessageSize,
- period,
- producerMaxRate,
- windowSize,
- autoGroup,
- onAcknowledge,
- blockOnPersistentSend,
- blockOnNonPersistentSend,
- preAcknowledge);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
- assertNotNull(session);
- session.close();
+ cf.setStaticConnectors(staticConnectors);
+ fail("Should throw exception");
}
- finally
+ catch (IllegalStateException e)
{
- stopLiveAndBackup();
+ // OK
}
- }
-
- public void testConstructor9() throws Exception
- {
try
{
- startLiveAndBackup();
- ClientSessionFactory cf = new ClientSessionFactoryImpl(liveTC);
- assertFactoryParams(cf,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
- assertNotNull(session);
- session.close();
+ cf.setDiscoveryAddress(discoveryAddress);
+ fail("Should throw exception");
}
- finally
+ catch (IllegalStateException e)
{
- stopLiveAndBackup();
+ // OK
}
- }
-
- public void testNumSessionsNumConnections() throws Exception
- {
try
{
- startLiveAndBackup();
- ClientSessionFactoryInternal cf = new ClientSessionFactoryImpl(liveTC);
-
- assertFactoryParams(cf,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE);
- ClientSessionImpl sessions[] = new ClientSessionImpl[ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 2];
- for (int i = 0; i < sessions.length; i++)
- {
- sessions[i] = (ClientSessionImpl) cf.createSession(false, true, true);
-
- }
- assertEquals(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 2, cf.numSessions());
- assertEquals(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS, cf.numConnections());
- for (ClientSessionImpl session : sessions)
- {
- session.close();
- }
+ cf.setDiscoveryPort(discoveryPort);
+ fail("Should throw exception");
}
- finally
+ catch (IllegalStateException e)
{
- stopLiveAndBackup();
+ // OK
}
- }
-
- public void testSetters() throws Exception
- {
- int batchSize = 33;
- int minLargeMessageSize = 101;
- int producerMaxRate = 99;
- int windowSize = 88;
- int consumerMaxRate = 77;
- int windowSize1 = 66;
- boolean onAcknowledge = true;
- boolean blockOnNonPersistentSend = true;
- boolean blockOnPersistentSend = true;
- boolean autoGroup = true;
- boolean preAcknowledge = true;
try
{
- startLiveAndBackup();
- ClientSessionFactory cf = new ClientSessionFactoryImpl(liveTC);
- assertFactoryParams(cf,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE);
- cf.setAckBatchSize(batchSize);
- cf.setAutoGroup(autoGroup);
- cf.setBlockOnAcknowledge(onAcknowledge);
- cf.setBlockOnNonPersistentSend(blockOnNonPersistentSend);
- cf.setBlockOnPersistentSend(blockOnPersistentSend);
+ cf.setDiscoveryRefreshTimeout(discoveryRefreshTimeout);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setPingPeriod(pingPeriod);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setConnectionTTL(connectionTTL);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setCallTimeout(callTimeout);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setMaxConnections(maxConnections);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setMinLargeMessageSize(minLargeMessageSize);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setConsumerWindowSize(consumerWindowSize);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
cf.setConsumerMaxRate(consumerMaxRate);
- cf.setConsumerWindowSize(windowSize1);
- cf.setMinLargeMessageSize(minLargeMessageSize);
- cf.setPreAcknowledge(preAcknowledge);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setProducerWindowSize(producerWindowSize);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
cf.setProducerMaxRate(producerMaxRate);
- cf.setProducerWindowSize(windowSize);
- assertFactoryParams(cf,
- batchSize,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- consumerMaxRate,
- windowSize1,
- ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
- minLargeMessageSize,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
- producerMaxRate,
- windowSize,
- autoGroup,
- onAcknowledge,
- blockOnPersistentSend,
- blockOnNonPersistentSend,
- preAcknowledge);
- ClientSessionImpl session = (ClientSessionImpl) cf.createSession(false, true, true);
- assertNotNull(session);
- session.close();
+ fail("Should throw exception");
}
- finally
+ catch (IllegalStateException e)
{
- stopLiveAndBackup();
+ // OK
}
- }
-
- public void testCreateSessionFailureWithSimpleConstructorWhenNoServer() throws Exception
- {
-
- /****************************/
- /* No JBM Server is started */
- /****************************/
-
- ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration(NettyConnectorFactory.class.getName()));
-
try
{
- sf.createSession(false, true, true);
- fail("Can not create a session when there is no running JBM Server");
+ cf.setBlockOnAcknowledge(blockOnAcknowledge);
+ fail("Should throw exception");
}
- catch (Exception e)
+ catch (IllegalStateException e)
{
+ // OK
}
-
- }
-
- /**
- * The test is commented because it generates an infinite loop.
- * The configuration to have it occured is:
- * - no backup & default values for max retries before/after failover
- *
- * - The infinite loop is in ConnectionManagerImpl.getConnectionForCreateSession()
- * - getConnection(1) always return null (no server to connect to)
- * - failover() always return true
- * - the value returned by failover() comes from the reconnect() method
- * - when there is no session already connected, the reconnect() method does *nothing*
- * and returns true (while nothing has been reconnected)
- */
- public void testCreateSessionFailureWithDefaultValuesWhenNoServer() throws Exception
- {
-
- /****************************/
- /* No JBM Server is started */
- /****************************/
-
- ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration(NettyConnectorFactory.class.getName()),
- null,
- ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS);
-
try
{
- sf.createSession(false, true, true);
- fail("Can not create a session when there is no running JBM Server");
+ cf.setBlockOnPersistentSend(blockOnPersistentSend);
+ fail("Should throw exception");
}
- catch (Exception e)
+ catch (IllegalStateException e)
{
+ // OK
}
+ try
+ {
+ cf.setBlockOnNonPersistentSend(blockOnNonPersistentSend);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setAutoGroup(autoGroup);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setPreAcknowledge(preAcknowledge);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setLoadBalancingPolicyClassName(loadBalancingPolicyClassName);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setAckBatchSize(ackBatchSize);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setInitialWaitTimeout(initialWaitTimeout);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setUseGlobalPools(useGlobalPools);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setThreadPoolMaxSize(threadPoolMaxSize);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setRetryInterval(retryInterval);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setRetryIntervalMultiplier(retryIntervalMultiplier);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setReconnectAttempts(reconnectAttempts);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+ try
+ {
+ cf.setFailoverOnServerShutdown(failoverOnServerShutdown);
+ fail("Should throw exception");
+ }
+ catch (IllegalStateException e)
+ {
+ // OK
+ }
+
+ cf.getStaticConnectors();
+ cf.getDiscoveryAddress();
+ cf.getDiscoveryPort();
+ cf.getDiscoveryRefreshTimeout();
+ cf.getPingPeriod();
+ cf.getConnectionTTL();
+ cf.getCallTimeout();
+ cf.getMaxConnections();
+ cf.getMinLargeMessageSize();
+ cf.getConsumerWindowSize();
+ cf.getConsumerMaxRate();
+ cf.getProducerWindowSize();
+ cf.getProducerMaxRate();
+ cf.isBlockOnAcknowledge();
+ cf.isBlockOnPersistentSend();
+ cf.isBlockOnNonPersistentSend();
+ cf.isAutoGroup();
+ cf.isPreAcknowledge();
+ cf.getLoadBalancingPolicyClassName();
+ cf.getAckBatchSize();
+ cf.getInitialWaitTimeout();
+ cf.isUseGlobalPools();
+ cf.getScheduledThreadPoolMaxSize();
+ cf.getThreadPoolMaxSize();
+ cf.getRetryInterval();
+ cf.getRetryIntervalMultiplier();
+ cf.getReconnectAttempts();
+ cf.isFailoverOnServerShutdown();
+
}
private void assertFactoryParams(ClientSessionFactory cf,
- int ackBatchSize,
+ List<Pair<TransportConfiguration, TransportConfiguration>> staticConnectors,
+ String discoveryAddress,
+ int discoveryPort,
+ long discoveryRefreshTimeout,
+ long pingPeriod,
+ long connectionTTL,
long callTimeout,
- int consumerMaxRate,
- int consumerWindowSize,
int maxConnections,
int minLargeMessageSize,
- long pingPeriod,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
int producerMaxRate,
- int sendWindowSize,
- boolean autoGroup,
boolean blockOnAcknowledge,
+ boolean blockOnPersistentSend,
boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean preAcknowledge)
+ boolean autoGroup,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int ackBatchSize,
+ long initialWaitTimeout,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int reconnectAttempts,
+ boolean failoverOnServerShutdown)
{
- assertEquals(cf.getAckBatchSize(), ackBatchSize);
+ List<Pair<TransportConfiguration, TransportConfiguration>> cfStaticConnectors = cf.getStaticConnectors();
+ if (staticConnectors == null)
+ {
+ assertNull(cfStaticConnectors);
+ }
+ else
+ {
+ assertEquals(staticConnectors.size(), cfStaticConnectors.size());
+
+ for (int i = 0; i < staticConnectors.size(); i++)
+ {
+ assertEquals(staticConnectors.get(i), cfStaticConnectors.get(i));
+ }
+ }
+ assertEquals(cf.getDiscoveryAddress(), discoveryAddress);
+ assertEquals(cf.getDiscoveryPort(), discoveryPort);
+ assertEquals(cf.getDiscoveryRefreshTimeout(), discoveryRefreshTimeout);
+ assertEquals(cf.getPingPeriod(), pingPeriod);
+ assertEquals(cf.getConnectionTTL(), connectionTTL);
assertEquals(cf.getCallTimeout(), callTimeout);
- assertEquals(cf.getConsumerMaxRate(), consumerMaxRate);
- assertEquals(cf.getConsumerWindowSize(), consumerWindowSize);
assertEquals(cf.getMaxConnections(), maxConnections);
assertEquals(cf.getMinLargeMessageSize(), minLargeMessageSize);
- assertEquals(cf.getPingPeriod(), pingPeriod);
+ assertEquals(cf.getConsumerWindowSize(), consumerWindowSize);
+ assertEquals(cf.getConsumerMaxRate(), consumerMaxRate);
+ assertEquals(cf.getProducerWindowSize(), producerWindowSize);
assertEquals(cf.getProducerMaxRate(), producerMaxRate);
- assertEquals(cf.getProducerWindowSize(), sendWindowSize);
- assertEquals(cf.isAutoGroup(), autoGroup);
assertEquals(cf.isBlockOnAcknowledge(), blockOnAcknowledge);
+ assertEquals(cf.isBlockOnPersistentSend(), blockOnPersistentSend);
assertEquals(cf.isBlockOnNonPersistentSend(), blockOnNonPersistentSend);
- assertEquals(cf.isBlockOnPersistentSend(), blockOnPersistentSend);
+ assertEquals(cf.isAutoGroup(), autoGroup);
assertEquals(cf.isPreAcknowledge(), preAcknowledge);
+ assertEquals(cf.getLoadBalancingPolicyClassName(), loadBalancingPolicyClassName);
+ assertEquals(cf.getAckBatchSize(), ackBatchSize);
+ assertEquals(cf.getInitialWaitTimeout(), initialWaitTimeout);
+ assertEquals(cf.isUseGlobalPools(), useGlobalPools);
+ assertEquals(cf.getScheduledThreadPoolMaxSize(), scheduledThreadPoolMaxSize);
+ assertEquals(cf.getThreadPoolMaxSize(), threadPoolMaxSize);
+ assertEquals(cf.getRetryInterval(), retryInterval);
+ assertEquals(cf.getRetryIntervalMultiplier(), retryIntervalMultiplier);
+ assertEquals(cf.getReconnectAttempts(), reconnectAttempts);
+ assertEquals(cf.isFailoverOnServerShutdown(), failoverOnServerShutdown);
}
private void stopLiveAndBackup() throws Exception
@@ -637,8 +828,8 @@
backupConf.setClustered(true);
backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
backupConf.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory",
- backupParams));
+ .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory",
+ backupParams));
backupConf.setBackup(true);
backupService = Messaging.newMessagingServer(backupConf, false);
backupService.start();
@@ -647,7 +838,7 @@
liveConf.setSecurityEnabled(false);
liveTC = new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory");
liveConf.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory"));
+ .add(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory"));
Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
backupTC = new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
backupParams);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionSendAcknowledgementHandlerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionSendAcknowledgementHandlerTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionSendAcknowledgementHandlerTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -78,11 +78,11 @@
public void testSendAcknowledgements() throws Exception
{
ClientSessionFactory csf = createInVMFactory();
+
+ csf.setProducerWindowSize(1024);
ClientSession session = csf.createSession(null, null, false, true, true, false, 1);
-
- csf.setProducerWindowSize(1024);
-
+
session.createQueue(address, queueName, false);
ClientProducer prod = session.createProducer(address);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionStopStartTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionStopStartTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/ClientSessionStopStartTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -549,15 +549,25 @@
assertNull(consumer.getLastException());
session.close();
}
+
+ private int getMessageEncodeSize(final SimpleString address) throws Exception
+ {
+ ClientSessionFactory cf = createInVMFactory();
+ ClientSession session = cf.createSession(false, true, true);
+ ClientMessage message = session.createClientMessage(false);
+ // we need to set the destination so we can calculate the encodesize correctly
+ message.setDestination(address);
+ int encodeSize = message.getEncodeSize();
+ session.close();
+ cf.close();
+ return encodeSize;
+ }
public void testStopStartMultipleConsumers() throws Exception
{
ClientSessionFactory sf = createInVMFactory();
- ClientSession tempSess = sf.createSession(false, true, true);
- ClientMessage tempMessage = tempSess.createClientMessage(false);
- tempMessage.setDestination(QUEUE);
- int size = tempMessage.getEncodeSize();
- sf.setConsumerWindowSize(size * 33);
+ sf.setConsumerWindowSize(this.getMessageEncodeSize(QUEUE) * 33);
+
final ClientSession session = sf.createSession(false, true, true);
session.createQueue(QUEUE, QUEUE, null, false);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/ConsumerWindowSizeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/ConsumerWindowSizeTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/ConsumerWindowSizeTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -52,6 +52,19 @@
private static final boolean isTrace = log.isTraceEnabled();
+ private int getMessageEncodeSize(final SimpleString address) throws Exception
+ {
+ ClientSessionFactory cf = createInVMFactory();
+ ClientSession session = cf.createSession(false, true, true);
+ ClientMessage message = session.createClientMessage(false);
+ // we need to set the destination so we can calculate the encodesize correctly
+ message.setDestination(address);
+ int encodeSize = message.getEncodeSize();
+ session.close();
+ cf.close();
+ return encodeSize;
+ }
+
/*
* tests send window size. we do this by having 2 receivers on the q. since we roundrobin the consumer for delivery we
* know if consumer 1 has received n messages then consumer 2 must have also have received n messages or at least up
@@ -65,15 +78,13 @@
{
messagingService.start();
cf.setBlockOnNonPersistentSend(false);
+ int numMessage = 100;
+ cf.setConsumerWindowSize(numMessage * this.getMessageEncodeSize(addressA));
ClientSession sendSession = cf.createSession(false, true, true);
ClientSession receiveSession = cf.createSession(false, true, true);
sendSession.createQueue(addressA, queueA, false);
ClientConsumer receivingConsumer = receiveSession.createConsumer(queueA);
- ClientMessage cm = sendSession.createClientMessage(false);
- cm.setDestination(addressA);
- int encodeSize = cm.getEncodeSize();
- int numMessage = 100;
- cf.setConsumerWindowSize(numMessage * encodeSize);
+
ClientSession session = cf.createSession(false, true, true);
ClientProducer cp = sendSession.createProducer(addressA);
ClientConsumer cc = session.createConsumer(queueA);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/client/TemporaryQueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/client/TemporaryQueueTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/client/TemporaryQueueTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,11 @@
package org.jboss.messaging.tests.integration.client;
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import org.jboss.messaging.core.client.ClientConsumer;
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientProducer;
@@ -32,18 +37,15 @@
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.CloseListener;
import org.jboss.messaging.core.remoting.RemotingConnection;
import org.jboss.messaging.core.remoting.impl.RemotingConnectionImpl;
import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
import org.jboss.messaging.core.server.MessagingServer;
-import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
import org.jboss.messaging.tests.util.ServiceTestBase;
import org.jboss.messaging.utils.SimpleString;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
/**
* A TemporaryQueueTest
*
@@ -51,8 +53,9 @@
*/
public class TemporaryQueueTest extends ServiceTestBase
{
-
// Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(TemporaryQueueTest.class);
private static final long CONNECTION_TTL = 2000;
@@ -237,31 +240,11 @@
server = createServer(false, configuration );
server.start();
- sf = new ClientSessionFactoryImpl(new TransportConfiguration(INVM_CONNECTOR_FACTORY),
- null,
- ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
- CONNECTION_TTL,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
- ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS);
+ sf = new ClientSessionFactoryImpl(new TransportConfiguration(INVM_CONNECTOR_FACTORY));
+ sf.setConnectionTTL(CONNECTION_TTL);
session = sf.createSession(false, true, true);
}
-
+
@Override
protected void tearDown() throws Exception
{
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/ClientCrashTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,25 +22,6 @@
package org.jboss.messaging.tests.integration.clientcrash;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
-
import org.jboss.messaging.core.client.ClientConsumer;
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientProducer;
@@ -149,29 +130,10 @@
{
super.setUp();
- sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"),
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- PING_PERIOD,
- CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
-
+ sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"));
+
+ sf.setPingPeriod(PING_PERIOD);
+ sf.setConnectionTTL(CONNECTION_TTL);
}
@Override
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/CrashClient.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/CrashClient.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/clientcrash/CrashClient.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -18,28 +18,10 @@
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
+ */
package org.jboss.messaging.tests.integration.clientcrash;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
import static org.jboss.messaging.tests.integration.clientcrash.ClientCrashTest.QUEUE;
import java.util.Arrays;
@@ -53,7 +35,6 @@
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.jms.client.JBossTextMessage;
-
/**
* Code to be run in an external VM, via main().
*
@@ -77,38 +58,24 @@
try
{
log.debug("args = " + Arrays.asList(args));
-
- ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"),
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- ClientCrashTest.PING_PERIOD,
- ClientCrashTest.CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
+
+ ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory"));
+
+ sf.setPingPeriod(ClientCrashTest.PING_PERIOD);
+ sf.setConnectionTTL(ClientCrashTest.CONNECTION_TTL);
+
ClientSession session = sf.createSession(false, true, true);
ClientProducer producer = session.createProducer(QUEUE);
-
- ClientMessage message = session.createClientMessage(JBossTextMessage.TYPE, false, 0,
- System.currentTimeMillis(), (byte) 1);
+
+ ClientMessage message = session.createClientMessage(JBossTextMessage.TYPE,
+ false,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
message.getBody().writeString(ClientCrashTest.MESSAGE_TEXT_FROM_CLIENT);
producer.send(message);
-
+
// exit without closing the session properly
System.exit(9);
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/ClusterTestBase.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/ClusterTestBase.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -828,8 +828,12 @@
serverBackuptc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams);
}
- ClientSessionFactory sf = new ClientSessionFactoryImpl(serverTotc, serverBackuptc, false, 100, 1d, -1);
-
+ ClientSessionFactory sf = new ClientSessionFactoryImpl(serverTotc, serverBackuptc);
+
+ sf.setFailoverOnServerShutdown(false);
+ sf.setRetryInterval(100);
+ sf.setRetryIntervalMultiplier(1d);
+ sf.setReconnectAttempts(-1);
sf.setBlockOnNonPersistentSend(blocking);
sf.setBlockOnPersistentSend(blocking);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -70,6 +70,8 @@
setupCluster();
startServers();
+
+ log.info("********** started servers");
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
@@ -115,6 +117,8 @@
this.closeAllSessionFactories();
+ log.info("** stopping servers");
+
stopServers(0, 1, 2, 3, 4);
startServers();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ClusterWithBackupFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ClusterWithBackupFailoverTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ClusterWithBackupFailoverTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -132,6 +132,8 @@
verifyReceiveRoundRobinInSomeOrder(10, 0, 1, 2);
stopServers();
+
+ log.info("*** test done");
}
protected void setupCluster() throws Exception
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureListenerOnFailoverTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -169,11 +169,12 @@
final int reconnectAttempts = 10;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
-
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
+
final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
List<MyListener> listeners = new ArrayList<MyListener>();
@@ -270,10 +271,11 @@
final int reconnectAttempts = 10;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
@@ -323,12 +325,13 @@
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- true,
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
-
+ backupParams));
+
+ sf.setFailoverOnServerShutdown(true);
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
+
final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
List<MyListener> listeners = new ArrayList<MyListener>();
@@ -427,11 +430,12 @@
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- true,
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ backupParams));
+
+ sf.setFailoverOnServerShutdown(true);
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
final int numSessions = (int)(ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS * 1.5);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/FailureOnCreateConnectionTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -122,10 +122,11 @@
final int reconnectAttempts = -1;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
InVMConnector.failOnCreateConnection = true;
//One failure only
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/MultiThreadRandomFailoverTestBase.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -1339,13 +1339,10 @@
{
final ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- -1);
-
+ backupParams));
+ sf.setReconnectAttempts(-1);
sf.setProducerWindowSize(32 * 1024);
+
return sf;
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/PagingFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/PagingFailoverTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/PagingFailoverTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -26,7 +26,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
-import org.jboss.beans.info.plugins.SetterAndFieldPropertyInfo;
import org.jboss.messaging.core.client.ClientConsumer;
import org.jboss.messaging.core.client.ClientMessage;
import org.jboss.messaging.core.client.ClientProducer;
@@ -34,6 +33,7 @@
import org.jboss.messaging.core.client.ClientSessionFactory;
import org.jboss.messaging.core.client.impl.ClientSessionImpl;
import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.paging.PagingManager;
import org.jboss.messaging.core.paging.PagingStore;
import org.jboss.messaging.core.remoting.RemotingConnection;
@@ -53,9 +53,10 @@
*/
public class PagingFailoverTest extends FailoverTestBase
{
-
// Constants -----------------------------------------------------
+ private final Logger log = Logger.getLogger(PagingFailoverTest.class);
+
final int RECEIVE_TIMEOUT = 25000;
// Attributes ----------------------------------------------------
@@ -86,7 +87,7 @@
public void testMultithreadFailoverOnProducing() throws Throwable
{
setUpFileBased(getMaxGlobal(), getPageSize());
-
+
int numberOfProducedMessages = multiThreadProducer(getNumberOfThreads(), true);
System.out.println(numberOfProducedMessages + " messages produced");
@@ -94,7 +95,6 @@
int numberOfConsumedMessages = multiThreadConsumer(getNumberOfThreads(), true, false);
assertEquals(numberOfProducedMessages, numberOfConsumedMessages);
-
}
public void testMultithreadFailoverOnConsume() throws Throwable
@@ -440,7 +440,13 @@
ClientSession session = factory.createSession(false, true, true, false);
try
{
- session.createQueue(ADDRESS, ADDRESS, null, true);
+ try
+ {
+ session.createQueue(ADDRESS, ADDRESS, null, true);
+ }
+ catch (Exception e)
+ {
+ }
final CountDownLatch startFlag = new CountDownLatch(1);
final CountDownLatch alignSemaphore = new CountDownLatch(numberOfThreads);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -83,10 +83,11 @@
final int reconnectAttempts = 1;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -159,10 +160,11 @@
final int reconnectAttempts = -1;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -247,10 +249,11 @@
final long asyncFailDelay = 2000;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -368,10 +371,11 @@
final int reconnectAttempts = 3;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -443,10 +447,11 @@
final int reconnectAttempts = 10;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -509,10 +514,11 @@
final int reconnectAttempts = -1;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -599,10 +605,11 @@
final int reconnectAttempts = -1;
- ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReconnectWithBackupTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -91,11 +91,12 @@
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- true,
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ backupParams));
+
+ sf.setFailoverOnServerShutdown(true);
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
@@ -166,11 +167,12 @@
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- true,
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ backupParams));
+
+ sf.setFailoverOnServerShutdown(true);
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
ClientSession session = sf.createSession(false, true, true);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/ReplicateConnectionFailureTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,25 +22,6 @@
package org.jboss.messaging.tests.integration.cluster.failover;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
-
import java.util.HashMap;
import java.util.Map;
@@ -95,29 +76,10 @@
{
final long pingPeriod = 500;
- ClientSessionFactoryInternal sf1 = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- pingPeriod,
- (long)(pingPeriod * 1.5),
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
-
+ ClientSessionFactoryInternal sf1 = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ sf1.setPingPeriod(pingPeriod);
+ sf1.setConnectionTTL((long)(pingPeriod * 1.5));
sf1.setProducerWindowSize(32 * 1024);
assertEquals(0, liveServer.getRemotingService().getConnections().size());
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/failover/SimpleAutomaticFailoverTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -592,11 +592,13 @@
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- true,
- retryInterval,
- retryMultiplier,
- reconnectAttempts);
+ backupParams));
+
+
+ sf.setFailoverOnServerShutdown(true);
+ sf.setRetryInterval(retryInterval);
+ sf.setRetryIntervalMultiplier(retryMultiplier);
+ sf.setReconnectAttempts(reconnectAttempts);
sf.setProducerWindowSize(32 * 1024);
@@ -695,12 +697,13 @@
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- true,
- 100,
- 1,
- -1);
-
+ backupParams));
+
+
+ sf.setFailoverOnServerShutdown(true);
+ sf.setRetryInterval(100);
+ sf.setRetryIntervalMultiplier(1);
+ sf.setReconnectAttempts(-1);
sf.setProducerWindowSize(32 * 1024);
for (int i = 0; i < 10; i++)
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareQueueControlWrapperTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareQueueControlWrapperTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareQueueControlWrapperTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -473,27 +473,9 @@
ClientSessionFactoryInternal sf = new ClientSessionFactoryImpl(new TransportConfiguration(InVMConnectorFactory.class.getName()),
new TransportConfiguration(InVMConnectorFactory.class.getName(),
- backupParams),
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- true,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
+ backupParams));
+ sf.setBlockOnNonPersistentSend(true);
+ sf.setBlockOnPersistentSend(true);
session = sf.createSession(false, true, true);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareTestBase.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/cluster/management/ReplicationAwareTestBase.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -106,6 +106,7 @@
assertTrue(backupMBeanServer != liveMBeanServer);
Configuration backupConf = new ConfigurationImpl();
+ backupConf.setJournalMinFiles(2);
backupConf.setSecurityEnabled(false);
backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
backupConf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName(),
@@ -119,6 +120,7 @@
}
Configuration liveConf = new ConfigurationImpl();
+ liveConf.setJournalMinFiles(2);
liveConf.setSecurityEnabled(false);
liveConf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/http/NettyHttpTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -21,6 +21,13 @@
*/
package org.jboss.messaging.tests.integration.http;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.remoting.impl.AbstractBufferHandler;
import org.jboss.messaging.core.remoting.spi.BufferHandler;
@@ -32,11 +39,6 @@
import org.jboss.messaging.integration.transports.netty.TransportConstants;
import org.jboss.messaging.tests.util.UnitTestCase;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
/**
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
*/
@@ -45,13 +47,37 @@
private NettyAcceptor acceptor;
private NettyConnector connector;
-
- public void testFoo()
+
+ private ExecutorService threadPool;
+
+ @Override
+ protected void setUp() throws Exception
{
+ super.setUp();
+
+ threadPool = Executors.newCachedThreadPool();
}
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ if (connector != null)
+ {
+ connector.close();
+ connector = null;
+ }
+ if (acceptor != null)
+ {
+ acceptor.stop();
+ acceptor = null;
+ }
+
+ threadPool.shutdownNow();
- // Commented out until https://jira.jboss.org/jira/browse/JBMESSAGING-1555 is fixed
+ super.tearDown();
+ }
+
public void testSendAndReceiveAtSameTime() throws Exception
{
@@ -64,11 +90,11 @@
conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
- acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener, threadPool);
acceptor.start();
SimpleBufferHandler2 connectorHandler = new SimpleBufferHandler2(connectorLatch);
- connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null), threadPool);
connector.start();
Connection conn = connector.createConnection();
connCreatedLatch.await(5, TimeUnit.SECONDS);
@@ -114,11 +140,11 @@
conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
- acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener, threadPool);
acceptor.start();
SimpleBufferHandler2 connectorHandler = new SimpleBufferHandler2(connectorLatch);
- connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null), threadPool);
connector.start();
Connection conn = connector.createConnection();
connCreatedLatch.await(5, TimeUnit.SECONDS);
@@ -167,11 +193,11 @@
conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
- acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener, threadPool);
acceptor.start();
SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
- connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null), threadPool);
connector.start();
Connection conn = connector.createConnection();
connCreatedLatch.await(5, TimeUnit.SECONDS);
@@ -221,11 +247,11 @@
conf.put(TransportConstants.HTTP_CLIENT_IDLE_SCAN_PERIOD, -1l);
DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
- acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener, threadPool);
acceptor.start();
SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
- connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null), threadPool);
connector.start();
Connection conn = connector.createConnection();
connCreatedLatch.await(5, TimeUnit.SECONDS);
@@ -274,11 +300,11 @@
conf.put(TransportConstants.HTTP_CLIENT_IDLE_PROP_NAME, 500l);
DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
- acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener, threadPool);
acceptor.start();
SimpleBufferHandler connectorHandler = new SimpleBufferHandler(connectorLatch);
- connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null), threadPool);
connector.start();
Connection conn = connector.createConnection();
connCreatedLatch.await(5, TimeUnit.SECONDS);
@@ -323,11 +349,11 @@
conf.put(TransportConstants.HTTP_SERVER_SCAN_PERIOD_PROP_NAME, 5000l);
DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
SimpleBufferHandler acceptorHandler = new SimpleBufferHandler(acceptorLatch);
- acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener, threadPool);
acceptor.start();
BogusResponseHandler connectorHandler = new BogusResponseHandler(connectorLatch);
- connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null), threadPool);
connector.start();
Connection conn = connector.createConnection();
connCreatedLatch.await(5, TimeUnit.SECONDS);
@@ -365,11 +391,11 @@
conf.put(TransportConstants.HTTP_SERVER_SCAN_PERIOD_PROP_NAME, 5000l);
DummyConnectionLifeCycleListener acceptorListener = new DummyConnectionLifeCycleListener(connCreatedLatch);
SimpleBufferHandler2 acceptorHandler = new SimpleBufferHandler2(acceptorLatch);
- acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener);
+ acceptor = new NettyAcceptor(conf, acceptorHandler, acceptorListener, threadPool);
acceptor.start();
BogusResponseHandler connectorHandler = new BogusResponseHandler(connectorLatch);
- connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null));
+ connector = new NettyConnector(conf, connectorHandler, new DummyConnectionLifeCycleListener(null), threadPool);
connector.start();
Connection conn = connector.createConnection();
connCreatedLatch.await(5, TimeUnit.SECONDS);
@@ -393,23 +419,7 @@
}
}
- @Override
- protected void tearDown() throws Exception
- {
- if (connector != null)
- {
- connector.close();
- connector = null;
- }
- if (acceptor != null)
- {
- acceptor.stop();
- acceptor = null;
- }
- super.tearDown();
- }
-
class SimpleBufferHandler extends AbstractBufferHandler
{
int messagesReceieved = 0;
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTestBase.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/bridge/BridgeTestBase.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -201,33 +201,15 @@
cff0 = new ConnectionFactoryFactory()
{
public ConnectionFactory createConnectionFactory() throws Exception
- {
-
+ {
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()));
+
//Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
- return new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- true,
- true,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- 0,
- false);
+ cf.setReconnectAttempts(0);
+ cf.setBlockOnNonPersistentSend(true);
+ cf.setBlockOnPersistentSend(true);
+
+ return cf;
}
};
@@ -239,31 +221,14 @@
public ConnectionFactory createConnectionFactory() throws Exception
{
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName(), params1));
+
//Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
- return new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName(), params1),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- true,
- true,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- 0,
- false);
+ cf.setReconnectAttempts(0);
+ cf.setBlockOnNonPersistentSend(true);
+ cf.setBlockOnPersistentSend(true);
+
+ return cf;
}
};
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/JMSFailoverTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -109,30 +109,11 @@
{
JBossConnectionFactory jbcf = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
-
+ backupParams));
+
+ jbcf.setBlockOnPersistentSend(true);
+ jbcf.setBlockOnNonPersistentSend(true);
+
Connection conn = jbcf.createConnection();
MyExceptionListener listener = new MyExceptionListener();
@@ -190,56 +171,16 @@
public void testManualFailover() throws Exception
{
- JBossConnectionFactory jbcfLive = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- true,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ JBossConnectionFactory jbcfLive = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+
+ jbcfLive.setBlockOnNonPersistentSend(true);
+ jbcfLive.setBlockOnPersistentSend(true);
+
JBossConnectionFactory jbcfBackup = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory",
- backupParams),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- true,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ backupParams));
+ jbcfBackup.setBlockOnNonPersistentSend(true);
+ jbcfBackup.setBlockOnPersistentSend(true);
Connection connLive = jbcfLive.createConnection();
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSQueueControlWrapperTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSQueueControlWrapperTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/cluster/management/ReplicationAwareJMSQueueControlWrapperTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -32,6 +32,7 @@
import javax.jms.Session;
import javax.jms.TextMessage;
+import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
import org.jboss.messaging.jms.JBossQueue;
import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
@@ -49,6 +50,9 @@
{
// Constants -----------------------------------------------------
+ private static final Logger log = Logger.getLogger(ReplicationAwareJMSQueueControlWrapperTest.class);
+
+
// Attributes ----------------------------------------------------
private JMSServerManagerImpl liveServerManager;
@@ -322,7 +326,7 @@
liveServerManager.createQueue(queueName, queueName);
backupServerManager.createQueue(queueName, queueName);
queue = new JBossQueue(queueName);
-
+
String otherQueueName = randomString();
liveServerManager.createQueue(otherQueueName, otherQueueName);
backupServerManager.createQueue(otherQueueName, otherQueueName);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/connection/ExceptionListenerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/connection/ExceptionListenerTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/connection/ExceptionListenerTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -92,30 +92,9 @@
jmsServer.setContext(new NullInitialContext());
jmsServer.start();
jmsServer.createQueue(Q_NAME, Q_NAME);
- cf = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- true,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ cf = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+ cf.setBlockOnPersistentSend(true);
+ cf.setPreAcknowledge(true);
}
@Override
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/consumer/ConsumerTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -90,30 +90,9 @@
jmsServer.setContext(new NullInitialContext());
jmsServer.start();
jmsServer.createQueue(Q_NAME, Q_NAME);
- cf = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- true,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ cf = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"));
+ cf.setBlockOnPersistentSend(true);
+ cf.setPreAcknowledge(true);
}
@Override
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSQueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSQueueControlTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSQueueControlTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -723,31 +723,10 @@
private Connection createConnection() throws JMSException
{
- JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- DEFAULT_PING_PERIOD,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
-
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()));
+
+ cf.setBlockOnPersistentSend(true);
+
return cf.createConnection();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -30,6 +30,9 @@
import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveLong;
import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
@@ -164,257 +167,265 @@
checkNoResource(ObjectNames.getJMSTopicObjectName(topicName));
}
- public void testCreateConnectionFactory() throws Exception
- {
- String[] cfJNDIBindings = new String[] { randomString(), randomString(), randomString() };
- String cfName = randomString();
+// public void testCreateConnectionFactoryLiveConnector() throws Exception
+// {
+// //String[] cfJNDIBindings = new String[] { randomString(), randomString(), randomString() };
+// List<String> cfJNDIBindings = new ArrayList<String>();
+// cfJNDIBindings.add(randomString());
+// cfJNDIBindings.add(randomString());
+// cfJNDIBindings.add(randomString());
+//
+// String cfName = randomString();
+//
+// for (String cfJNDIBinding : cfJNDIBindings)
+// {
+// checkNoBinding(context, cfJNDIBinding);
+// }
+// checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+//
+// JMSServerControlMBean control = createManagementControl();
+//
+// TransportConfiguration tcLive = new TransportConfiguration(InVMConnectorFactory.class.getName());
+//
+// control.createConnectionFactory(cfName, tcLive, cfJNDIBindings);
+//
+// for (String cfJNDIBinding : cfJNDIBindings)
+// {
+// Object o = checkBinding(context, cfJNDIBinding);
+// assertTrue(o instanceof ConnectionFactory);
+// ConnectionFactory cf = (ConnectionFactory)o;
+// Connection connection = cf.createConnection();
+// connection.close();
+// }
+// checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+// }
+//
+// public void testCreateConnectionFactory_2() throws Exception
+// {
+// String[] cfJNDIBindings = new String[] { randomString(), randomString(), randomString() };
+// String cfName = randomString();
+// boolean preAcknowledge = randomBoolean();
+// boolean blockOnAcknowledge = randomBoolean();
+// boolean blockOnNonPersistentSend = randomBoolean();
+// boolean blockOnPersistentSend = randomBoolean();
+//
+// for (String cfJNDIBinding : cfJNDIBindings)
+// {
+// checkNoBinding(context, cfJNDIBinding);
+// }
+// checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+//
+// JMSServerControlMBean control = createManagementControl();
+// control.createConnectionFactory(cfName,
+// InVMConnectorFactory.class.getName(),
+// blockOnAcknowledge,
+// blockOnNonPersistentSend,
+// blockOnPersistentSend,
+// preAcknowledge,
+// cfJNDIBindings);
+//
+// for (String cfJNDIBinding : cfJNDIBindings)
+// {
+// Object o = checkBinding(context, cfJNDIBinding);
+// assertTrue(o instanceof ConnectionFactory);
+// ConnectionFactory cf = (ConnectionFactory)o;
+// Connection connection = cf.createConnection();
+// connection.close();
+// }
+//
+// checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+// ConnectionFactoryControlMBean cfControl = ManagementControlHelper.createConnectionFactoryControl(cfName,
+// mbeanServer);
+// assertEquals(preAcknowledge, cfControl.isPreAcknowledge());
+// assertEquals(blockOnAcknowledge, cfControl.isBlockOnAcknowledge());
+// assertEquals(blockOnNonPersistentSend, cfControl.isBlockOnNonPersistentSend());
+// assertEquals(blockOnPersistentSend, cfControl.isBlockOnPersistentSend());
+// }
+//
+// public void testCreateConnectionFactory_3() throws Exception
+// {
+// String[] cfJNDIBindings = new String[] {randomString(), randomString(), randomString()} ;
+// String cfName = randomString();
+// long pingPeriod = randomPositiveLong();
+// long connectionTTL = randomPositiveLong();
+// long callTimeout = randomPositiveLong();
+// String clientID = randomString();
+// int dupsOKBatchSize = randomPositiveInt();
+// int transactionBatchSize = randomPositiveInt();
+// int consumerWindowSize = randomPositiveInt();
+// int consumerMaxRate = randomPositiveInt();
+// int producerWindowSize = randomPositiveInt();
+// int producerMaxRate = randomPositiveInt();
+// int minLargeMessageSize = randomPositiveInt();
+// boolean autoGroup = randomBoolean();
+// int maxConnections = randomPositiveInt();
+// long retryInterval = randomPositiveLong();
+// double retryIntervalMultiplier = randomDouble();
+// int reconnectAttempts = randomPositiveInt();
+// boolean failoverOnServerShutdown = randomBoolean();
+// boolean preAcknowledge = randomBoolean();
+// boolean blockOnAcknowledge = randomBoolean();
+// boolean blockOnNonPersistentSend = randomBoolean();
+// boolean blockOnPersistentSend = randomBoolean();
+//
+// for (String cfJNDIBinding : cfJNDIBindings)
+// {
+// checkNoBinding(context, cfJNDIBinding);
+// }
+// checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+//
+// JMSServerControlMBean control = createManagementControl();
+//
+// control.createSimpleConnectionFactory(cfName,
+// InVMConnectorFactory.class.getName(),
+// ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+// pingPeriod,
+// connectionTTL,
+// callTimeout,
+// clientID,
+// dupsOKBatchSize,
+// transactionBatchSize,
+// consumerWindowSize,
+// consumerMaxRate,
+// producerWindowSize,
+// producerMaxRate,
+// minLargeMessageSize,
+// blockOnAcknowledge,
+// blockOnNonPersistentSend,
+// blockOnPersistentSend,
+// autoGroup,
+// maxConnections,
+// preAcknowledge,
+// retryInterval,
+// retryIntervalMultiplier,
+// reconnectAttempts,
+// failoverOnServerShutdown,
+// cfJNDIBindings);
+//
+// for (String cfJNDIBinding : cfJNDIBindings)
+// {
+// Object o = checkBinding(context, cfJNDIBinding);
+// assertTrue(o instanceof ConnectionFactory);
+// ConnectionFactory cf = (ConnectionFactory)o;
+// Connection connection = cf.createConnection();
+// connection.close();
+// }
+//
+// checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+// ConnectionFactoryControlMBean cfControl = ManagementControlHelper.createConnectionFactoryControl(cfName,
+// mbeanServer);
+// assertEquals(cfName, cfControl.getName());
+// assertEquals(pingPeriod, cfControl.getPingPeriod());
+// assertEquals(connectionTTL, cfControl.getConnectionTTL());
+// assertEquals(callTimeout, cfControl.getCallTimeout());
+// assertEquals(clientID, cfControl.getClientID());
+// assertEquals(dupsOKBatchSize, cfControl.getDupsOKBatchSize());
+// assertEquals(transactionBatchSize, cfControl.getTransactionBatchSize());
+// assertEquals(consumerWindowSize, cfControl.getConsumerWindowSize());
+// assertEquals(consumerMaxRate, cfControl.getConsumerMaxRate());
+// assertEquals(producerWindowSize, cfControl.getProducerWindowSize());
+// assertEquals(producerMaxRate, cfControl.getProducerMaxRate());
+// assertEquals(minLargeMessageSize, cfControl.getMinLargeMessageSize());
+// assertEquals(autoGroup, cfControl.isAutoGroup());
+// assertEquals(maxConnections, cfControl.getMaxConnections());
+// assertEquals(retryInterval, cfControl.getRetryInterval());
+// assertEquals(retryIntervalMultiplier, cfControl.getRetryIntervalMultiplier());
+// assertEquals(reconnectAttempts, cfControl.getReconnectAttempts());
+// assertEquals(failoverOnServerShutdown, cfControl.isFailoverOnNodeShutdown());
+// assertEquals(preAcknowledge, cfControl.isPreAcknowledge());
+// assertEquals(blockOnAcknowledge, cfControl.isBlockOnAcknowledge());
+// assertEquals(blockOnNonPersistentSend, cfControl.isBlockOnNonPersistentSend());
+// assertEquals(blockOnPersistentSend, cfControl.isBlockOnPersistentSend());
+// }
+//
+// public void _testCreateConnectionFactoryWithDiscoveryGroup() throws Exception
+// {
+// MessagingServer server = null;
+// try
+// {
+// String[] cfJNDIBindings = new String[] {randomString(), randomString(), randomString()};
+// String cfName = randomString();
+//
+// server = startMessagingServer(8765);
+//
+// for (String cfJNDIBinding : cfJNDIBindings)
+// {
+// checkNoBinding(context, cfJNDIBinding);
+// }
+//
+// JMSServerControlMBean control = createManagementControl();
+// control.createConnectionFactory(cfName,
+// randomString(),
+// "231.7.7.7",
+// 8765,
+// ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
+// ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
+// ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+// ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+// ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
+// ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
+// null,
+// ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+// ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+// ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
+// ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
+// ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
+// ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+// ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+// ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
+// ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
+// ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
+// ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
+// ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
+// ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+// ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
+// ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+// DEFAULT_RECONNECT_ATTEMPTS,
+// DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
+// cfJNDIBindings);
+//
+// for (String cfJNDIBinding : cfJNDIBindings)
+// {
+// Object o = checkBinding(context, cfJNDIBinding);
+// assertTrue(o instanceof ConnectionFactory);
+// ConnectionFactory cf = (ConnectionFactory)o;
+// Connection connection = cf.createConnection();
+// connection.close();
+// }
+// }
+// finally
+// {
+// if (server != null)
+// {
+// server.stop();
+// }
+// }
+// }
+//
+// public void testDestroyConnectionFactory() throws Exception
+// {
+// String cfJNDIBinding = randomString();
+// String cfName = randomString();
+//
+// checkNoBinding(context, cfJNDIBinding);
+// checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+//
+// JMSServerControlMBean control = createManagementControl();
+// control.createConnectionFactory(cfName, InVMConnectorFactory.class.getName(), new String[] {cfJNDIBinding});
+//
+// Object o = checkBinding(context, cfJNDIBinding);
+// assertTrue(o instanceof ConnectionFactory);
+// ConnectionFactory cf = (ConnectionFactory)o;
+// Connection connection = cf.createConnection();
+// connection.close();
+// checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+//
+// control.destroyConnectionFactory(cfName);
+//
+// checkNoBinding(context, cfJNDIBinding);
+// checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
+// }
- for (String cfJNDIBinding : cfJNDIBindings)
- {
- checkNoBinding(context, cfJNDIBinding);
- }
- checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
-
- JMSServerControlMBean control = createManagementControl();
- control.createConnectionFactory(cfName, InVMConnectorFactory.class.getName(), cfJNDIBindings);
-
- for (String cfJNDIBinding : cfJNDIBindings)
- {
- Object o = checkBinding(context, cfJNDIBinding);
- assertTrue(o instanceof ConnectionFactory);
- ConnectionFactory cf = (ConnectionFactory)o;
- Connection connection = cf.createConnection();
- connection.close();
- }
- checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
- }
-
- public void testCreateConnectionFactory_2() throws Exception
- {
- String[] cfJNDIBindings = new String[] { randomString(), randomString(), randomString() };
- String cfName = randomString();
- boolean preAcknowledge = randomBoolean();
- boolean blockOnAcknowledge = randomBoolean();
- boolean blockOnNonPersistentSend = randomBoolean();
- boolean blockOnPersistentSend = randomBoolean();
-
- for (String cfJNDIBinding : cfJNDIBindings)
- {
- checkNoBinding(context, cfJNDIBinding);
- }
- checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
-
- JMSServerControlMBean control = createManagementControl();
- control.createConnectionFactory(cfName,
- InVMConnectorFactory.class.getName(),
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- preAcknowledge,
- cfJNDIBindings);
-
- for (String cfJNDIBinding : cfJNDIBindings)
- {
- Object o = checkBinding(context, cfJNDIBinding);
- assertTrue(o instanceof ConnectionFactory);
- ConnectionFactory cf = (ConnectionFactory)o;
- Connection connection = cf.createConnection();
- connection.close();
- }
-
- checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
- ConnectionFactoryControlMBean cfControl = ManagementControlHelper.createConnectionFactoryControl(cfName,
- mbeanServer);
- assertEquals(preAcknowledge, cfControl.isPreAcknowledge());
- assertEquals(blockOnAcknowledge, cfControl.isBlockOnAcknowledge());
- assertEquals(blockOnNonPersistentSend, cfControl.isBlockOnNonPersistentSend());
- assertEquals(blockOnPersistentSend, cfControl.isBlockOnPersistentSend());
- }
-
- public void testCreateConnectionFactory_3() throws Exception
- {
- String[] cfJNDIBindings = new String[] {randomString(), randomString(), randomString()} ;
- String cfName = randomString();
- long pingPeriod = randomPositiveLong();
- long connectionTTL = randomPositiveLong();
- long callTimeout = randomPositiveLong();
- String clientID = randomString();
- int dupsOKBatchSize = randomPositiveInt();
- int transactionBatchSize = randomPositiveInt();
- int consumerWindowSize = randomPositiveInt();
- int consumerMaxRate = randomPositiveInt();
- int producerWindowSize = randomPositiveInt();
- int producerMaxRate = randomPositiveInt();
- int minLargeMessageSize = randomPositiveInt();
- boolean autoGroup = randomBoolean();
- int maxConnections = randomPositiveInt();
- long retryInterval = randomPositiveLong();
- double retryIntervalMultiplier = randomDouble();
- int reconnectAttempts = randomPositiveInt();
- boolean failoverOnServerShutdown = randomBoolean();
- boolean preAcknowledge = randomBoolean();
- boolean blockOnAcknowledge = randomBoolean();
- boolean blockOnNonPersistentSend = randomBoolean();
- boolean blockOnPersistentSend = randomBoolean();
-
- for (String cfJNDIBinding : cfJNDIBindings)
- {
- checkNoBinding(context, cfJNDIBinding);
- }
- checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
-
- JMSServerControlMBean control = createManagementControl();
-
- control.createSimpleConnectionFactory(cfName,
- InVMConnectorFactory.class.getName(),
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnServerShutdown,
- cfJNDIBindings);
-
- for (String cfJNDIBinding : cfJNDIBindings)
- {
- Object o = checkBinding(context, cfJNDIBinding);
- assertTrue(o instanceof ConnectionFactory);
- ConnectionFactory cf = (ConnectionFactory)o;
- Connection connection = cf.createConnection();
- connection.close();
- }
-
- checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
- ConnectionFactoryControlMBean cfControl = ManagementControlHelper.createConnectionFactoryControl(cfName,
- mbeanServer);
- assertEquals(cfName, cfControl.getName());
- assertEquals(pingPeriod, cfControl.getPingPeriod());
- assertEquals(connectionTTL, cfControl.getConnectionTTL());
- assertEquals(callTimeout, cfControl.getCallTimeout());
- assertEquals(clientID, cfControl.getClientID());
- assertEquals(dupsOKBatchSize, cfControl.getDupsOKBatchSize());
- assertEquals(transactionBatchSize, cfControl.getTransactionBatchSize());
- assertEquals(consumerWindowSize, cfControl.getConsumerWindowSize());
- assertEquals(consumerMaxRate, cfControl.getConsumerMaxRate());
- assertEquals(producerWindowSize, cfControl.getProducerWindowSize());
- assertEquals(producerMaxRate, cfControl.getProducerMaxRate());
- assertEquals(minLargeMessageSize, cfControl.getMinLargeMessageSize());
- assertEquals(autoGroup, cfControl.isAutoGroup());
- assertEquals(maxConnections, cfControl.getMaxConnections());
- assertEquals(retryInterval, cfControl.getRetryInterval());
- assertEquals(retryIntervalMultiplier, cfControl.getRetryIntervalMultiplier());
- assertEquals(reconnectAttempts, cfControl.getReconnectAttempts());
- assertEquals(failoverOnServerShutdown, cfControl.isFailoverOnNodeShutdown());
- assertEquals(preAcknowledge, cfControl.isPreAcknowledge());
- assertEquals(blockOnAcknowledge, cfControl.isBlockOnAcknowledge());
- assertEquals(blockOnNonPersistentSend, cfControl.isBlockOnNonPersistentSend());
- assertEquals(blockOnPersistentSend, cfControl.isBlockOnPersistentSend());
- }
-
- public void _testCreateConnectionFactoryWithDiscoveryGroup() throws Exception
- {
- MessagingServer server = null;
- try
- {
- String[] cfJNDIBindings = new String[] {randomString(), randomString(), randomString()};
- String cfName = randomString();
-
- server = startMessagingServer(8765);
-
- for (String cfJNDIBinding : cfJNDIBindings)
- {
- checkNoBinding(context, cfJNDIBinding);
- }
-
- JMSServerControlMBean control = createManagementControl();
- control.createConnectionFactory(cfName,
- randomString(),
- "231.7.7.7",
- 8765,
- ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
- ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
- ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
- ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
- null,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE,
- ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
- ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
- ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
- ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
- ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- cfJNDIBindings);
-
- for (String cfJNDIBinding : cfJNDIBindings)
- {
- Object o = checkBinding(context, cfJNDIBinding);
- assertTrue(o instanceof ConnectionFactory);
- ConnectionFactory cf = (ConnectionFactory)o;
- Connection connection = cf.createConnection();
- connection.close();
- }
- }
- finally
- {
- if (server != null)
- {
- server.stop();
- }
- }
- }
-
- public void testDestroyConnectionFactory() throws Exception
- {
- String cfJNDIBinding = randomString();
- String cfName = randomString();
-
- checkNoBinding(context, cfJNDIBinding);
- checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
-
- JMSServerControlMBean control = createManagementControl();
- control.createConnectionFactory(cfName, InVMConnectorFactory.class.getName(), new String[] {cfJNDIBinding});
-
- Object o = checkBinding(context, cfJNDIBinding);
- assertTrue(o instanceof ConnectionFactory);
- ConnectionFactory cf = (ConnectionFactory)o;
- Connection connection = cf.createConnection();
- connection.close();
- checkResource(ObjectNames.getConnectionFactoryObjectName(cfName));
-
- control.destroyConnectionFactory(cfName);
-
- checkNoBinding(context, cfJNDIBinding);
- checkNoResource(ObjectNames.getConnectionFactoryObjectName(cfName));
- }
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -88,214 +88,197 @@
protected JMSServerControlMBean createManagementControl() throws Exception
{
JBossQueue managementQueue = new JBossQueue(DEFAULT_MANAGEMENT_ADDRESS.toString(),
- DEFAULT_MANAGEMENT_ADDRESS.toString());
- final JMSMessagingProxy proxy = new JMSMessagingProxy(session,
- managementQueue,
- ResourceNames.JMS_SERVER);
-
+ DEFAULT_MANAGEMENT_ADDRESS.toString());
+ final JMSMessagingProxy proxy = new JMSMessagingProxy(session, managementQueue, ResourceNames.JMS_SERVER);
+
return new JMSServerControlMBean()
{
- public boolean closeConnectionsForAddress(final String ipAddress) throws Exception
+ public void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ List<String> jndiBindings) throws Exception
{
- return (Boolean)proxy.invokeOperation("closeConnectionsForAddress", ipAddress);
+ proxy.invokeOperation("createConnectionFactory", name, connectorConfigs, jndiBindings);
}
- public void createConnectionFactory(final String name,
- final String connectorFactoryClassName,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ List<String> jndiBindings) throws Exception
{
- proxy.invokeOperation("createConnectionFactory", name, connectorFactoryClassName, jndiBindings);
+ proxy.invokeOperation("createConnectionFactory", name, connectorConfigs, clientID, jndiBindings);
}
- public void createConnectionFactory(final String name,
- final String connectorFactoryClassName,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean preAcknowledge,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name,
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ String clientID,
+ long pingPeriod,
+ long connectionTTL,
+ long callTimeout,
+ int maxConnections,
+ int minLargeMessageSize,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
+ int producerMaxRate,
+ boolean blockOnAcknowledge,
+ boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
+ boolean autoGroup,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int reconnectAttempts,
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception
{
proxy.invokeOperation("createConnectionFactory",
- name,
- connectorFactoryClassName,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- preAcknowledge,
- jndiBindings);
+ name,
+ connectorConfigs,
+ clientID,
+ pingPeriod,
+ connectionTTL,
+ callTimeout,
+ maxConnections,
+ minLargeMessageSize,
+ consumerWindowSize,
+ consumerMaxRate,
+ producerWindowSize,
+ producerMaxRate,
+ blockOnAcknowledge,
+ blockOnPersistentSend,
+ blockOnNonPersistentSend,
+ autoGroup,
+ preAcknowledge,
+ loadBalancingPolicyClassName,
+ transactionBatchSize,
+ dupsOKBatchSize,
+ useGlobalPools,
+ scheduledThreadPoolMaxSize,
+ threadPoolMaxSize,
+ retryInterval,
+ retryIntervalMultiplier,
+ reconnectAttempts,
+ failoverOnServerShutdown,
+ jndiBindings);
}
- public void createSimpleConnectionFactory(final String name,
- final String connectorFactoryClassName,
- final String connectionLoadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int producerWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ List<String> jndiBindings) throws Exception
{
- proxy.invokeOperation("createSimpleConnectionFactory",
- name,
- connectorFactoryClassName,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnServerShutdown,
- jndiBindings);
+ proxy.invokeOperation("createConnectionFactory", name, discoveryAddress, clientID, jndiBindings);
}
- public void createConnectionFactory(final String name,
- final List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
- final String connectionLoadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int producerWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name,
+ String discoveryAddress,
+ int discoveryPort,
+ String clientID,
+ long discoveryRefreshTimeout,
+ long pingPeriod,
+ long connectionTTL,
+ long callTimeout,
+ int maxConnections,
+ int minLargeMessageSize,
+ int consumerWindowSize,
+ int consumerMaxRate,
+ int producerWindowSize,
+ int producerMaxRate,
+ boolean blockOnAcknowledge,
+ boolean blockOnPersistentSend,
+ boolean blockOnNonPersistentSend,
+ boolean autoGroup,
+ boolean preAcknowledge,
+ String loadBalancingPolicyClassName,
+ int transactionBatchSize,
+ int dupsOKBatchSize,
+ long initialWaitTimeout,
+ boolean useGlobalPools,
+ int scheduledThreadPoolMaxSize,
+ int threadPoolMaxSize,
+ long retryInterval,
+ double retryIntervalMultiplier,
+ int reconnectAttempts,
+ boolean failoverOnServerShutdown,
+ List<String> jndiBindings) throws Exception
{
proxy.invokeOperation("createConnectionFactory",
- name,
- connectorConfigs,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnServerShutdown,
- jndiBindings);
+ name,
+ discoveryAddress,
+ discoveryPort,
+ clientID,
+ pingPeriod,
+ connectionTTL,
+ callTimeout,
+ maxConnections,
+ minLargeMessageSize,
+ consumerWindowSize,
+ consumerMaxRate,
+ producerWindowSize,
+ producerMaxRate,
+ blockOnAcknowledge,
+ blockOnPersistentSend,
+ blockOnNonPersistentSend,
+ autoGroup,
+ preAcknowledge,
+ loadBalancingPolicyClassName,
+ transactionBatchSize,
+ dupsOKBatchSize,
+ initialWaitTimeout,
+ useGlobalPools,
+ scheduledThreadPoolMaxSize,
+ threadPoolMaxSize,
+ retryInterval,
+ retryIntervalMultiplier,
+ reconnectAttempts,
+ failoverOnServerShutdown,
+ jndiBindings);
+
}
- public void createConnectionFactory(final String name,
- final String discoveryGroupName,
- final String discoveryGroupAddress,
- final int discoveryGroupPort,
- final long discoveryGroupRefreshTimeout,
- final long discoveryInitialWait,
- final String connectionLoadBalancingPolicyClassName,
- final long pingPeriod,
- final long connectionTTL,
- final long callTimeout,
- final String clientID,
- final int dupsOKBatchSize,
- final int transactionBatchSize,
- final int consumerWindowSize,
- final int consumerMaxRate,
- final int producerWindowSize,
- final int producerMaxRate,
- final int minLargeMessageSize,
- final boolean blockOnAcknowledge,
- final boolean blockOnNonPersistentSend,
- final boolean blockOnPersistentSend,
- final boolean autoGroup,
- final int maxConnections,
- final boolean preAcknowledge,
- final long retryInterval,
- final double retryIntervalMultiplier,
- final int reconnectAttempts,
- final boolean failoverOnServerShutdown,
- final String[] jndiBindings) throws Exception
+ public void createConnectionFactory(String name, TransportConfiguration liveTC, List<String> jndiBindings) throws Exception
{
- proxy.invokeOperation("createConnectionFactory",
- name,
- discoveryGroupName,
- discoveryGroupAddress,
- discoveryGroupPort,
- discoveryGroupRefreshTimeout,
- discoveryInitialWait,
- connectionLoadBalancingPolicyClassName,
- pingPeriod,
- connectionTTL,
- callTimeout,
- clientID,
- dupsOKBatchSize,
- transactionBatchSize,
- consumerWindowSize,
- consumerMaxRate,
- producerWindowSize,
- producerMaxRate,
- minLargeMessageSize,
- blockOnAcknowledge,
- blockOnNonPersistentSend,
- blockOnPersistentSend,
- autoGroup,
- maxConnections,
- preAcknowledge,
- retryInterval,
- retryIntervalMultiplier,
- reconnectAttempts,
- failoverOnServerShutdown,
- jndiBindings);
+ proxy.invokeOperation("createConnectionFactory", name, liveTC, jndiBindings);
}
+ public void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ proxy.invokeOperation("createConnectionFactory", name, liveTC, clientID, jndiBindings);
+ }
+
+ public void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ List<String> jndiBindings) throws Exception
+ {
+ proxy.invokeOperation("createConnectionFactory", name, liveTC, backupTC, jndiBindings);
+ }
+
+ public void createConnectionFactory(String name,
+ TransportConfiguration liveTC,
+ TransportConfiguration backupTC,
+ String clientID,
+ List<String> jndiBindings) throws Exception
+ {
+ proxy.invokeOperation("createConnectionFactory", name, liveTC, clientID, backupTC, jndiBindings);
+ }
+
+ public boolean closeConnectionsForAddress(final String ipAddress) throws Exception
+ {
+ return (Boolean)proxy.invokeOperation("closeConnectionsForAddress", ipAddress);
+ }
+
public boolean createQueue(final String name, final String jndiBinding) throws Exception
{
return (Boolean)proxy.invokeOperation("createQueue", name, jndiBinding);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSUtil.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSUtil.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/JMSUtil.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,24 +22,6 @@
package org.jboss.messaging.tests.integration.jms.server.management;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PING_PERIOD;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
import static org.jboss.messaging.tests.util.RandomUtil.randomString;
import javax.jms.Connection;
@@ -79,39 +61,26 @@
public static Connection createConnection(String connectorFactory) throws JMSException
{
- return createConnection(connectorFactory, DEFAULT_CONNECTION_TTL, DEFAULT_PING_PERIOD);
- }
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(connectorFactory));
+
+ cf.setBlockOnNonPersistentSend(true);
+ cf.setBlockOnPersistentSend(true);
+ return cf.createConnection();
+ }
+
public static Connection createConnection(String connectorFactory, long connectionTTL, long pingPeriod) throws JMSException
{
- JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(connectorFactory),
- null,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- pingPeriod,
- connectionTTL,
- DEFAULT_CALL_TIMEOUT,
- null,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- true,
- true,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN);
+ JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(connectorFactory));
+
+ cf.setBlockOnNonPersistentSend(true);
+ cf.setBlockOnPersistentSend(true);
+ cf.setConnectionTTL(connectionTTL);
+ cf.setPingPeriod(pingPeriod);
return cf.createConnection();
}
-
+
static MessageConsumer createConsumer(Connection connection, Destination destination, String connectorFactory) throws JMSException
{
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -121,12 +90,13 @@
public static MessageConsumer createConsumer(Connection connection, Destination destination) throws JMSException
{
- return createConsumer(connection,
- destination,
- InVMConnectorFactory.class.getName());
+ return createConsumer(connection, destination, InVMConnectorFactory.class.getName());
}
- static TopicSubscriber createDurableSubscriber(Connection connection, Topic topic, String clientID, String subscriptionName) throws JMSException
+ static TopicSubscriber createDurableSubscriber(Connection connection,
+ Topic topic,
+ String clientID,
+ String subscriptionName) throws JMSException
{
connection.setClientID(clientID);
Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -139,7 +109,7 @@
JBossConnectionFactory cf = new JBossConnectionFactory(new TransportConfiguration(InVMConnectorFactory.class.getName()));
return sendMessages(cf, destination, messagesToSend);
}
-
+
public static String[] sendMessages(ConnectionFactory cf, Destination destination, int messagesToSend) throws Exception
{
String[] messageIDs = new String[messagesToSend];
@@ -155,7 +125,7 @@
producer.send(m);
messageIDs[i] = m.getJMSMessageID();
}
-
+
conn.close();
return messageIDs;
@@ -173,7 +143,8 @@
public static void consumeMessages(int expected, Destination dest) throws JMSException
{
Connection connection = createConnection(InVMConnectorFactory.class.getName());
- try{
+ try
+ {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(dest);
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/NullInitialContext.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/NullInitialContext.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/server/management/NullInitialContext.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -24,6 +24,7 @@
package org.jboss.messaging.tests.integration.jms.server.management;
import javax.naming.InitialContext;
+import javax.naming.Name;
import javax.naming.NamingException;
/**
@@ -38,35 +39,32 @@
public class NullInitialContext extends InitialContext
{
- public NullInitialContext() throws NamingException
+ @Override
+ public Object lookup(Name name) throws NamingException
+ {
+ return null;
+ }
+
+ @Override
+ public Object lookup(String name) throws NamingException
{
- super();
+ return null;
}
- // Constants -----------------------------------------------------
+ @Override
+ public void rebind(Name name, Object obj) throws NamingException
+ {
+ }
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // InitialContext overrides --------------------------------------
-
@Override
public void rebind(String name, Object obj) throws NamingException
{
- // do nothing
}
- // Public --------------------------------------------------------
+ public NullInitialContext() throws NamingException
+ {
+ super();
+ }
+
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/largemessage/mock/MockConnector.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/largemessage/mock/MockConnector.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/largemessage/mock/MockConnector.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -23,6 +23,8 @@
package org.jboss.messaging.tests.integration.largemessage.mock;
import java.util.Map;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
import org.jboss.messaging.core.remoting.impl.invm.InVMConnection;
import org.jboss.messaging.core.remoting.impl.invm.InVMConnector;
@@ -53,7 +55,7 @@
final BufferHandler handler,
final ConnectionLifeCycleListener listener)
{
- super(configuration, handler, listener);
+ super(configuration, handler, listener, Executors.newCachedThreadPool());
callback = (MockCallback)configuration.get("callback");
}
@@ -72,7 +74,8 @@
// Protected -----------------------------------------------------
@Override
- protected Connection internalCreateConnection(final BufferHandler handler, final ConnectionLifeCycleListener listener)
+ protected Connection internalCreateConnection(final BufferHandler handler, final ConnectionLifeCycleListener listener,
+ final Executor serverExecutor)
{
return new MockConnection(id, handler, listener);
}
@@ -94,7 +97,7 @@
*/
public MockConnection(final int serverID, final BufferHandler handler, final ConnectionLifeCycleListener listener)
{
- super(serverID, handler, listener);
+ super(serverID, handler, listener, Executors.newSingleThreadExecutor());
}
@Override
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/largemessage/mock/MockConnectorFactory.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/largemessage/mock/MockConnectorFactory.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/largemessage/mock/MockConnectorFactory.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -23,6 +23,7 @@
package org.jboss.messaging.tests.integration.largemessage.mock;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.BufferHandler;
import org.jboss.messaging.core.remoting.spi.ConnectionLifeCycleListener;
@@ -55,7 +56,8 @@
*/
public Connector createConnector(final Map<String, Object> configuration,
final BufferHandler handler,
- final ConnectionLifeCycleListener listener)
+ final ConnectionLifeCycleListener listener,
+ final Executor executor)
{
return new MockConnector(configuration, handler, listener);
}
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/remoting/PingTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -127,29 +127,10 @@
{
TransportConfiguration transportConfig = new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory");
- ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig,
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- PING_INTERVAL,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
-
+ ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig);
+
+ csf.setPingPeriod(PING_INTERVAL);
+
ClientSession session = csf.createSession(false, true, true);
assertEquals(1, ((ClientSessionFactoryInternal)csf).numConnections());
@@ -202,28 +183,9 @@
{
TransportConfiguration transportConfig = new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory");
- ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig,
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- PING_INTERVAL,
- DEFAULT_CONNECTION_TTL,
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
+ ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig);
+
+ csf.setPingPeriod(PING_INTERVAL);
ClientSession session = csf.createSession(false, true, true);
@@ -277,29 +239,11 @@
{
TransportConfiguration transportConfig = new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory");
- ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig,
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- PING_INTERVAL,
- (long)(PING_INTERVAL * 1.5),
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
-
+ ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig);
+
+ csf.setPingPeriod(PING_INTERVAL);
+ csf.setConnectionTTL((long)(PING_INTERVAL * 1.5));
+
Listener clientListener = new Listener();
ClientSession session = csf.createSession(false, true, true);
@@ -396,28 +340,10 @@
TransportConfiguration transportConfig = new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory");
- ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig,
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- PING_INTERVAL,
- (long)(PING_INTERVAL * 1.5),
- DEFAULT_CALL_TIMEOUT,
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
+ ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig);
+
+ csf.setPingPeriod(PING_INTERVAL);
+ csf.setConnectionTTL((long)(PING_INTERVAL * 1.5));
ClientSession session = csf.createSession(false, true, true);
Modified: trunk/tests/src/org/jboss/messaging/tests/stress/remote/PingStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/stress/remote/PingStressTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/stress/remote/PingStressTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,24 +22,6 @@
package org.jboss.messaging.tests.stress.remote;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RECONNECT_ATTEMPTS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER;
-import static org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
-
import java.util.concurrent.CountDownLatch;
import org.jboss.messaging.core.client.ClientSession;
@@ -147,30 +129,12 @@
server.getRemotingService().addInterceptor(noPongInterceptor);
- final ClientSessionFactory csf1 = new ClientSessionFactoryImpl(transportConfig,
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- PING_INTERVAL,
- (long)(PING_INTERVAL * 1.5),
- PING_INTERVAL * 10, // Using a smaller call
- // timeout
- // for this test
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
+ final ClientSessionFactory csf1 = new ClientSessionFactoryImpl(transportConfig);
+
+ csf1.setPingPeriod(PING_INTERVAL);
+ csf1.setConnectionTTL((long)(PING_INTERVAL * 1.5));
+ csf1.setCallTimeout(PING_INTERVAL * 10);
+
final int numberOfSessions = 1;
final int numberOfThreads = 30;
@@ -196,31 +160,11 @@
try
{
- final ClientSessionFactory csf2 = new ClientSessionFactoryImpl(transportConfig,
- null,
- DEFAULT_FAILOVER_ON_SERVER_SHUTDOWN,
- DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
- PING_INTERVAL,
- (long)(PING_INTERVAL * 1.5),
- PING_INTERVAL * 10, // Using a smaller
- // call
- // timeout for this
- // test
- DEFAULT_CONSUMER_WINDOW_SIZE,
- DEFAULT_CONSUMER_MAX_RATE,
- DEFAULT_PRODUCER_WINDOW_SIZE,
- DEFAULT_PRODUCER_MAX_RATE,
- DEFAULT_MIN_LARGE_MESSAGE_SIZE,
- DEFAULT_BLOCK_ON_ACKNOWLEDGE,
- DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
- DEFAULT_BLOCK_ON_PERSISTENT_SEND,
- DEFAULT_AUTO_GROUP,
- DEFAULT_MAX_CONNECTIONS,
- DEFAULT_PRE_ACKNOWLEDGE,
- DEFAULT_ACK_BATCH_SIZE,
- DEFAULT_RETRY_INTERVAL,
- DEFAULT_RETRY_INTERVAL_MULTIPLIER,
- DEFAULT_RECONNECT_ATTEMPTS);
+ final ClientSessionFactory csf2 = new ClientSessionFactoryImpl(transportConfig);
+
+ csf2.setPingPeriod(PING_INTERVAL);
+ csf2.setConnectionTTL((long)(PING_INTERVAL * 1.5));
+ csf2.setCallTimeout(PING_INTERVAL * 10);
// Start all at once to make concurrency worst
flagAligned.countDown();
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory1.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory1.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory1.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,7 @@
package org.jboss.messaging.tests.unit.core.remoting.impl;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -39,7 +40,7 @@
{
public Acceptor createAcceptor(Map<String, Object> params,
- BufferHandler handler, ConnectionLifeCycleListener listener)
+ BufferHandler handler, ConnectionLifeCycleListener listener, Executor threadPool)
{
return new Acceptor1();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory2.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory2.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory2.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,7 @@
package org.jboss.messaging.tests.unit.core.remoting.impl;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -39,7 +40,7 @@
{
public Acceptor createAcceptor(Map<String, Object> params,
- BufferHandler handler, ConnectionLifeCycleListener listener)
+ BufferHandler handler, ConnectionLifeCycleListener listener, Executor threadPool)
{
return new Acceptor2();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory3.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory3.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/AcceptorFactory3.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,7 @@
package org.jboss.messaging.tests.unit.core.remoting.impl;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -39,7 +40,7 @@
{
public Acceptor createAcceptor(Map<String, Object> params,
- BufferHandler handler, ConnectionLifeCycleListener listener)
+ BufferHandler handler, ConnectionLifeCycleListener listener, Executor threadPool)
{
return new Acceptor3();
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory1.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory1.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory1.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,7 @@
package org.jboss.messaging.tests.unit.core.remoting.impl;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -39,7 +40,7 @@
public static volatile Acceptor acceptor;
public Acceptor createAcceptor(Map<String, Object> configuration,
- BufferHandler handler, ConnectionLifeCycleListener listener)
+ BufferHandler handler, ConnectionLifeCycleListener listener, Executor threadPool)
{
return acceptor;
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory2.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory2.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory2.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,7 @@
package org.jboss.messaging.tests.unit.core.remoting.impl;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -39,7 +40,7 @@
public static volatile Acceptor acceptor;
public Acceptor createAcceptor(Map<String, Object> configuration,
- BufferHandler handler, ConnectionLifeCycleListener listener)
+ BufferHandler handler, ConnectionLifeCycleListener listener, Executor threadPool)
{
return acceptor;
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory3.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory3.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory3.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,7 @@
package org.jboss.messaging.tests.unit.core.remoting.impl;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -39,7 +40,7 @@
public static volatile Acceptor acceptor;
public Acceptor createAcceptor(Map<String, Object> configuration,
- BufferHandler handler, ConnectionLifeCycleListener listener)
+ BufferHandler handler, ConnectionLifeCycleListener listener, Executor threadPool)
{
return acceptor;
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory4.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory4.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/TestAcceptorFactory4.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -22,6 +22,7 @@
package org.jboss.messaging.tests.unit.core.remoting.impl;
import java.util.Map;
+import java.util.concurrent.Executor;
import org.jboss.messaging.core.remoting.spi.Acceptor;
import org.jboss.messaging.core.remoting.spi.AcceptorFactory;
@@ -39,7 +40,7 @@
public static volatile Acceptor acceptor;
public Acceptor createAcceptor(Map<String, Object> configuration,
- BufferHandler handler, ConnectionLifeCycleListener listener)
+ BufferHandler handler, ConnectionLifeCycleListener listener, Executor threadPool)
{
return acceptor;
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyAcceptorFactoryTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -23,6 +23,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.Executors;
import org.easymock.EasyMock;
import org.jboss.messaging.core.remoting.spi.Acceptor;
@@ -48,9 +49,9 @@
Map<String, Object> params = new HashMap<String, Object>();
BufferHandler handler = EasyMock.createStrictMock(BufferHandler.class);
ConnectionLifeCycleListener listener = EasyMock.createStrictMock(ConnectionLifeCycleListener.class);
+
+ Acceptor acceptor = factory.createAcceptor(params, handler, listener, Executors.newCachedThreadPool());
- Acceptor acceptor = factory.createAcceptor(params, handler, listener);
-
assertTrue(acceptor instanceof NettyAcceptor);
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyAcceptorTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.Executors;
import org.easymock.EasyMock;
import org.jboss.messaging.core.remoting.spi.BufferHandler;
@@ -45,7 +46,7 @@
BufferHandler handler = EasyMock.createStrictMock(BufferHandler.class);
Map<String, Object> params = new HashMap<String, Object>();
ConnectionLifeCycleListener listener = EasyMock.createStrictMock(ConnectionLifeCycleListener.class);
- NettyAcceptor acceptor = new NettyAcceptor(params, handler, listener);
+ NettyAcceptor acceptor = new NettyAcceptor(params, handler, listener, Executors.newCachedThreadPool());
acceptor.start();
acceptor.pause();
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java 2009-05-01 15:56:58 UTC (rev 6645)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/netty/NettyConnectorTest.java 2009-05-01 17:43:25 UTC (rev 6646)
@@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.Executors;
import org.easymock.EasyMock;
import org.jboss.messaging.core.remoting.spi.BufferHandler;
@@ -56,7 +57,7 @@
Map<String, Object> params = new HashMap<String, Object>();
ConnectionLifeCycleListener listener = EasyMock.createStrictMock(ConnectionLifeCycleListener.class);
- NettyConnector connector = new NettyConnector(params, handler, listener);
+ NettyConnector connector = new NettyConnector(params, handler, listener, Executors.newCachedThreadPool());
connector.start();
connector.close();
@@ -70,7 +71,7 @@
try
{
- new NettyConnector(params, null, listener);
+ new NettyConnector(params, null, listener, Executors.newCachedThreadPool());
fail("Should throw Exception");
}
@@ -81,7 +82,7 @@
try
{
- new NettyConnector(params, handler, null);
+ new NettyConnector(params, handler, null, Executors.newCachedThreadPool());
fail("Should throw Exception");
}
More information about the jboss-cvs-commits
mailing list