[jboss-cvs] JBoss Messaging SVN: r1973 - in trunk: src/etc/xmdesc and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 17 17:29:52 EST 2007
Author: timfox
Date: 2007-01-17 17:29:52 -0500 (Wed, 17 Jan 2007)
New Revision: 1973
Removed:
trunk/src/main/org/jboss/jms/client/ClientAOPStackProvider.java
trunk/src/main/org/jboss/jms/server/endpoint/advised/ClientAOPStackProviderAdvised.java
Modified:
trunk/src/etc/prepare-aop.xml
trunk/src/etc/xmdesc/Bridge-xmbean.xml
trunk/src/main/org/jboss/jms/client/ClientAOPStackLoader.java
trunk/src/main/org/jboss/jms/client/container/ClosedInterceptor.java
trunk/src/main/org/jboss/jms/client/container/ExceptionInterceptor.java
trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryDelegate.java
trunk/src/main/org/jboss/jms/server/ServerPeer.java
trunk/src/main/org/jboss/jms/server/bridge/Bridge.java
trunk/src/main/org/jboss/jms/server/bridge/BridgeMBean.java
trunk/src/main/org/jboss/jms/server/bridge/BridgeService.java
trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/advised/ConnectionFactoryAdvised.java
trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java
trunk/tests/etc/log4j.xml
trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java
trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java
trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
Log:
More bridge work
Modified: trunk/src/etc/prepare-aop.xml
===================================================================
--- trunk/src/etc/prepare-aop.xml 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/etc/prepare-aop.xml 2007-01-17 22:29:52 UTC (rev 1973)
@@ -15,7 +15,7 @@
<prepare expr="execution(* org.jboss.jms.client.delegate.ClientBrowserDelegate->$implementing{org.jboss.jms.delegate.BrowserDelegate}(..))"/>
<!-- Prepare the server delegate classes - these provide the server side advice stack -->
- <prepare expr="execution(* org.jboss.jms.server.endpoint.advised.ClientAOPStackProviderAdvised->$implementing{org.jboss.jms.client.ClientAOPStackProvider}(..))"/>
+
<prepare expr="execution(* org.jboss.jms.server.endpoint.advised.ConnectionFactoryAdvised->$implementing{org.jboss.jms.server.endpoint.ConnectionFactoryEndpoint}(..))"/>
<prepare expr="execution(* org.jboss.jms.server.endpoint.advised.ConnectionAdvised->$implementing{org.jboss.jms.server.endpoint.ConnectionEndpoint}(..))"/>
<prepare expr="execution(* org.jboss.jms.server.endpoint.advised.SessionAdvised->$implementing{org.jboss.jms.server.endpoint.SessionEndpoint}(..))"/>
Modified: trunk/src/etc/xmdesc/Bridge-xmbean.xml
===================================================================
--- trunk/src/etc/xmdesc/Bridge-xmbean.xml 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/etc/xmdesc/Bridge-xmbean.xml 2007-01-17 22:29:52 UTC (rev 1973)
@@ -24,13 +24,27 @@
<type>java.lang.String</type>
</attribute>
- <attribute access="read-write" getMethod="getDestConnectionFactoryLookup"
- setMethod="setDestConnectionFactoryLookup">
- <description>The destination connection factory lookup</description>
- <name>DestConnectionFactoryLookup</name>
+ <attribute access="read-write" getMethod="getTargetConnectionFactoryLookup"
+ setMethod="setTargetConnectionFactoryLookup">
+ <description>The target connection factory lookup</description>
+ <name>TargetConnectionFactoryLookup</name>
<type>java.lang.String</type>
</attribute>
+ <attribute access="read-write" getMethod="getSourceDestinationLookup"
+ setMethod="setSourceDestinationLookup">
+ <description>The source destination lookup</description>
+ <name>SourceDestinationLookup</name>
+ <type>java.lang.String</type>
+ </attribute>
+
+ <attribute access="read-write" getMethod="getTargetDestinationLookup"
+ setMethod="setTargetDestinationLookup">
+ <description>The target destination lookup</description>
+ <name>TargetDestinationLookup</name>
+ <type>java.lang.String</type>
+ </attribute>
+
<attribute access="read-write" getMethod="getSourceUsername"
setMethod="setSourceUsername">
<description>The source username</description>
@@ -45,17 +59,24 @@
<type>java.lang.String</type>
</attribute>
- <attribute access="read-write" getMethod="getDestUsername"
- setMethod="setDestUsername">
- <description>The destination username</description>
- <name>DestUsername</name>
+ <attribute access="read-write" getMethod="getTargetUsername"
+ setMethod="setTargetUsername">
+ <description>The target username</description>
+ <name>TargetUsername</name>
<type>java.lang.String</type>
</attribute>
+ <attribute access="read-write" getMethod="getTargetPassword"
+ setMethod="setTargetPassword">
+ <description>The target password</description>
+ <name>TargetPassword</name>
+ <type>java.lang.String</type>
+ </attribute>
+
<attribute access="read-write" getMethod="getQualityOfServiceMode"
setMethod="setQualityOfServiceMode">
<description>The quality of service mode. 0 = at most once. 1 = duplicates ok, 2 = once and only once</description>
- <name>QualitOfServiceMode</name>
+ <name>QualityOfServiceMode</name>
<type>int</type>
</attribute>
@@ -77,7 +98,7 @@
setMethod="setMaxBatchTime">
<description>Number of milliseconds to wait after no messages arrive to forward batch of messages</description>
<name>MaxBatchTime</name>
- <type>int</type>
+ <type>long</type>
</attribute>
<attribute access="read-write" getMethod="getSubName"
@@ -120,15 +141,21 @@
<type>boolean</type>
</attribute>
- <attribute access="read-write" getMethod="getSourceJNDIProperties" setMethod="setSourceJNDIProperties>
+ <attribute access="read-only" getMethod="isStarted">
+ <description>Is the bridge started?</description>
+ <name>Started</name>
+ <type>boolean</type>
+ </attribute>
+
+ <attribute access="read-write" getMethod="getSourceJNDIProperties" setMethod="setSourceJNDIProperties">
<description>The JNDI properties to use to lookup the source destination, or null if a local JNDI initial context should be used</description>
<name>SourceJNDIProperties</name>
<type>java.lang.String</type>
</attribute>
- <attribute access="read-write" getMethod="getDestNDIProperties" setMethod="setDestJNDIProperties>
- <description>The JNDI properties to use to lookup the destination destination, or null if a local JNDI initial context should be used</description>
- <name>DestJNDIProperties</name>
+ <attribute access="read-write" getMethod="getTargetJNDIProperties" setMethod="setTargetJNDIProperties">
+ <description>The JNDI properties to use to lookup the target destination, or null if a local JNDI initial context should be used</description>
+ <name>TargetJNDIProperties</name>
<type>java.lang.String</type>
</attribute>
@@ -153,5 +180,15 @@
<description>JBoss Service lifecycle operation</description>
<name>destroy</name>
</operation>
+
+ <operation>
+ <description>Pause the bridge</description>
+ <name>pause</name>
+ </operation>
+
+ <operation>
+ <description>Resume the bridge</description>
+ <name>resume</name>
+ </operation>
</mbean>
\ No newline at end of file
Modified: trunk/src/main/org/jboss/jms/client/ClientAOPStackLoader.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/ClientAOPStackLoader.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/client/ClientAOPStackLoader.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -7,6 +7,7 @@
package org.jboss.jms.client;
import org.jboss.jms.client.container.JmsClientAspectXMLLoader;
+import org.jboss.jms.server.endpoint.ConnectionFactoryEndpoint;
/**
* A static singleton that insures the client-side AOP stack is loaded.
@@ -56,7 +57,7 @@
* @throws Exception - if something goes wrong with downloading the AOP configuration from the
* server and installing it.
*/
- public synchronized void load(ClientAOPStackProvider delegate) throws Exception
+ public synchronized void load(ConnectionFactoryEndpoint delegate) throws Exception
{
if (loaded)
{
Deleted: trunk/src/main/org/jboss/jms/client/ClientAOPStackProvider.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/ClientAOPStackProvider.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/client/ClientAOPStackProvider.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -1,23 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.client;
-
-/**
- * An interface implemented by an object that can provide a client-side AOP stack configuration.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface ClientAOPStackProvider
-{
- /**
- * @return the AOP stack as byte[]. Use JmsClientAspectXMLLoader to deploy it on the client.
- */
- byte[] getClientAOPStack();
-}
Modified: trunk/src/main/org/jboss/jms/client/container/ClosedInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ClosedInterceptor.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/client/container/ClosedInterceptor.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -295,10 +295,12 @@
del.closing();
del.close();
}
- catch (Throwable ignored)
+ catch (Throwable t)
{
- // Add a log interceptor to the child if you want the error
- // ignored.printStackTrace();
+ if (trace)
+ {
+ log.trace("Failed to close", t);
+ }
}
}
Modified: trunk/src/main/org/jboss/jms/client/container/ExceptionInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ExceptionInterceptor.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/client/container/ExceptionInterceptor.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -46,6 +46,8 @@
// Constants ------------------------------------------------------------------------------------
private static final Logger log = Logger.getLogger(ExceptionInterceptor.class);
+
+ private boolean trace = log.isTraceEnabled();
// Static ---------------------------------------------------------------------------------------
@@ -71,7 +73,7 @@
catch(JMSException e)
{
// JMSException should not be logged unless trace is on
- // if (trace) { log.trace("Caught JMSException", e); }
+ if (trace) { log.trace("Caught JMSException", e); }
throw e;
}
catch (Throwable t)
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -81,7 +81,7 @@
// ConnectionFactoryDelegate implementation -----------------------------------------------------
- public byte[] getClientAOPStack()
+ public byte[] getClientAOPStack() throws JMSException
{
// Use one of the non-clustered ConnectionFactory delegates to retrieve the client AOP stack
// from one of the nodes.
@@ -89,7 +89,7 @@
ConnectionFactoryDelegate aopStackProvider = delegates[0];
log.debug("getting AOP stack from " + aopStackProvider);
-
+
return aopStackProvider.getClientAOPStack();
}
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -173,21 +173,10 @@
SimpleMetaData md = mi.getMetaData();
- if ("getClientAOPStack".equals(methodName))
- {
- // the ClientAOPStackProvider on the server-side is the ServerPeer itself
- md.addMetaData(Dispatcher.DISPATCHER,
+ md.addMetaData(Dispatcher.DISPATCHER,
Dispatcher.OID,
- new Integer(serverID),
- PayloadKey.AS_IS);
- }
- else
- {
- md.addMetaData(Dispatcher.DISPATCHER,
- Dispatcher.OID,
new Integer(id),
- PayloadKey.AS_IS);
- }
+ PayloadKey.AS_IS);
// If the method being invoked is createConnectionDelegate() then we must invoke it on the
// same remoting client subsequently used by the connection. This is because we need to pass
Modified: trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryDelegate.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryDelegate.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -22,7 +22,6 @@
package org.jboss.jms.delegate;
import org.jboss.jms.server.endpoint.ConnectionFactoryEndpoint;
-import org.jboss.jms.client.ClientAOPStackProvider;
/**
* Represents the minimal set of operations to provide connection factory
@@ -34,6 +33,6 @@
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision$</tt>
*/
-public interface ConnectionFactoryDelegate extends ClientAOPStackProvider, ConnectionFactoryEndpoint
+public interface ConnectionFactoryDelegate extends ConnectionFactoryEndpoint
{
}
Modified: trunk/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/server/ServerPeer.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -40,17 +40,14 @@
import javax.transaction.xa.Xid;
import org.jboss.aop.AspectXmlLoader;
-import org.jboss.jms.client.ClientAOPStackProvider;
import org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper;
import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
import org.jboss.jms.server.connectormanager.SimpleConnectorManager;
import org.jboss.jms.server.destination.ManagedQueue;
import org.jboss.jms.server.endpoint.ServerSessionEndpoint;
-import org.jboss.jms.server.endpoint.advised.ClientAOPStackProviderAdvised;
import org.jboss.jms.server.messagecounter.MessageCounter;
import org.jboss.jms.server.messagecounter.MessageCounterManager;
import org.jboss.jms.server.plugin.contract.JMSUserManager;
-import org.jboss.jms.server.remoting.JMSDispatcher;
import org.jboss.jms.server.remoting.JMSServerInvocationHandler;
import org.jboss.jms.server.remoting.JMSWireFormat;
import org.jboss.jms.server.security.SecurityMetadataStore;
@@ -93,7 +90,7 @@
* $Id$
*/
public class ServerPeer extends ServiceMBeanSupport
- implements ClientAOPStackProvider, ServerPeerMBean
+ implements ServerPeerMBean
{
// Constants ------------------------------------------------------------------------------------
@@ -276,10 +273,6 @@
initializeRemoting(mbeanServer);
- // Register myself as ClientAOPStackProvider with the JMSDispatcher
- ClientAOPStackProviderAdvised advised = new ClientAOPStackProviderAdvised(this);
- JMSDispatcher.instance.registerTarget(new Integer(serverPeerID), advised);
-
started = true;
log.info("JBoss Messaging " + getVersion().getProviderVersion() + " server [" +
@@ -892,15 +885,12 @@
return buffer.toString();
}
-
- // ClientAOPStackProvider implementation --------------------------------------------------------
-
+ // Public ---------------------------------------------------------------------------------------
+
public byte[] getClientAOPStack()
{
return clientAOPStack;
}
-
- // Public ---------------------------------------------------------------------------------------
public MessageCounterManager getMessageCounterManager()
{
Modified: trunk/src/main/org/jboss/jms/server/bridge/Bridge.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/bridge/Bridge.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/server/bridge/Bridge.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -197,6 +197,9 @@
*/
public Bridge()
{
+ this.messages = new LinkedList();
+
+ this.lock = new Object();
}
@@ -213,6 +216,8 @@
int maxBatchSize, long maxBatchTime,
String subName, String clientID)
{
+ this();
+
this.sourceCff = sourceCff;
this.targetCff = destCff;
@@ -245,12 +250,6 @@
this.clientID = clientID;
- checkParams();
-
- this.messages = new LinkedList();
-
- this.lock = new Object();
-
if (trace)
{
log.trace("Created " + this);
@@ -270,6 +269,8 @@
if (trace) { log.trace("Starting " + this); }
+ checkParams();
+
boolean ok = setupJMSObjectsWithRetry();
if (ok)
@@ -395,7 +396,6 @@
return;
}
this.sourceDestination = dest;
- checkParams();
}
public Destination getTargetDestination()
@@ -411,7 +411,6 @@
return;
}
this.targetDestination = dest;
- checkParams();
}
public String getSourceUsername()
@@ -419,7 +418,7 @@
return sourceUsername;
}
- public synchronized void setSourceUserName(String name)
+ public synchronized void setSourceUsername(String name)
{
if (started)
{
@@ -427,7 +426,6 @@
return;
}
sourceUsername = name;
- checkParams();
}
public synchronized String getSourcePassword()
@@ -443,7 +441,6 @@
return;
}
sourcePassword = pwd;
- checkParams();
}
public synchronized String getDestUsername()
@@ -459,7 +456,6 @@
return;
}
this.targetUsername = name;
- checkParams();
}
public synchronized String getDestPassword()
@@ -475,7 +471,6 @@
return;
}
this.targetPassword = pwd;
- checkParams();
}
public synchronized String getSelector()
@@ -491,7 +486,6 @@
return;
}
this.selector = selector;
- checkParams();
}
public synchronized long getFailureRetryInterval()
@@ -508,7 +502,6 @@
}
this.failureRetryInterval = interval;
- checkParams();
}
public synchronized int getMaxRetries()
@@ -525,7 +518,6 @@
}
this.maxRetries = retries;
- checkParams();
}
public synchronized int getQualityOfServiceMode()
@@ -542,7 +534,6 @@
}
qualityOfServiceMode = mode;
- checkParams();
}
public synchronized int getMaxBatchSize()
@@ -559,7 +550,6 @@
}
maxBatchSize = size;
- checkParams();
}
public synchronized long getMaxBatchTime()
@@ -576,7 +566,6 @@
}
maxBatchTime = time;
- checkParams();
}
public synchronized String getSubName()
@@ -593,7 +582,6 @@
}
this.subName = subname;
- checkParams();
}
public synchronized String getClientID()
@@ -610,7 +598,6 @@
}
this.clientID = clientID;
- checkParams();
}
public synchronized boolean isPaused()
@@ -623,6 +610,11 @@
return failed;
}
+ public synchronized boolean isStarted()
+ {
+ return started;
+ }
+
public synchronized void setSourceConnectionFactoryFactory(ConnectionFactoryFactory cff)
{
if (started)
@@ -683,7 +675,7 @@
{
throw new IllegalArgumentException("maxBatchTime must be >= 1 or -1 to represent unlimited batch time");
}
- if (this.qualityOfServiceMode != QOS_AT_MOST_ONCE && qualityOfServiceMode != QOS_DUPLICATES_OK && qualityOfServiceMode != QOS_ONCE_AND_ONLY_ONCE)
+ if (qualityOfServiceMode != QOS_AT_MOST_ONCE && qualityOfServiceMode != QOS_DUPLICATES_OK && qualityOfServiceMode != QOS_ONCE_AND_ONLY_ONCE)
{
throw new IllegalArgumentException("Invalid quality of service mode " + qualityOfServiceMode);
}
Modified: trunk/src/main/org/jboss/jms/server/bridge/BridgeMBean.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/bridge/BridgeMBean.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/server/bridge/BridgeMBean.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -33,75 +33,85 @@
*/
public interface BridgeMBean
{
- String getSourceDestinationLookup();
+ String getSourceConnectionFactoryLookup();
- void setSourceDestinationLookup(String lookup);
+ String getTargetConnectionFactoryLookup();
+ void setSourceConnectionFactoryLookup(String lookup);
+
+ void setTargetConnectionFactoryLookup(String lookup);
+
+ String getSourceDestinationLookup();
+
String getTargetDestinationLookup();
-
+
+ void setSourceDestinationLookup(String lookup);
+
void setTargetDestinationLookup(String lookup);
-
+
String getSourceUsername();
- void setSourceUserName(String name);
-
String getSourcePassword();
+ void setSourceUsername(String name);
+
void setSourcePassword(String pwd);
-
+
String getTargetUsername();
+
+ String getTargetPassword();
void setTargetUsername(String name);
- String getTargetPassword();
-
void setTargetPassword(String pwd);
-
- String getSelector();
- void setSelector(String selector);
-
- long getFailureRetryInterval();
-
- void setFailureRetryInterval(long interval);
-
- int getMaxRetries();
-
- void setMaxRetries(int retries);
-
int getQualityOfServiceMode();
- void setQualityOfServiceMode(int mode);
+ void setQualityOfServiceMode(int mode);
+ String getSelector();
+
+ void setSelector(String selector);
+
int getMaxBatchSize();
void setMaxBatchSize(int size);
-
+
long getMaxBatchTime();
void setMaxBatchTime(long time);
-
+
String getSubName();
void setSubName(String subname);
-
+
String getClientID();
+
+ void setClientID(String clientID);
- void setClientID(String id);
-
+ long getFailureRetryInterval();
+
+ void setFailureRetryInterval(long interval);
+
+ int getMaxRetries();
+
+ void setMaxRetries(int retries);
+
+ boolean isFailed();
+
boolean isPaused();
+
+ String getSourceJNDIProperties();
- boolean isFailed();
-
void setSourceJNDIProperties(String props);
+ String getTargetJNDIProperties();
+
void setTargetJNDIProperties(String props);
- String getSourceJNDIProperties();
+ // JMX attributes
- String getTargetJNDIProperties();
-
void pause() throws Exception;
- void resume() throws Exception;
+ void resume() throws Exception;
}
Modified: trunk/src/main/org/jboss/jms/server/bridge/BridgeService.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/bridge/BridgeService.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/server/bridge/BridgeService.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -57,7 +57,6 @@
private String targetDestinationLookup;
-
public BridgeService()
{
bridge = new Bridge();
@@ -77,22 +76,22 @@
public synchronized void setSourceConnectionFactoryLookup(String lookup)
{
- if (getState() != STOPPED)
+ if (bridge.isStarted())
{
log.warn("Cannot set SourceConnectionFactoryLookup when bridge is started");
return;
}
- this.sourceConnectionFactoryLookup = lookup;
- }
+ this.sourceConnectionFactoryLookup = checkAndTrim(lookup);
+ }
public synchronized void setTargetConnectionFactoryLookup(String lookup)
{
- if (getState() != STOPPED)
+ if (bridge.isStarted())
{
log.warn("Cannot set DestConnectionFactoryLookup when bridge is started");
return;
}
- this.targetConnectionFactoryLookup = lookup;
+ this.targetConnectionFactoryLookup = checkAndTrim(lookup);
}
public String getSourceDestinationLookup()
@@ -107,22 +106,22 @@
public void setSourceDestinationLookup(String lookup)
{
- if (getState() != STOPPED)
+ if (bridge.isStarted())
{
log.warn("Cannot set SourceDestinationLookup when bridge is started");
return;
}
- this.sourceDestinationLookup = lookup;
+ this.sourceDestinationLookup = checkAndTrim(lookup);
}
public void setTargetDestinationLookup(String lookup)
{
- if (getState() != STOPPED)
+ if (bridge.isStarted())
{
log.warn("Cannot set TargetDestinationLookup when bridge is started");
return;
}
- this.targetDestinationLookup = lookup;
+ this.targetDestinationLookup = checkAndTrim(lookup);
}
public String getSourceUsername()
@@ -135,9 +134,9 @@
return bridge.getSourcePassword();
}
- public void setSourceUserName(String name)
+ public void setSourceUsername(String name)
{
- bridge.setSourceUserName(name);
+ bridge.setSourceUsername(name);
}
public void setSourcePassword(String pwd)
@@ -254,6 +253,11 @@
{
return bridge.isPaused();
}
+
+ public boolean isStarted()
+ {
+ return bridge.isStarted();
+ }
public synchronized String getSourceJNDIProperties()
{
@@ -262,15 +266,12 @@
public synchronized void setSourceJNDIProperties(String props)
{
- if (props != null)
+ if (bridge.isStarted())
{
- props = props.trim();
- if ("".equals(props))
- {
- props = null;
- }
+ log.warn("Cannot set SourceJNDIProperties when bridge is started");
+ return;
}
- this.sourceJNDIProperties = props;
+ this.sourceJNDIProperties = checkAndTrim(props);
}
public synchronized String getTargetJNDIProperties()
@@ -280,15 +281,12 @@
public synchronized void setTargetJNDIProperties(String props)
{
- if (props != null)
+ if (bridge.isStarted())
{
- props = props.trim();
- if ("".equals(props))
- {
- props = null;
- }
+ log.warn("Cannot set TargetJNDIProperties when bridge is started");
+ return;
}
- this.targetJNDIProperties = props;
+ this.targetJNDIProperties = checkAndTrim(props);
}
public MessagingComponent getInstance()
@@ -339,6 +337,10 @@
icSource = new InitialContext(sourceProps);
}
+ if (sourceDestinationLookup == null)
+ {
+ throw new IllegalArgumentException("Source destination lookup cannot be null");
+ }
Destination sourceDest = (Destination)icSource.lookup(sourceDestinationLookup);
InitialContext icDest = null;
@@ -349,11 +351,20 @@
}
else
{
- icDest = new InitialContext(sourceProps);
+ icDest = new InitialContext(targetProps);
}
+ if (targetDestinationLookup == null)
+ {
+ throw new IllegalArgumentException("Target destination lookup cannot be null");
+ }
Destination targetDest = (Destination)icDest.lookup(targetDestinationLookup);
-
+
+ if (sourceConnectionFactoryLookup == null)
+ {
+ throw new IllegalArgumentException("Source connection factory lookup cannot be null");
+ }
+
ConnectionFactoryFactory sourceCff =
new JNDIConnectionFactoryFactory(sourceProps, sourceConnectionFactoryLookup);
@@ -379,6 +390,19 @@
// Private ---------------------------------------------------------------------------------
+ private String checkAndTrim(String s)
+ {
+ if (s != null)
+ {
+ s = s.trim();
+ if ("".equals(s))
+ {
+ s = null;
+ }
+ }
+ return s;
+ }
+
private Properties createProps(String propsString) throws Exception
{
ByteArrayInputStream is = new ByteArrayInputStream(propsString.getBytes());
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryEndpoint.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryEndpoint.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -47,5 +47,7 @@
throws JMSException;
IDBlock getIdBlock(int size) throws JMSException;
+
+ byte[] getClientAOPStack() throws JMSException;
}
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -196,6 +196,18 @@
throw ExceptionUtil.handleJMSInvocation(t, this + " getIdBlock");
}
}
+
+ public byte[] getClientAOPStack() throws JMSException
+ {
+ try
+ {
+ return serverPeer.getClientAOPStack();
+ }
+ catch (Throwable t)
+ {
+ throw ExceptionUtil.handleJMSInvocation(t, this + " getClientAOPStack");
+ }
+ }
// Public ---------------------------------------------------------------------------------------
Deleted: trunk/src/main/org/jboss/jms/server/endpoint/advised/ClientAOPStackProviderAdvised.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/advised/ClientAOPStackProviderAdvised.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/server/endpoint/advised/ClientAOPStackProviderAdvised.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -1,57 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.server.endpoint.advised;
-
-import org.jboss.jms.server.ServerPeer;
-import org.jboss.jms.client.ClientAOPStackProvider;
-
-/**
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- *
- * $Id$
- */
-public class ClientAOPStackProviderAdvised implements ClientAOPStackProvider
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private ServerPeer serverPeer;
-
- // Constructors --------------------------------------------------
-
- public ClientAOPStackProviderAdvised(ServerPeer serverPeer)
- {
- this.serverPeer = serverPeer;
- }
-
- // ClientAOPStackProvider implementation --------------------------------
-
- public byte[] getClientAOPStack()
- {
- return serverPeer.getClientAOPStack();
- }
-
- // Public --------------------------------------------------------
-
- public String toString()
- {
- return "ClientAOPStackProviderAdvised->" + serverPeer;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Modified: trunk/src/main/org/jboss/jms/server/endpoint/advised/ConnectionFactoryAdvised.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/advised/ConnectionFactoryAdvised.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/server/endpoint/advised/ConnectionFactoryAdvised.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -22,6 +22,7 @@
package org.jboss.jms.server.endpoint.advised;
import javax.jms.JMSException;
+
import org.jboss.jms.server.endpoint.ConnectionFactoryEndpoint;
import org.jboss.jms.server.endpoint.CreateConnectionResult;
import org.jboss.messaging.core.plugin.IDBlock;
@@ -69,6 +70,11 @@
{
return endpoint.getIdBlock(size);
}
+
+ public byte[] getClientAOPStack() throws JMSException
+ {
+ return endpoint.getClientAOPStack();
+ }
// AdvisedSupport override ---------------------------------------
Modified: trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -21,6 +21,14 @@
*/
package org.jboss.jms.server.remoting;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import org.jboss.aop.Dispatcher;
import org.jboss.aop.joinpoint.InvocationResponse;
import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.aop.util.PayloadKey;
@@ -32,12 +40,6 @@
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
-import javax.management.MBeanServer;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -127,7 +129,7 @@
"for session id " + s);
}
}
-
+
InvocationResponse resp = JMSDispatcher.instance.invoke(i);
byte version = mm.getVersion();
Modified: trunk/tests/etc/log4j.xml
===================================================================
--- trunk/tests/etc/log4j.xml 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/tests/etc/log4j.xml 2007-01-17 22:29:52 UTC (rev 1973)
@@ -24,7 +24,7 @@
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p @%t [%c{1}] %m%n"/>
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] @%t %m%n"/>
</layout>
</appender>
@@ -32,16 +32,11 @@
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
- <!-- <param name="Threshold" value="TRACE#org.jboss.logging.XLevel"/> -->
<layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="@%t %d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ <param name="ConversionPattern" value="%t %d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
</layout>
</appender>
- <category name="com.arjuna">
- <priority value="TRACE" class="org.jboss.logging.XLevel"/>
- </category>
-
<category name="org.apache">
<priority value="INFO"/>
</category>
@@ -50,12 +45,12 @@
<priority value="WARN"/>
</category>
- <category name="org.jboss.remoting">
+ <category name="org.jboss">
<priority value="INFO"/>
</category>
- <category name="org.jboss">
- <priority value="INFO"/>
+ <category name="org.jboss.remoting">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
</category>
<category name="org.jboss.messaging">
@@ -73,19 +68,15 @@
<!-- Ignoring trace from these: -->
<category name="org.jboss.jms.server.remoting.JMSServerInvocationHandler">
- <priority value="DEBUG"/>
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
</category>
- <category name="org.jboss.messaging.core.plugin.JDBCSupport">
- <priority value="INFO"/>
- </category>
-
<category name="org.jboss.test.messaging.tools.jmx.MockJBossSecurityManager">
<priority value="DEBUG"/>
</category>
<category name="org.jboss.jms.server.remoting.JMSWireFormat">
- <priority value="DEBUG"/>
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
</category>
<root>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -21,13 +21,28 @@
*/
package org.jboss.test.messaging.jms.bridge;
+import java.io.ByteArrayOutputStream;
+import java.util.Properties;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
import javax.management.ObjectName;
+import javax.naming.InitialContext;
-import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.jms.server.bridge.Bridge;
+import org.jboss.logging.Logger;
import org.jboss.test.messaging.tools.ServerManagement;
/**
* A BridgeMBeanTest
+ *
+ *
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision: 1.1 $</tt>
@@ -35,118 +50,704 @@
* $Id$
*
*/
-public class BridgeMBeanTest extends MessagingTestCase
+public class BridgeMBeanTest extends BridgeTestBase
{
-
+ private static final Logger log = Logger.getLogger(BridgeMBeanTest.class);
+
+
public BridgeMBeanTest(String name)
{
super(name);
}
-
+
protected void setUp() throws Exception
{
+ nodeCount = 3;
+
super.setUp();
}
-
+
protected void tearDown() throws Exception
{
super.tearDown();
}
- /*
-
- Example config
-
- String config =
- "<mbean code=org.jboss.jms.server.bridge.BridgeService " +
- "name=jboss.messaging:service=Bridge,name=exampleBridge" +
- "xmbean-dd=\"xmdesc/Bridge-xmbean.xml\">" +
- "<attribute name=\"SourceConnectionFactoryLookup\">/ConnectionFactory</attribute>"+
- "<attribute name=\"TargetConnectionFactoryLookup\">/ConnectionFactory</attribute>"+
- "<attribute name=\"SourceDestinationLookup\">/topic/sourceTopic</attribute>"+
- "<attribute name=\"TargetDestinationLookup\">/queue/targetQueue</attribute>"+
- "<attribute name=\"SourceUsername\">bob</attribute>"+
- "<attribute name=\"SourcePassword\">pwd1</attribute>"+
- "<attribute name=\"TargetUsername\">jane</attribute>"+
- "<attribute name=\"TargetPassword\">pwd2</attribute>"+
- "<attribute name=\"QualityOfServiceMode\">2</attribute>"+
- "<attribute name=\"Selector\">vegetable='marrow'</attribute>"+
- "<attribute name=\"MaxBatchSize\">100</attribute>"+
- "<attribute name=\"MaxBatchTime\">5000</attribute>"+
- "<attribute name=\"SubName\">mySubscription</attribute>"+
- "<attribute name=\"ClientID\">clientid-123</attribute>"+
- "<attribute name=\"FailureRetryInterval\">5000</attribute>"+
- "<attribute name=\"MaxRetries\">-1</attribute>"+
- "<attribute name=\"SourceJNDIProperties\"><![CDATA["+
-"java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory\n"+
-"java.naming.provider.url=jnp://server1:1099\n"+
-"java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces\n"+
-"]]>"+
- "</attribute>";
- "<attribute name=\"TargetJNDIProperties\"><![CDATA["+
-"java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory\n"+
-"java.naming.provider.url=jnp://server1:1099\n"+
-"java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces\n"+
-"]]>"+
- "</attribute>"+
- "</mbean>";
+ public void testStopStartPauseResume() throws Exception
+ {
+ if (!ServerManagement.isRemote())
+ {
+ return;
+ }
+
+ ServerManagement.deployQueue("sourceQueue", 1);
+ ServerManagement.deployQueue("targetQueue", 2);
+
+ Properties props1 = new Properties();
+ props1.putAll(ServerManagement.getJNDIEnvironment(1));
+
+ Properties props2 = new Properties();
+ props2.putAll(ServerManagement.getJNDIEnvironment(2));
+
+ String sprops1 = tableToString(props1);
+
+ String sprops2 = tableToString(props2);
+
+ ObjectName on = deployBridge(0, "Bridge1", "/XAConnectionFactory", "/XAConnectionFactory",
+ "/queue/sourceQueue", "/queue/targetQueue",
+ null, null, null, null,
+ Bridge.QOS_AT_MOST_ONCE, null, 1,
+ -1, null, null, 5000, -1,
+ sprops1, sprops2);
+
+ ServerManagement.getServer(0).invoke(on, "create", new Object[0], new String[0]);
+
+ Connection connSource = null;
+
+ Connection connTarget = null;
+
+ InitialContext icSource = new InitialContext(props1);
+ InitialContext icTarget = new InitialContext(props2);
+
+ try
+ {
+ ConnectionFactory cf0 = (ConnectionFactory)icSource.lookup("/XAConnectionFactory");
+
+ ConnectionFactory cf1 = (ConnectionFactory)icTarget.lookup("/XAConnectionFactory");
+
+ Destination destSource = (Destination)icSource.lookup("/queue/sourceQueue");
+
+ Destination destTarget = (Destination)icTarget.lookup("/queue/targetQueue");
+
+ connSource = cf0.createConnection();
+
+ connTarget = cf1.createConnection();
+
+ connTarget.start();
+
+ connSource.start();
+
+ final int NUM_MESSAGES = 50;
+
+ Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSource.createProducer(destSource);
+
+ Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sessTarget.createConsumer(destTarget);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSource.createTextMessage("message" + i);
+
+ prod.send(tm);
+ }
+
+ //It's stopped so no messages should be received
+
+ Message m = cons.receive(2000);
+
+ assertNull(m);
+
+ //Start it
+
+ ServerManagement.getServer(0).invoke(on, "start", new Object[0], new String[0]);
+
+ //Now should receive the messages
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage)cons.receive(2000);
+
+ assertNotNull(tm);
-
- */
+ assertEquals("message" + i, tm.getText());
+ }
+
+ m = cons.receive(2000);
+
+ assertNull(m);
+
+
+ //Send some more
+
+ for (int i = NUM_MESSAGES; i < 2 * NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSource.createTextMessage("message" + i);
+
+ prod.send(tm);
+ }
+
+ //These should be received too
+
+ for (int i = NUM_MESSAGES; i < 2 * NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage)cons.receive(2000);
+
+ assertNotNull(tm);
+
+ assertEquals("message" + i, tm.getText());
+ }
+
+ m = cons.receive(2000);
+
+ assertNull(m);
+
+ //Pause it
+
+ ServerManagement.getServer(0).invoke(on, "pause", new Object[0], new String[0]);
+
+ boolean isPaused = ((Boolean)ServerManagement.getAttribute(on, "Paused")).booleanValue();
+
+ assertTrue(isPaused);
+
+ // Send some more
+
+ for (int i = 2 * NUM_MESSAGES; i < 3 * NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSource.createTextMessage("message" + i);
+
+ prod.send(tm);
+ }
+
+ //These shouldn't be received
+
+ m = cons.receive(2000);
+
+ assertNull(m);
+
+ // Resume
+
+ ServerManagement.getServer(0).invoke(on, "resume", new Object[0], new String[0]);
+
+ //Now messages should be received
+
+ for (int i = 2 * NUM_MESSAGES; i < 3 * NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage)cons.receive(2000);
+
+ assertNotNull(tm);
+
+ assertEquals("message" + i, tm.getText());
+ }
+
+ m = cons.receive(2000);
+
+ assertNull(m);
+
+ isPaused = ((Boolean)ServerManagement.getAttribute(on, "Paused")).booleanValue();
+
+ assertFalse(isPaused);
+
+ //Stop
+
+ ServerManagement.getServer(0).invoke(on, "stop", new Object[0], new String[0]);
+
+ boolean isStarted = ((Boolean)ServerManagement.getAttribute(on, "Started")).booleanValue();
+
+ assertFalse(isStarted);
+
+ MessageConsumer cons2 = sessSource.createConsumer(destSource);
+
+ m = cons2.receive(2000);
+
+ assertNull(m);
+
+ }
+ finally
+ {
+ if (connSource != null)
+ {
+ connSource.close();
+ }
+
+ if (connTarget != null)
+ {
+ connTarget.close();
+ }
+ }
+ }
+
+ public void testDeploy() throws Exception
+ {
+ if (!ServerManagement.isRemote())
+ {
+ return;
+ }
+
+ ServerManagement.deployQueue("sourceQueue", 1);
+ ServerManagement.deployQueue("targetQueue", 2);
+
+ try
+ {
+ Thread.sleep(5000);
+
+ Properties props1 = new Properties();
+ props1.putAll(ServerManagement.getJNDIEnvironment(1));
+
+ Properties props2 = new Properties();
+ props2.putAll(ServerManagement.getJNDIEnvironment(2));
+
+ String sprops1 = tableToString(props1);
+
+ String sprops2 = tableToString(props2);
+
+ ObjectName on = deployBridge(0, "Bridge1", "/XAConnectionFactory", "/XAConnectionFactory",
+ "/queue/sourceQueue", "/queue/targetQueue",
+ null, null, null, null,
+ Bridge.QOS_ONCE_AND_ONLY_ONCE, null, 1,
+ -1, null, null, 5000, -1,
+ sprops1, sprops2);
+
+ ServerManagement.getServer(0).invoke(on, "create", new Object[0], new String[0]);
+
+ {
+ String cfLookup = (String)ServerManagement.getAttribute(on, "SourceConnectionFactoryLookup");
+ assertEquals("/XAConnectionFactory", cfLookup);
+ ServerManagement.setAttribute(on, "SourceConnectionFactoryLookup", "/Wibble");
+ cfLookup = (String)ServerManagement.getAttribute(on, "SourceConnectionFactoryLookup");
+ assertEquals("/Wibble", cfLookup);
+ ServerManagement.setAttribute(on, "SourceConnectionFactoryLookup", "/XAConnectionFactory");
+ }
+
+ {
+ String cfLookup = (String)ServerManagement.getAttribute(on, "TargetConnectionFactoryLookup");
+ assertEquals("/XAConnectionFactory", cfLookup);
+ ServerManagement.setAttribute(on, "TargetConnectionFactoryLookup", "/Wibble");
+ cfLookup = (String)ServerManagement.getAttribute(on, "TargetConnectionFactoryLookup");
+ assertEquals("/Wibble", cfLookup);
+ ServerManagement.setAttribute(on, "TargetConnectionFactoryLookup", "/XAConnectionFactory");
+ }
+
+ {
+ String destLookup = (String)ServerManagement.getAttribute(on, "SourceDestinationLookup");
+ assertEquals("/queue/sourceQueue", destLookup);
+ ServerManagement.setAttribute(on, "SourceDestinationLookup", "/queue/WibbleQueue");
+ destLookup = (String)ServerManagement.getAttribute(on, "SourceDestinationLookup");
+ assertEquals("/queue/WibbleQueue", destLookup);
+ ServerManagement.setAttribute(on, "SourceDestinationLookup", "/queue/sourceQueue");
+ }
+
+ {
+ String destLookup = (String)ServerManagement.getAttribute(on, "TargetDestinationLookup");
+ assertEquals("/queue/targetQueue", destLookup);
+ ServerManagement.setAttribute(on, "TargetDestinationLookup", "/queue/WibbleQueue");
+ destLookup = (String)ServerManagement.getAttribute(on, "TargetDestinationLookup");
+ assertEquals("/queue/WibbleQueue", destLookup);
+ ServerManagement.setAttribute(on, "TargetDestinationLookup", "/queue/targetQueue");
+ }
+
+ {
+ String username = (String)ServerManagement.getAttribute(on, "SourceUsername");
+ assertEquals(null, username);
+ ServerManagement.setAttribute(on, "SourceUsername", "bob");
+ username = (String)ServerManagement.getAttribute(on, "SourceUsername");
+ assertEquals("bob", username);
+ ServerManagement.setAttribute(on, "SourceUsername", null);
+ }
+
+ {
+ String password = (String)ServerManagement.getAttribute(on, "SourcePassword");
+ assertEquals(null, password);
+ ServerManagement.setAttribute(on, "SourcePassword", "eek");
+ password = (String)ServerManagement.getAttribute(on, "SourcePassword");
+ assertEquals("eek", password);
+ ServerManagement.setAttribute(on, "SourcePassword", null);
+ }
+
+ {
+ String username = (String)ServerManagement.getAttribute(on, "TargetUsername");
+ assertEquals(null, username);
+ ServerManagement.setAttribute(on, "TargetUsername", "bob");
+ username = (String)ServerManagement.getAttribute(on, "TargetUsername");
+ assertEquals("bob", username);
+ ServerManagement.setAttribute(on, "TargetUsername", null);
+ }
+
+ {
+ String password = (String)ServerManagement.getAttribute(on, "TargetPassword");
+ assertEquals(null, password);
+ ServerManagement.setAttribute(on, "TargetPassword", "eek");
+ password = (String)ServerManagement.getAttribute(on, "TargetPassword");
+ assertEquals("eek", password);
+ ServerManagement.setAttribute(on, "TargetPassword", null);
+ }
+
+ {
+ Integer qos = (Integer)ServerManagement.getAttribute(on, "QualityOfServiceMode");
+ assertEquals(Bridge.QOS_ONCE_AND_ONLY_ONCE, qos.intValue());
+ ServerManagement.setAttribute(on, "QualityOfServiceMode", String.valueOf(Bridge.QOS_AT_MOST_ONCE));
+ qos = (Integer)ServerManagement.getAttribute(on, "QualityOfServiceMode");
+ assertEquals(new Integer(Bridge.QOS_AT_MOST_ONCE), qos);
+ ServerManagement.setAttribute(on, "QualityOfServiceMode", String.valueOf(Bridge.QOS_ONCE_AND_ONLY_ONCE));
+ }
+
+ {
+ String selector = (String)ServerManagement.getAttribute(on, "Selector");
+ assertEquals(null, selector);
+ ServerManagement.setAttribute(on, "Selector", "god='dead'");
+ selector = (String)ServerManagement.getAttribute(on, "Selector");
+ assertEquals("god='dead'", selector);
+ ServerManagement.setAttribute(on, "Selector", null);
+ }
+
+ {
+ Integer maxBatchSize = (Integer)ServerManagement.getAttribute(on, "MaxBatchSize");
+ assertEquals(1, maxBatchSize.intValue());
+ ServerManagement.setAttribute(on, "MaxBatchSize", "10");
+ maxBatchSize = (Integer)ServerManagement.getAttribute(on, "MaxBatchSize");
+ assertEquals(10, maxBatchSize.intValue());
+ ServerManagement.setAttribute(on, "MaxBatchSize", "1");
+ }
+
+ {
+ Long maxBatchTime = (Long)ServerManagement.getAttribute(on, "MaxBatchTime");
+ assertEquals(-1, maxBatchTime.longValue());
+ ServerManagement.setAttribute(on, "MaxBatchTime", "3000");
+ maxBatchTime = (Long)ServerManagement.getAttribute(on, "MaxBatchTime");
+ assertEquals(3000, maxBatchTime.longValue());
+ ServerManagement.setAttribute(on, "MaxBatchTime", "-1");
+ }
+
+ {
+ String subName = (String)ServerManagement.getAttribute(on, "SubName");
+ assertEquals(null, subName);
+ ServerManagement.setAttribute(on, "SubName", "submarine");
+ subName = (String)ServerManagement.getAttribute(on, "SubName");
+ assertEquals("submarine", subName);
+ ServerManagement.setAttribute(on, "SubName", null);
+ }
+
+ {
+ String clientID = (String)ServerManagement.getAttribute(on, "ClientID");
+ assertEquals(null, clientID);
+ ServerManagement.setAttribute(on, "ClientID", "clientid-123");
+ clientID = (String)ServerManagement.getAttribute(on, "ClientID");
+ assertEquals("clientid-123", clientID);
+ ServerManagement.setAttribute(on, "ClientID", null);
+ }
+
+ {
+ Long failureRetryInterval = (Long)ServerManagement.getAttribute(on, "FailureRetryInterval");
+ assertEquals(5000, failureRetryInterval.longValue());
+ ServerManagement.setAttribute(on, "FailureRetryInterval", "10000");
+ failureRetryInterval = (Long)ServerManagement.getAttribute(on, "FailureRetryInterval");
+ assertEquals(10000, failureRetryInterval.longValue());
+ ServerManagement.setAttribute(on, "FailureRetryInterval", "5000");
+ }
+
+ {
+ Integer maxRetries = (Integer)ServerManagement.getAttribute(on, "MaxRetries");
+ assertEquals(-1, maxRetries.intValue());
+ ServerManagement.setAttribute(on, "MaxRetries", "1000");
+ maxRetries = (Integer)ServerManagement.getAttribute(on, "MaxRetries");
+ assertEquals(1000, maxRetries.intValue());
+ ServerManagement.setAttribute(on, "MaxRetries", "-1");
+ }
+
+ ServerManagement.getServer(0).invoke(on, "start", new Object[0], new String[0]);
+
+ //Should not be able to change attributes when bridge is started - need to stop first
+
+ {
+ String cfLookup = (String)ServerManagement.getAttribute(on, "SourceConnectionFactoryLookup");
+ assertEquals("/XAConnectionFactory", cfLookup);
+ ServerManagement.setAttribute(on, "SourceConnectionFactoryLookup", "/Wibble");
+ cfLookup = (String)ServerManagement.getAttribute(on, "SourceConnectionFactoryLookup");
+ assertEquals("/XAConnectionFactory", cfLookup);
+ }
+
+ {
+ String cfLookup = (String)ServerManagement.getAttribute(on, "TargetConnectionFactoryLookup");
+ assertEquals("/XAConnectionFactory", cfLookup);
+ ServerManagement.setAttribute(on, "TargetConnectionFactoryLookup", "/Wibble");
+ cfLookup = (String)ServerManagement.getAttribute(on, "TargetConnectionFactoryLookup");
+ assertEquals("/XAConnectionFactory", cfLookup);
+ }
+
+ {
+ String destLookup = (String)ServerManagement.getAttribute(on, "SourceDestinationLookup");
+ assertEquals("/queue/sourceQueue", destLookup);
+ ServerManagement.setAttribute(on, "SourceDestinationLookup", "/queue/WibbleQueue");
+ destLookup = (String)ServerManagement.getAttribute(on, "SourceDestinationLookup");
+ assertEquals("/queue/sourceQueue", destLookup);
+ }
+
+ {
+ String destLookup = (String)ServerManagement.getAttribute(on, "TargetDestinationLookup");
+ assertEquals("/queue/targetQueue", destLookup);
+ ServerManagement.setAttribute(on, "TargetDestinationLookup", "/queue/WibbleQueue");
+ destLookup = (String)ServerManagement.getAttribute(on, "TargetDestinationLookup");
+ assertEquals("/queue/targetQueue", destLookup);
+ }
+
+ {
+ String username = (String)ServerManagement.getAttribute(on, "SourceUsername");
+ assertEquals(null, username);
+ ServerManagement.setAttribute(on, "SourceUsername", "bob");
+ username = (String)ServerManagement.getAttribute(on, "SourceUsername");
+ assertEquals(null, username);
+ }
+
+ {
+ String password = (String)ServerManagement.getAttribute(on, "SourcePassword");
+ assertEquals(null, password);
+ ServerManagement.setAttribute(on, "SourcePassword", "eek");
+ password = (String)ServerManagement.getAttribute(on, "SourcePassword");
+ assertEquals(null, password);
+ }
+
+ {
+ String username = (String)ServerManagement.getAttribute(on, "TargetUsername");
+ assertEquals(null, username);
+ ServerManagement.setAttribute(on, "TargetUsername", "bob");
+ username = (String)ServerManagement.getAttribute(on, "TargetUsername");
+ assertEquals(null, username);
+ }
+
+ {
+ String password = (String)ServerManagement.getAttribute(on, "TargetPassword");
+ assertEquals(null, password);
+ ServerManagement.setAttribute(on, "TargetPassword", "eek");
+ password = (String)ServerManagement.getAttribute(on, "TargetPassword");
+ assertEquals(null, password);
+ }
+
+ {
+ Integer qos = (Integer)ServerManagement.getAttribute(on, "QualityOfServiceMode");
+ assertEquals(Bridge.QOS_ONCE_AND_ONLY_ONCE, qos.intValue());
+ ServerManagement.setAttribute(on, "QualityOfServiceMode", String.valueOf(Bridge.QOS_AT_MOST_ONCE));
+ qos = (Integer)ServerManagement.getAttribute(on, "QualityOfServiceMode");
+ assertEquals(new Integer(Bridge.QOS_ONCE_AND_ONLY_ONCE), qos);
+ }
+
+ {
+ String selector = (String)ServerManagement.getAttribute(on, "Selector");
+ assertEquals(null, selector);
+ ServerManagement.setAttribute(on, "Selector", "god='dead'");
+ selector = (String)ServerManagement.getAttribute(on, "Selector");
+ assertEquals(null, selector);
+ }
+
+ {
+ Integer maxBatchSize = (Integer)ServerManagement.getAttribute(on, "MaxBatchSize");
+ assertEquals(1, maxBatchSize.intValue());
+ ServerManagement.setAttribute(on, "MaxBatchSize", "10");
+ maxBatchSize = (Integer)ServerManagement.getAttribute(on, "MaxBatchSize");
+ assertEquals(1, maxBatchSize.intValue());
+ }
+
+ {
+ Long maxBatchTime = (Long)ServerManagement.getAttribute(on, "MaxBatchTime");
+ assertEquals(-1, maxBatchTime.longValue());
+ ServerManagement.setAttribute(on, "MaxBatchTime", "3000");
+ maxBatchTime = (Long)ServerManagement.getAttribute(on, "MaxBatchTime");
+ assertEquals(-1, maxBatchTime.longValue());
+ }
+
+ {
+ String subName = (String)ServerManagement.getAttribute(on, "SubName");
+ assertEquals(null, subName);
+ ServerManagement.setAttribute(on, "SubName", "submarine");
+ subName = (String)ServerManagement.getAttribute(on, "SubName");
+ assertEquals(null, subName);
+ }
+
+ {
+ String clientID = (String)ServerManagement.getAttribute(on, "ClientID");
+ assertEquals(null, clientID);
+ ServerManagement.setAttribute(on, "ClientID", "clientid-123");
+ clientID = (String)ServerManagement.getAttribute(on, "ClientID");
+ assertEquals(null, clientID);
+ }
+
+ {
+ Long failureRetryInterval = (Long)ServerManagement.getAttribute(on, "FailureRetryInterval");
+ assertEquals(5000, failureRetryInterval.longValue());
+ ServerManagement.setAttribute(on, "FailureRetryInterval", "10000");
+ failureRetryInterval = (Long)ServerManagement.getAttribute(on, "FailureRetryInterval");
+ assertEquals(5000, failureRetryInterval.longValue());
+ }
+
+ {
+ Integer maxRetries = (Integer)ServerManagement.getAttribute(on, "MaxRetries");
+ assertEquals(-1, maxRetries.intValue());
+ ServerManagement.setAttribute(on, "MaxRetries", "1000");
+ maxRetries = (Integer)ServerManagement.getAttribute(on, "MaxRetries");
+ assertEquals(-1, maxRetries.intValue());
+ }
+
+ InitialContext icSource = new InitialContext(props1);
+ InitialContext icTarget = new InitialContext(props2);
+
+ checkBridged(icSource, icTarget, "/ConnectionFactory", "/ConnectionFactory",
+ "/queue/sourceQueue", "/queue/targetQueue");
+
+
+ }
+ finally
+ {
+ ServerManagement.undeployQueue("sourceQueue", 1);
+ ServerManagement.undeployQueue("targetQueue", 2);
+ }
+
+ }
+ private String tableToString(Properties t) throws Exception
+ {
+ ByteArrayOutputStream boa = new ByteArrayOutputStream();
+
+ t.store(boa, "");
+
+ return new String(boa.toByteArray());
+ }
- private ObjectName deployBridge(String bridgeName, String sourceCFLookup, String targetCFLookup,
- String sourceDestLookup, String targetDestLookup,
- String sourceUsername, String sourcePassword,
- String targetUsername, String targetPassword,
- int qos, String selector, int maxBatchSize,
- long maxBatchTime, String subName, String clientID,
- long failureRetryInterval, int maxRetries,
- String sourceJNDIProperties,
- String targetJNDIProperties) throws Exception
+ private ObjectName deployBridge(int server, String bridgeName, String sourceCFLookup, String targetCFLookup,
+ String sourceDestLookup, String targetDestLookup,
+ String sourceUsername, String sourcePassword,
+ String targetUsername, String targetPassword,
+ int qos, String selector, int maxBatchSize,
+ long maxBatchTime, String subName, String clientID,
+ long failureRetryInterval, int maxRetries,
+ String sourceJNDIProperties,
+ String targetJNDIProperties) throws Exception
{
String config =
- "<mbean code=org.jboss.jms.server.bridge.BridgeService " +
- "name=jboss.messaging:service=Bridge,name=" + bridgeName +
- "xmbean-dd=\"xmdesc/Bridge-xmbean.xml\">" +
- "<attribute name=\"SourceConnectionFactoryLookup\">" + sourceCFLookup + "/attribute>"+
- "<attribute name=\"TargetConnectionFactoryLookup\">" + targetCFLookup + "</attribute>"+
- "<attribute name=\"SourceDestinationLookup\">" + sourceDestLookup + "</attribute>"+
- "<attribute name=\"TargetDestinationLookup\">" + targetDestLookup + "</attribute>"+
- sourceUsername == null ? "" :
- "<attribute name=\"SourceUsername\">" + sourceUsername + "</attribute>"+
- sourcePassword == null ? "" :
- "<attribute name=\"SourcePassword\">" + sourcePassword +"</attribute>"+
- targetUsername == null ? "" :
- "<attribute name=\"TargetUsername\">" + targetUsername +"</attribute>"+
- targetPassword == null ? "" :
- "<attribute name=\"TargetPassword\">" + targetPassword + "</attribute>"+
- "<attribute name=\"QualityOfServiceMode\">" + qos +"</attribute>"+
- selector == null ? "" :
- "<attribute name=\"Selector\">" + selector + "</attribute>"+
- "<attribute name=\"MaxBatchSize\">" + maxBatchSize + "</attribute>"+
- "<attribute name=\"MaxBatchTime\">" + maxBatchTime +"</attribute>"+
- subName == null ? "" :
- "<attribute name=\"SubName\">" + subName + "</attribute>"+
- clientID == null ? "" :
- "<attribute name=\"ClientID\">" + clientID + "</attribute>"+
- "<attribute name=\"FailureRetryInterval\">" + failureRetryInterval + "</attribute>"+
- "<attribute name=\"MaxRetries\">" + maxRetries +"</attribute>"+
- sourceJNDIProperties == null ? "" :
- "<attribute name=\"SourceJNDIProperties\"><![CDATA["+
+ "<mbean code=\"org.jboss.jms.server.bridge.BridgeService\" " +
+ "name=\"jboss.messaging:service=Bridge,name=" + bridgeName + "\" " +
+ "xmbean-dd=\"xmdesc/Bridge-xmbean.xml\">" +
+ "<attribute name=\"SourceConnectionFactoryLookup\">" + sourceCFLookup + "</attribute>"+
+ "<attribute name=\"TargetConnectionFactoryLookup\">" + targetCFLookup + "</attribute>"+
+ "<attribute name=\"SourceDestinationLookup\">" + sourceDestLookup + "</attribute>"+
+ "<attribute name=\"TargetDestinationLookup\">" + targetDestLookup + "</attribute>";
+ if (sourceUsername != null)
+ {
+ config += "<attribute name=\"SourceUsername\">" + sourceUsername + "</attribute>";
+ }
+ if (sourcePassword != null)
+ {
+ config += "<attribute name=\"SourcePassword\">" + sourcePassword +"</attribute>";
+ }
+ if (targetUsername != null)
+ {
+ config += "<attribute name=\"TargetUsername\">" + targetUsername +"</attribute>";
+ }
+ if (targetPassword != null)
+ {
+ config += "<attribute name=\"TargetPassword\">" + targetPassword + "</attribute>";
+ }
+ config += "<attribute name=\"QualityOfServiceMode\">" + qos +"</attribute>";
+ if (selector != null)
+ {
+ config += "<attribute name=\"Selector\">" + selector + "</attribute>";
+ }
+ config += "<attribute name=\"MaxBatchSize\">" + maxBatchSize + "</attribute>"+
+ "<attribute name=\"MaxBatchTime\">" + maxBatchTime +"</attribute>";
+ if (subName != null)
+ {
+ config += "<attribute name=\"SubName\">" + subName + "</attribute>";
+ }
+ if (clientID != null)
+ {
+ config += "<attribute name=\"ClientID\">" + clientID + "</attribute>";
+ }
+ config += "<attribute name=\"FailureRetryInterval\">" + failureRetryInterval + "</attribute>"+
+ "<attribute name=\"MaxRetries\">" + maxRetries +"</attribute>";
+ if (sourceJNDIProperties != null)
+ {
+ config += "<attribute name=\"SourceJNDIProperties\"><![CDATA["+
sourceJNDIProperties +
"]]>"+
- "</attribute>"+
- targetJNDIProperties == null ? "" :
- "<attribute name=\"TargetJNDIProperties\"><![CDATA["+
+ "</attribute>";
+ }
+ if (targetJNDIProperties != null)
+ {
+ config += "<attribute name=\"TargetJNDIProperties\"><![CDATA["+
targetJNDIProperties +
"]]>"+
- "</attribute>"+
- "</mbean>";
+ "</attribute>";
+ }
+ config += "</mbean>";
- log.info(config);
+ return ServerManagement.getServer(server).deploy(config);
+ }
+
+ private void checkBridged(InitialContext icSource, InitialContext icTarget,
+ String sourceCFLookup, String targetCFLookup,
+ String sourceDestLookup, String targetDestLookup)
+ throws Exception
+ {
+ Connection connSource = null;
- return ServerManagement.deploy(config);
+ Connection connTarget = null;
+
+ try
+ {
+ ConnectionFactory cf0 = (ConnectionFactory)icSource.lookup(sourceCFLookup);
+
+ ConnectionFactory cf1 = (ConnectionFactory)icTarget.lookup(targetCFLookup);
+
+ Destination destSource = (Destination)icSource.lookup(sourceDestLookup);
+
+ Destination destTarget = (Destination)icTarget.lookup(targetDestLookup);
+
+ connSource = cf0.createConnection();
+
+ connTarget = cf1.createConnection();
+
+ connTarget.start();
+
+ connSource.start();
+
+ final int NUM_MESSAGES = 50;
+
+ Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSource.createProducer(destSource);
+
+ Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sessTarget.createConsumer(destTarget);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSource.createTextMessage("message" + i);
+
+ prod.send(tm);
+ }
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage)cons.receive(10000);
+
+ assertNotNull(tm);
+
+ assertEquals("message" + i, tm.getText());
+ }
+
+ Message m = cons.receive(1000);
+
+ assertNull(m);
+
+ MessageConsumer cons2 = sessSource.createConsumer(destSource);
+
+ m = cons2.receive(1000);
+
+ assertNull(m);
+
+ }
+ finally
+ {
+ if (connSource != null)
+ {
+ connSource.close();
+ }
+
+ if (connTarget != null)
+ {
+ connTarget.close();
+ }
+ }
}
-
+
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -32,6 +32,7 @@
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
+import javax.jms.Topic;
import javax.naming.InitialContext;
import org.jboss.jms.server.bridge.Bridge;
@@ -900,13 +901,13 @@
ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
- Queue sourceQueue = (Queue)ic0.lookup("/queue/sourceQueue");
+ Topic sourceTopic = (Topic)ic0.lookup("/topic/sourceTopic");
Queue destQueue = (Queue)ic1.lookup("/queue/destQueue");
final int BATCH_SIZE = 10;
- bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
+ bridge = new Bridge(cff0, cff1, sourceTopic, destQueue,
null, null, null, null,
null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
1, -1,
@@ -920,7 +921,7 @@
Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessSend.createProducer(sourceQueue);
+ MessageProducer prod = sessSend.createProducer(sourceTopic);
for (int i = 0; i < BATCH_SIZE; i++)
{
@@ -1030,13 +1031,13 @@
ConnectionFactory cf1 = (ConnectionFactory)ic1.lookup("/ConnectionFactory");
- Queue sourceQueue = (Queue)ic0.lookup("/queue/sourceQueue");
+ Topic sourceTopic = (Topic)ic0.lookup("/topic/sourceTopic");
Queue destQueue = (Queue)ic1.lookup("/queue/destQueue");
final int BATCH_SIZE = 10;
- bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
+ bridge = new Bridge(cff0, cff1, sourceTopic, destQueue,
null, null, null, null,
null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
1, -1,
@@ -1050,7 +1051,7 @@
Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessSend.createProducer(sourceQueue);
+ MessageProducer prod = sessSend.createProducer(sourceTopic);
for (int i = 0; i < BATCH_SIZE; i++)
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -39,7 +39,7 @@
{
private static final Logger log = Logger.getLogger(BridgeTest.class);
- private static final int NODE_COUNT = 2;
+ protected int nodeCount = 2;
public BridgeTestBase(String name)
{
@@ -50,9 +50,11 @@
{
super.setUp();
+ log.info("Starting " + nodeCount + " servers");
+
if (ServerManagement.isRemote())
{
- for (int i = 0; i < NODE_COUNT; i++)
+ for (int i = 0; i < nodeCount; i++)
{
// make sure all servers are created and started; make sure that database is zapped
// ONLY for the first server, the others rely on values they expect to find in shared
@@ -67,7 +69,7 @@
{
if (ServerManagement.isRemote())
{
- for (int i = 0; i < NODE_COUNT; i++)
+ for (int i = 0; i < nodeCount; i++)
{
try
{
@@ -84,7 +86,7 @@
}
}
- for (int i = 1; i < NODE_COUNT; i++)
+ for (int i = 1; i < nodeCount; i++)
{
try
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -21,7 +21,9 @@
*/
package org.jboss.test.messaging.jms.bridge;
+import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Set;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -38,7 +40,6 @@
import org.jboss.jms.server.bridge.ConnectionFactoryFactory;
import org.jboss.jms.server.bridge.JNDIConnectionFactoryFactory;
import org.jboss.logging.Logger;
-import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
/**
@@ -55,8 +56,6 @@
{
private static final Logger log = Logger.getLogger(ReconnectTest.class);
- private static final int NODE_COUNT = 2;
-
public ReconnectTest(String name)
{
super(name);
@@ -74,6 +73,8 @@
// Crash and reconnect
+ //Once and only once
+
public void testCrashAndReconnectDestBasic_OnceAndOnlyOnce_P() throws Exception
{
if (!ServerManagement.isRemote())
@@ -92,44 +93,86 @@
testCrashAndReconnectDestBasic(Bridge.QOS_ONCE_AND_ONLY_ONCE, false);
}
+ //dups ok
- public void testCrashAndReconnectDestCrashBeforePrepare_OnceAndOnlyOnce_P() throws Exception
+ public void testCrashAndReconnectDestBasic_DuplicatesOk_P() throws Exception
{
if (!ServerManagement.isRemote())
{
return;
}
- testCrashAndReconnectDestCrashBeforePrepare(Bridge.QOS_ONCE_AND_ONLY_ONCE, true);
+ testCrashAndReconnectDestBasic(Bridge.QOS_DUPLICATES_OK, true);
}
- public void testCrashAndReconnectDestCrashBeforePrepare_OnceAndOnlyOnce_NP() throws Exception
+ public void testCrashAndReconnectDestBasic_DuplicatesOk_NP() throws Exception
{
if (!ServerManagement.isRemote())
{
return;
}
- testCrashAndReconnectDestCrashBeforePrepare(Bridge.QOS_ONCE_AND_ONLY_ONCE, false);
+ testCrashAndReconnectDestBasic(Bridge.QOS_DUPLICATES_OK, false);
}
+ //At most once
+ public void testCrashAndReconnectDestBasic_AtMostOnce_P() throws Exception
+ {
+ if (!ServerManagement.isRemote())
+ {
+ return;
+ }
+ testCrashAndReconnectDestBasic(Bridge.QOS_AT_MOST_ONCE, true);
+ }
- public void testCrashAndReconnectDestCrashOnCommit_OnceAndOnlyOnce_P() throws Exception
+ public void testCrashAndReconnectDestBasic_AtMostOnce_NP() throws Exception
{
if (!ServerManagement.isRemote())
{
return;
}
- testCrashAndReconnectDestCrashOnCommit(Bridge.QOS_ONCE_AND_ONLY_ONCE, true);
+ testCrashAndReconnectDestBasic(Bridge.QOS_AT_MOST_ONCE, false);
}
- public void testCrashAndReconnectDestCrashOnCommit_OnceAndOnlyOnce_NP() throws Exception
+
+ // Crash tests specific to XA transactions
+
+ public void testCrashAndReconnectDestCrashBeforePrepare_P() throws Exception
{
if (!ServerManagement.isRemote())
{
return;
}
- testCrashAndReconnectDestCrashOnCommit(Bridge.QOS_ONCE_AND_ONLY_ONCE, false);
+ testCrashAndReconnectDestCrashBeforePrepare(true);
}
+
+ public void testCrashAndReconnectDestCrashBeforePrepare_NP() throws Exception
+ {
+ if (!ServerManagement.isRemote())
+ {
+ return;
+ }
+ testCrashAndReconnectDestCrashBeforePrepare(false);
+ }
+
+
+
+ public void testCrashAndReconnectDestCrashOnCommit_P() throws Exception
+ {
+ if (!ServerManagement.isRemote())
+ {
+ return;
+ }
+ testCrashAndReconnectDestCrashOnCommit(true);
+ }
+
+ public void testCrashAndReconnectDestCrashOnCommit_NP() throws Exception
+ {
+ if (!ServerManagement.isRemote())
+ {
+ return;
+ }
+ testCrashAndReconnectDestCrashOnCommit(false);
+ }
/*
@@ -146,7 +189,7 @@
Connection connDest = null;
Bridge bridge = null;
-
+
try
{
ServerManagement.deployQueue("sourceQueue", 0);
@@ -258,21 +301,12 @@
prod.send(tm);
}
- //Messages should now be receivable
+ //If Qos=once and only once then all messages should be received
+ //If Qos=at most then only the second half will be received
+ //If Qos=dups ok then the the first half will be received twice followed by the second half
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons.receive(10000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- m = cons.receive(1000);
-
- assertNull(m);
-
+ checkMessagesReceived(qosMode, cons, NUM_MESSAGES);
+
//Make sure no messages are left in the source dest
MessageConsumer cons2 = sessSend.createConsumer(sourceQueue);
@@ -281,10 +315,7 @@
m = cons2.receive(1000);
- assertNull(m);
-
- log.info("Got here");
-
+ assertNull(m);
}
finally
{
@@ -346,6 +377,8 @@
}
+
+
/*
* Send some messages
* Crash the destination server
@@ -354,7 +387,7 @@
* Send some more messages
* Verify all messages are received
*/
- private void testCrashAndReconnectDestCrashBeforePrepare(int qosMode, boolean persistent) throws Exception
+ private void testCrashAndReconnectDestCrashBeforePrepare(boolean persistent) throws Exception
{
Connection connSource = null;
@@ -390,7 +423,7 @@
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
null, null, null, null,
- null, 1000, -1, qosMode,
+ null, 1000, -1, Bridge.QOS_ONCE_AND_ONLY_ONCE,
10, 5000,
null, null);
@@ -473,21 +506,8 @@
prod.send(tm);
}
- //Messages should now be receivable
+ checkMessagesReceived(Bridge.QOS_ONCE_AND_ONLY_ONCE, cons, NUM_MESSAGES);
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons.receive(10000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- m = cons.receive(1000);
-
- assertNull(m);
-
//Make sure no messages are left in the source dest
MessageConsumer cons2 = sessSend.createConsumer(sourceQueue);
@@ -567,7 +587,7 @@
* Send some more messages
* Verify all messages are received
*/
- private void testCrashAndReconnectDestCrashOnCommit(int qosMode, boolean persistent) throws Exception
+ private void testCrashAndReconnectDestCrashOnCommit(boolean persistent) throws Exception
{
Connection connSource = null;
@@ -605,7 +625,7 @@
bridge = new Bridge(cff0, cff1, sourceQueue, destQueue,
null, null, null, null,
- null, 1000, -1, qosMode,
+ null, 1000, -1, Bridge.QOS_ONCE_AND_ONLY_ONCE,
NUM_MESSAGES, 5000,
null, null);
@@ -654,10 +674,16 @@
ServerManagement.nullServer(1);
+ log.info("Poisoned server");
+
//Wait for maxBatchTime to kick in so a batch is sent
//This should cause the server to crash after prepare but before commit
+ //Also the wait must be enough to allow transaction recovery to kick in
+ //Since there will be a heuristically prepared branch on the consumer that needs to be rolled
+ //back
+
Thread.sleep(20000);
//Restart the server
@@ -672,11 +698,6 @@
log.info("Deployed queue");
-
- log.info("Now sleeping");
-
- Thread.sleep(120000);
-
log.info("Slept");
cff1 = new JNDIConnectionFactoryFactory(props1, "/ConnectionFactory");
@@ -704,21 +725,8 @@
prod.send(tm);
}
- //Messages should now be receivable
+ checkMessagesReceived(Bridge.QOS_ONCE_AND_ONLY_ONCE, cons, NUM_MESSAGES);
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage)cons.receive(10000);
-
- assertNotNull(tm);
-
- assertEquals("message" + i, tm.getText());
- }
-
- m = cons.receive(1000);
-
- assertNull(m);
-
//Make sure no messages are left in the source dest
MessageConsumer cons2 = sessSend.createConsumer(sourceQueue);
@@ -793,6 +801,47 @@
}
}
+ private void checkMessagesReceived(int qosMode, MessageConsumer cons, int numMessages) throws Exception
+ {
+ //Consume the messages
+
+ Set msgs = new HashSet();
+
+ while (true)
+ {
+ TextMessage tm = (TextMessage)cons.receive(2000);
+
+ if (tm == null)
+ {
+ break;
+ }
+
+ msgs.add(tm.getText());
+
+ }
+
+ if (qosMode == Bridge.QOS_ONCE_AND_ONLY_ONCE || qosMode == Bridge.QOS_DUPLICATES_OK)
+ {
+ //All the messages should be received
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ assertTrue(msgs.contains("message" + i));
+ }
+
+ //Should be no more
+ if (qosMode == Bridge.QOS_ONCE_AND_ONLY_ONCE)
+ {
+ assertEquals(numMessages, msgs.size());
+ }
+ }
+ else if (qosMode == Bridge.QOS_AT_MOST_ONCE)
+ {
+ //No *guarantee* that any messages will be received
+ //but you still might get some depending on how/where the crash occurred
+ }
+ }
+
// Inner classes -------------------------------------------------------------------
}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -72,6 +72,8 @@
{
try
{
+ log.info(this + " lookup: " + name);
+
return namingDelegate.lookup(name);
}
catch(Exception e)
Modified: trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2007-01-17 14:29:46 UTC (rev 1972)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2007-01-17 22:29:52 UTC (rev 1973)
@@ -63,6 +63,8 @@
public Context getInitialContext(Hashtable environment) throws NamingException
{
+ log.info(this + " getting intialcontext for " + environment);
+
String s = (String)environment.get(Constants.SERVER_INDEX_PROPERTY_NAME);
if (s == null)
More information about the jboss-cvs-commits
mailing list