[jboss-cvs] JBoss Messaging SVN: r5538 - in branches/Branch_1_4: tests/src/org/jboss/test/messaging/jms/bridge and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 18 07:30:25 EST 2008
Author: gaohoward
Date: 2008-12-18 07:30:25 -0500 (Thu, 18 Dec 2008)
New Revision: 5538
Modified:
branches/Branch_1_4/src/main/org/jboss/jms/server/bridge/Bridge.java
branches/Branch_1_4/src/main/org/jboss/jms/server/bridge/BridgeService.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectWithRecoveryTest.java
branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/SimpleCrashWithRestartTest.java
Log:
JBMESSAGING-999
Modified: branches/Branch_1_4/src/main/org/jboss/jms/server/bridge/Bridge.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/jms/server/bridge/Bridge.java 2008-12-18 10:15:55 UTC (rev 5537)
+++ branches/Branch_1_4/src/main/org/jboss/jms/server/bridge/Bridge.java 2008-12-18 12:30:25 UTC (rev 5538)
@@ -26,6 +26,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
+import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -58,6 +59,7 @@
* A Bridge
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:hgao at redhat.com">Howard Gao</a>
* @version <tt>$Revision$</tt>
*
* $Id$
@@ -164,14 +166,30 @@
private volatile boolean addMessageIDInHeader;
-
-
private boolean started;
private LinkedList<Message> messages;
private Object lock;
+ private String sourceCffName;
+
+ private String targetCffName;
+
+ private Properties sourceProviderProperties;
+
+ private Properties targetProviderProperties;
+
+ private String sourceDestName;
+
+ private String targetDestName;
+
+ private boolean isSameSourceAndTarget;
+
+ private String queueCffName;
+
+ private String topicCffName;
+
private ConnectionFactoryFactory sourceCff;
private ConnectionFactoryFactory targetCff;
@@ -220,14 +238,14 @@
* Constructor for MBean
*/
public Bridge()
- {
+ {
this.messages = new LinkedList<Message>();
- this.lock = new Object();
+ this.lock = new Object();
}
- public Bridge(ConnectionFactoryFactory sourceCff, ConnectionFactoryFactory destCff,
- DestinationFactory sourceDestinationFactory, DestinationFactory targetDestinationFactory,
+ public Bridge(boolean sameSourceNTarget, Properties srcProps, Properties tarProps,
+ String srcDestName, String tarDestName, String qCffName, String tCffName,
String sourceUsername, String sourcePassword,
String targetUsername, String targetPassword,
String selector, long failureRetryInterval,
@@ -236,41 +254,28 @@
int maxBatchSize, long maxBatchTime,
String subName, String clientID,
boolean addMessageIDInHeader)
- {
+ {
this();
- this.sourceCff = sourceCff;
-
- this.targetCff = destCff;
-
- this.sourceDestinationFactory = sourceDestinationFactory;
-
- this.targetDestinationFactory = targetDestinationFactory;
-
+ this.isSameSourceAndTarget = sameSourceNTarget;
+ this.sourceProviderProperties = srcProps;
+ this.targetProviderProperties = tarProps;
+ this.sourceDestName = srcDestName;
+ this.targetDestName = tarDestName;
+ this.queueCffName = qCffName;
+ this.topicCffName = tCffName;
this.sourceUsername = sourceUsername;
-
this.sourcePassword = sourcePassword;
-
this.targetUsername = targetUsername;
-
this.targetPassword = targetPassword;
-
this.selector = selector;
-
this.failureRetryInterval = failureRetryInterval;
-
this.maxRetries = maxRetries;
-
this.qualityOfServiceMode = qosMode;
-
this.maxBatchSize = maxBatchSize;
-
this.maxBatchTime = maxBatchTime;
-
this.subName = subName;
-
this.clientID = clientID;
-
this.addMessageIDInHeader = addMessageIDInHeader;
this.name = "Bridge-" + System.identityHashCode(this);
@@ -280,7 +285,6 @@
log.trace("Created " + this);
}
}
-
// MessagingComponent overrides --------------------------------------------------
@@ -703,46 +707,55 @@
return started;
}
- public synchronized void setSourceConnectionFactoryFactory(ConnectionFactoryFactory cff)
+ public void setSourceCFFName(String name)
{
- if (started)
- {
- log.warn(name + " Cannot set SourceConnectionFactoryFactory while bridge is started");
- return;
- }
- this.sourceCff = cff;
+ sourceCffName = name;
}
- public synchronized void setDestConnectionFactoryFactory(ConnectionFactoryFactory cff)
+ public void setTargetCFFName(String name)
{
- if (started)
- {
- log.warn(name + " Cannot set DestConnectionFactoryFactory while bridge is started");
- return;
- }
- this.targetCff = cff;
+ targetCffName = name;
}
+
+ public void setSourceProps(Properties sourceProps)
+ {
+ sourceProviderProperties = sourceProps;
+ }
+
+ public void setTargetProps(Properties targetProps)
+ {
+ targetProviderProperties = targetProps;
+ }
+
+ public void setSourceDestinationName(String sourceDestinationLookup)
+ {
+ sourceDestName = sourceDestinationLookup;
+ }
+
+ public void setTargetDestinationName(String targetDestinationLookup)
+ {
+ targetDestName = targetDestinationLookup;
+ }
+
+ public void setIsSameSourceAndTarget(boolean sameSourceAndTarget)
+ {
+ isSameSourceAndTarget = sameSourceAndTarget;
+ }
+
+ public void setQueueCffName(String name)
+ {
+ queueCffName = name;
+ }
+
+ public void setTopicCffName(String name)
+ {
+ topicCffName = name;
+ }
// Private -------------------------------------------------------------------
private void checkParams()
{
- if (sourceCff == null)
- {
- throw new IllegalArgumentException("sourceCff cannot be null");
- }
- if (targetCff == null)
- {
- throw new IllegalArgumentException("targetCff cannot be null");
- }
- if (sourceDestinationFactory == null)
- {
- throw new IllegalArgumentException("sourceDestinationFactory cannot be null");
- }
- if (targetDestinationFactory == null)
- {
- throw new IllegalArgumentException("targetDestinationFactory cannot be null");
- }
if (failureRetryInterval < 0 && failureRetryInterval != -1)
{
throw new IllegalArgumentException("failureRetryInterval must be > 0 or -1 to represent no retry");
@@ -919,9 +932,41 @@
try
{
//Lookup the destinations
- sourceDestination = sourceDestinationFactory.createDestination();
+ sourceDestinationFactory = new JNDIDestinationFactory(sourceProviderProperties, sourceDestName);
+ sourceDestination = sourceDestinationFactory.createDestination();
- targetDestination = targetDestinationFactory.createDestination();
+ targetDestinationFactory = new JNDIDestinationFactory(targetProviderProperties, targetDestName);
+ targetDestination = targetDestinationFactory.createDestination();
+
+ //factories
+ if(sourceDestination instanceof Topic)
+ {
+ sourceCffName = topicCffName;
+ }
+ else
+ {
+ sourceCffName = queueCffName;
+ }
+
+ sourceCff = new JNDIConnectionFactoryFactory(sourceProviderProperties, sourceCffName);
+
+ if (isSameSourceAndTarget)
+ {
+ targetCff = sourceCff;
+ }
+ else
+ {
+ if(targetDestination instanceof Topic)
+ {
+ targetCffName = topicCffName;
+ }
+ else
+ {
+ targetCffName = queueCffName;
+ }
+
+ targetCff = new JNDIConnectionFactoryFactory(targetProviderProperties, targetCffName);
+ }
if (sourceCff == targetCff)
{
@@ -946,11 +991,6 @@
}
}
- //Lookup the destinations
- sourceDestination = sourceDestinationFactory.createDestination();
-
- targetDestination = targetDestinationFactory.createDestination();
-
sourceConn = createConnection(sourceUsername, sourcePassword, sourceCff);
if (forwardMode != FORWARD_MODE_LOCALTX)
@@ -1661,5 +1701,6 @@
}
}
}
- }
+ }
+
}
Modified: branches/Branch_1_4/src/main/org/jboss/jms/server/bridge/BridgeService.java
===================================================================
--- branches/Branch_1_4/src/main/org/jboss/jms/server/bridge/BridgeService.java 2008-12-18 10:15:55 UTC (rev 5537)
+++ branches/Branch_1_4/src/main/org/jboss/jms/server/bridge/BridgeService.java 2008-12-18 12:30:25 UTC (rev 5538)
@@ -317,53 +317,16 @@
Properties targetProps = (Properties)server.getAttribute(targetProviderLoader, "Properties");
- // JBMESSAGING-1183: set the factory refs according to the destinations types
- Context icSource = new InitialContext(sourceProps);
- Context icTarget = new InitialContext(targetProps);
- Destination sourceDest = (Destination)icSource.lookup(sourceDestinationLookup);
- Destination targetDest = (Destination)icTarget.lookup(targetDestinationLookup);
- String sourceFactoryRef = "QueueFactoryRef";
- if(sourceDest instanceof Topic)
- {
- sourceFactoryRef = "TopicFactoryRef";
- }
- String targetFactoryRef = "QueueFactoryRef";
- if(targetDest instanceof Topic)
- {
- targetFactoryRef = "TopicFactoryRef";
- }
-
- String sourceCFRef = (String)server.getAttribute(sourceProviderLoader, sourceFactoryRef);
+ String queueCffName = (String)server.getAttribute(getSourceProviderLoader(), "QueueFactoryRef");
+ String topicCffName = (String)server.getAttribute(getSourceProviderLoader(), "TopicFactoryRef");
- String targetCFRef = (String)server.getAttribute(targetProviderLoader, targetFactoryRef);
-
- ConnectionFactoryFactory sourceCff =
- new JNDIConnectionFactoryFactory(sourceProps, sourceCFRef);
-
- ConnectionFactoryFactory destCff;
-
- if (sameSourceAndTarget)
- {
- destCff = sourceCff;
- }
- else
- {
- destCff= new JNDIConnectionFactoryFactory(targetProps, targetCFRef);
- }
-
- bridge.setName(serviceName.getCanonicalName());
-
- bridge.setSourceConnectionFactoryFactory(sourceCff);
-
- bridge.setDestConnectionFactoryFactory(destCff);
-
- DestinationFactory sourceDestinationFactory = new JNDIDestinationFactory(sourceProps, sourceDestinationLookup);
-
- DestinationFactory targetDestinationFactory = new JNDIDestinationFactory(targetProps, targetDestinationLookup);
-
- bridge.setSourceDestinationFactory(sourceDestinationFactory);
-
- bridge.setTargetDestinationFactory(targetDestinationFactory);
+ bridge.setIsSameSourceAndTarget(sameSourceAndTarget);
+ bridge.setSourceProps(sourceProps);
+ bridge.setTargetProps(targetProps);
+ bridge.setSourceDestinationName(sourceDestinationLookup);
+ bridge.setTargetDestinationName(targetDestinationLookup);
+ bridge.setQueueCffName(queueCffName);
+ bridge.setTopicCffName(topicCffName);
bridge.start();
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java 2008-12-18 10:15:55 UTC (rev 5537)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeMBeanTest.java 2008-12-18 12:30:25 UTC (rev 5538)
@@ -35,6 +35,7 @@
import javax.naming.InitialContext;
import org.jboss.jms.server.bridge.Bridge;
+import org.jboss.jms.server.bridge.BridgeService;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.tools.ServerManagement;
@@ -89,6 +90,83 @@
super.tearDown();
}
+ //destination not available when startup
+ //https://jira.jboss.org/jira/browse/JBMESSAGING-999
+ public void testDestinationNotAvailableWhenBridgeStartup() throws Exception
+ {
+ ObjectName on = null;
+
+ try
+ {
+ //crash the dest server first
+
+ log.info("About to crash server");
+
+ ServerManagement.kill(1);
+
+ on = deployBridge(0, "Bridge3", sourceProviderLoader, targetProviderLoader,
+ "/queue/sourceQueue", "/queue/targetQueue",
+ null, null, null, null,
+ Bridge.QOS_AT_MOST_ONCE, null, 1,
+ -1, null, null, 5000, -1, false);
+ log.info("Deployed bridge");
+
+ ServerManagement.getServer(0).invoke(on, "create", new Object[0], new String[0]);
+
+ log.info("Created bridge");
+
+ log.info("Starting bridge");
+ ServerManagement.getServer(0).invoke(on, "start", new Object[0], new String[0]);
+ log.info("Started bridge");
+
+
+ //Wait a while before starting up to simulate the dest being down for a while
+ log.info("Waiting 3 secs before bringing server back up");
+ Thread.sleep(3000);
+ log.info("Done wait");
+ //Restart the server
+
+ log.info("Restarting server");
+
+ ServerManagement.start(1, "all", false);
+
+ ServerManagement.deployQueue("targetQueue", 1);
+
+ setUpAdministeredObjects();
+
+ //Wait a while before starting up to simulate the dest being down for a while
+ log.info("Waiting 5 secs before bringing server back up");
+ Thread.sleep(5000);
+ log.info("Done wait");
+
+ final int NUM_MESSAGES = 10;
+
+ //Send some messages
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, true);
+
+ log.info("Sent messages");
+
+ checkMessagesReceived(cf1, targetQueue, Bridge.QOS_ONCE_AND_ONLY_ONCE, NUM_MESSAGES, false);
+ }
+ finally
+ {
+ try
+ {
+ if (on != null)
+ {
+ ServerManagement.getServer(0).invoke(on, "stop", new Object[0], new String[0]);
+ ServerManagement.getServer(0).invoke(on, "destroy", new Object[0], new String[0]);
+ }
+ }
+ catch(Exception e)
+ {
+ //Ignore
+ }
+ }
+
+ }
+
public void testStopStartPauseResume() throws Exception
{
Connection connSource = null;
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java 2008-12-18 10:15:55 UTC (rev 5537)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTest.java 2008-12-18 12:30:25 UTC (rev 5538)
@@ -366,17 +366,18 @@
try
{
- bridge= new Bridge(null, cff1, sourceQueueFactory, targetQueueFactory,
- sourceUsername, sourcePassword, destUsername, destPassword,
- selector, failureRetryInterval, maxRetries, qosMode,
- batchSize, maxBatchTime,
- subName, clientID, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ sourceUsername, sourcePassword, destUsername, destPassword,
+ selector, failureRetryInterval, maxRetries, qosMode,
+ batchSize, maxBatchTime, subName, clientID, false);
}
catch (IllegalArgumentException e)
{
//Ok
}
-
+
+/*
try
{
bridge= new Bridge(cff0, null, sourceQueueFactory, targetQueueFactory,
@@ -389,7 +390,7 @@
{
//Ok
}
-
+
try
{
bridge= new Bridge(cff0, cff1, null, targetQueueFactory,
@@ -415,14 +416,14 @@
{
//Ok
}
-
+*/
try
{
- bridge= new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- sourceUsername, sourcePassword, destUsername, destPassword,
- selector, -2, maxRetries, qosMode,
- batchSize, maxBatchTime,
- subName, clientID, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ sourceUsername, sourcePassword, destUsername, destPassword,
+ selector, -2, maxRetries, qosMode,
+ batchSize, maxBatchTime, subName, clientID, false);
}
catch (IllegalArgumentException e)
{
@@ -431,24 +432,25 @@
try
{
- bridge= new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- sourceUsername, sourcePassword, destUsername, destPassword,
- selector, -1, 10, qosMode,
- batchSize, maxBatchTime,
- subName, clientID, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ sourceUsername, sourcePassword, destUsername, destPassword,
+ selector, -1, 10, qosMode,
+ batchSize, maxBatchTime, subName, clientID, false);
}
catch (IllegalArgumentException e)
{
//Ok
}
-
+
+
try
{
- bridge= new Bridge(cff0, cff1, sourceQueueFactory, null,
- sourceUsername, sourcePassword, destUsername, destPassword,
- selector, failureRetryInterval, maxRetries, -2,
- batchSize, maxBatchTime,
- subName, clientID, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ sourceUsername, sourcePassword, destUsername, destPassword,
+ selector, failureRetryInterval, maxRetries, -2,
+ batchSize, maxBatchTime, subName, clientID, false);
}
catch (IllegalArgumentException e)
{
@@ -457,11 +459,11 @@
try
{
- bridge= new Bridge(cff0, cff1, sourceQueueFactory, null,
- sourceUsername, sourcePassword, destUsername, destPassword,
- selector, failureRetryInterval, maxRetries, 3,
- batchSize, maxBatchTime,
- subName, clientID, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ sourceUsername, sourcePassword, destUsername, destPassword,
+ selector, failureRetryInterval, maxRetries, 3,
+ batchSize, maxBatchTime, subName, clientID, false);
}
catch (IllegalArgumentException e)
{
@@ -470,11 +472,11 @@
try
{
- bridge= new Bridge(cff0, cff1, sourceQueueFactory, null,
- sourceUsername, sourcePassword, destUsername, destPassword,
- selector, failureRetryInterval, maxRetries, 3,
- 0, maxBatchTime,
- subName, clientID, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ sourceUsername, sourcePassword, destUsername, destPassword,
+ selector, failureRetryInterval, maxRetries, 3,
+ 0, maxBatchTime, subName, clientID, false);
}
catch (IllegalArgumentException e)
{
@@ -483,11 +485,11 @@
try
{
- bridge= new Bridge(cff0, cff1, sourceQueueFactory, null,
- sourceUsername, sourcePassword, destUsername, destPassword,
- selector, failureRetryInterval, maxRetries, 3,
- batchSize, -2,
- subName, clientID, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ sourceUsername, sourcePassword, destUsername, destPassword,
+ selector, failureRetryInterval, maxRetries, 3,
+ batchSize, -2, subName, clientID, false);
}
catch (IllegalArgumentException e)
{
@@ -517,11 +519,11 @@
String selector = "vegetable='radish'";
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- selector, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
- 1, -1,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ selector, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
+ 1, -1, null, null, false);
bridge.start();
@@ -611,11 +613,11 @@
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff1, sourceTopicFactory, targetQueueFactory,
- null, null, null, null,
- null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
- 1, -1,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/topic/sourceTopic", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
+ 1, -1, null, null, false);
bridge.start();
@@ -663,11 +665,11 @@
{
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff1, sourceTopicFactory, targetQueueFactory,
- null, null, null, null,
- null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
- 1, -1,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/topic/sourceTopic", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
+ 1, -1, null, null, false);
bridge.start();
@@ -692,11 +694,11 @@
{
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff1, sourceTopicFactory, targetQueueFactory,
- null, null, null, null,
- null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
- 1, -1,
- "subTest", "clientid123", false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/topic/sourceTopic", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
+ 1, -1, "subTest", "clientid123", false);
bridge.start();
@@ -742,11 +744,11 @@
{
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
- 1, -1,
- null, null, on);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
+ 1, -1, null, null, on);
bridge.start();
@@ -913,11 +915,11 @@
{
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
- 1, -1,
- null, null, messageIDInHeader);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
+ 1, -1, null, null, messageIDInHeader);
bridge.start();
@@ -1074,11 +1076,11 @@
{
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
- 1, -1,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, Bridge.QOS_AT_MOST_ONCE,
+ 1, -1, null, null, false);
bridge.start();
@@ -1161,12 +1163,13 @@
try
{
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 5000, 10, qosMode,
- batchSize, -1,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, qosMode,
+ batchSize, -1, null, null, false);
+
bridge.start();
connSource = cf0.createConnection();
@@ -1234,11 +1237,11 @@
try
{
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 5000, 10, qosMode,
- 2, maxBatchTime,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, qosMode,
+ 2, maxBatchTime, null, null, false);
bridge.start();
@@ -1308,11 +1311,11 @@
try
{
- bridge = new Bridge(cff0, cff0, sourceQueueFactory, localTargetQueueFactory,
- null, null, null, null,
- null, 5000, 10, qosMode,
- batchSize, -1,
- null, null, false);
+ bridge = new Bridge(true, sourceProps, sourceProps, "/queue/sourceQueue", "/queue/localTargetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, qosMode,
+ batchSize, -1, null, null, false);
bridge.start();
@@ -1380,11 +1383,11 @@
{
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 5000, 10, qosMode,
- NUM_MESSAGES, -1,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, qosMode,
+ NUM_MESSAGES, -1, null, null, false);
bridge.start();
@@ -1438,11 +1441,11 @@
{
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff0, sourceQueueFactory, localTargetQueueFactory,
- null, null, null, null,
- null, 5000, 10, qosMode,
- NUM_MESSAGES, -1,
- null, null, false);
+ bridge = new Bridge(true, sourceProps, sourceProps, "/queue/sourceQueue", "/queue/localTargetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 5000, 10, qosMode,
+ NUM_MESSAGES, -1, null, null, false);
bridge.start();
@@ -1498,11 +1501,11 @@
final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 3000, 10, qosMode,
- MAX_BATCH_SIZE, MAX_BATCH_TIME,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 3000, 10, qosMode,
+ MAX_BATCH_SIZE, MAX_BATCH_TIME, null, null, false);
bridge.start();
@@ -1539,11 +1542,11 @@
final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
- bridge = new Bridge(cff0, cff0, sourceQueueFactory, localTargetQueueFactory,
- null, null, null, null,
- null, 3000, 10, qosMode,
- MAX_BATCH_SIZE, MAX_BATCH_TIME,
- null, null, false);
+ bridge = new Bridge(true, sourceProps, sourceProps, "/queue/sourceQueue", "/queue/localTargetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 3000, 10, qosMode,
+ MAX_BATCH_SIZE, MAX_BATCH_TIME, null, null, false);
bridge.start();
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java 2008-12-18 10:15:55 UTC (rev 5537)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java 2008-12-18 12:30:25 UTC (rev 5538)
@@ -21,8 +21,10 @@
*/
package org.jboss.test.messaging.jms.bridge;
+import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Properties;
import java.util.Set;
import javax.jms.Connection;
@@ -52,6 +54,7 @@
* A BridgeTestBase
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:hgao at redhat.com">Howard Gao</a>
* @version <tt>$Revision: 1.1 $</tt>
*
* $Id$
@@ -75,6 +78,10 @@
protected static boolean firstTime = true;
+ protected static Properties sourceProps;
+
+ protected static Properties targetProps;
+
public BridgeTestBase(String name)
{
super(name);
@@ -135,7 +142,22 @@
{
Hashtable props0 = ServerManagement.getJNDIEnvironment(0);
+ sourceProps = new Properties();
+ Enumeration keys = props0.keys();
+ while (keys.hasMoreElements())
+ {
+ Object key = keys.nextElement();
+ sourceProps.put(key, props0.get(key));
+ }
+
Hashtable props1 = ServerManagement.getJNDIEnvironment(1);
+ targetProps = new Properties();
+ keys = props1.keys();
+ while (keys.hasMoreElements())
+ {
+ Object key = keys.nextElement();
+ targetProps.put(key, props1.get(key));
+ }
cff0 = new JNDIConnectionFactoryFactory(props0, "/ConnectionFactory");
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java 2008-12-18 10:15:55 UTC (rev 5537)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectTest.java 2008-12-18 12:30:25 UTC (rev 5538)
@@ -22,6 +22,7 @@
package org.jboss.test.messaging.jms.bridge;
import org.jboss.jms.server.bridge.Bridge;
+import org.jboss.jms.server.bridge.BridgeService;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.tools.ServerManagement;
@@ -43,6 +44,69 @@
// Crash and reconnect
+ //destination not available when startup
+ //https://jira.jboss.org/jira/browse/JBMESSAGING-999
+ public void testDestinationNotAvailableWhenBridgeStartup() throws Exception
+ {
+ Bridge bridge = null;
+
+ try
+ {
+ //crash the dest server first
+
+ log.info("About to crash server");
+
+ ServerManagement.kill(1);
+
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory", null, null, null, null,
+ null, 1000, -1, Bridge.QOS_ONCE_AND_ONLY_ONCE, 10, -1, null, null, false);
+
+ bridge.start();
+
+ //Restart the server
+
+ log.info("Restarting server");
+
+ ServerManagement.start(1, "all", false);
+
+ ServerManagement.deployQueue("targetQueue", 1);
+
+ setUpAdministeredObjects();
+
+ //Wait a while before starting up to simulate the dest being down for a while
+ log.info("Waiting 5 secs before bringing server back up");
+ Thread.sleep(5000);
+ log.info("Done wait");
+
+ final int NUM_MESSAGES = 10;
+
+ //Send some messages
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, true);
+
+ log.info("Sent messages");
+
+ checkMessagesReceived(cf1, targetQueue, Bridge.QOS_ONCE_AND_ONLY_ONCE, NUM_MESSAGES, false);
+ }
+ finally
+ {
+
+ if (bridge != null)
+ {
+ try
+ {
+ bridge.stop();
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to stop bridge", e);
+ }
+ }
+ }
+
+ }
+
// Once and only once
public void testCrashAndReconnectDestBasic_OnceAndOnlyOnce_P() throws Exception
@@ -97,12 +161,11 @@
{
ServerManagement.kill(1);
- Bridge bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 1000, -1, Bridge.QOS_DUPLICATES_OK,
- 10, -1,
- null, null, false);
+ Bridge bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory", null, null, null, null,
+ null, 1000, -1, Bridge.QOS_DUPLICATES_OK, 10, -1, null, null, false);
+
try
{
bridge.start();
@@ -144,11 +207,10 @@
try
{
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 1000, -1, qosMode,
- 10, -1,
- null, null, false);
+
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory", null, null, null, null,
+ null, 1000, -1, qosMode, 10, -1, null, null, false);
bridge.start();
@@ -224,11 +286,10 @@
try
{
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 1000, -1, Bridge.QOS_ONCE_AND_ONLY_ONCE,
- 10, 5000,
- null, null, false);
+
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory", null, null, null, null,
+ null, 1000, -1, Bridge.QOS_ONCE_AND_ONLY_ONCE, 10, 5000, null, null, false);
bridge.start();
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectWithRecoveryTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectWithRecoveryTest.java 2008-12-18 10:15:55 UTC (rev 5537)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/ReconnectWithRecoveryTest.java 2008-12-18 12:30:25 UTC (rev 5538)
@@ -89,11 +89,11 @@
{
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 1000, -1, Bridge.QOS_ONCE_AND_ONLY_ONCE,
- NUM_MESSAGES, -1,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 1000, -1, Bridge.QOS_ONCE_AND_ONLY_ONCE,
+ NUM_MESSAGES, -1, null, null, false);
bridge.start();
Modified: branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/SimpleCrashWithRestartTest.java
===================================================================
--- branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/SimpleCrashWithRestartTest.java 2008-12-18 10:15:55 UTC (rev 5537)
+++ branches/Branch_1_4/tests/src/org/jboss/test/messaging/jms/bridge/SimpleCrashWithRestartTest.java 2008-12-18 12:30:25 UTC (rev 5538)
@@ -89,11 +89,11 @@
{
final int NUM_MESSAGES = 10;
- bridge = new Bridge(cff0, cff1, sourceQueueFactory, targetQueueFactory,
- null, null, null, null,
- null, 1000, -1, Bridge.QOS_AT_MOST_ONCE,
- NUM_MESSAGES, -1,
- null, null, false);
+ bridge = new Bridge(false, sourceProps, targetProps, "/queue/sourceQueue", "/queue/targetQueue",
+ "/ConnectionFactory", "/ConnectionFactory",
+ null, null, null, null,
+ null, 1000, -1, Bridge.QOS_AT_MOST_ONCE,
+ NUM_MESSAGES, -1, null, null, false);
bridge.start();
More information about the jboss-cvs-commits
mailing list