JBoss hornetq SVN: r10259 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ssl.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-02-27 05:24:21 -0500 (Sun, 27 Feb 2011)
New Revision: 10259
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java
Log:
added super for setup
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java 2011-02-26 09:12:02 UTC (rev 10258)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java 2011-02-27 10:24:21 UTC (rev 10259)
@@ -140,6 +140,7 @@
@Override
protected void setUp() throws Exception
{
+ super.setUp();
ConfigurationImpl config = createBasicConfig();
config.setSecurityEnabled(false);
Map<String, Object> params = new HashMap<String, Object>();
13 years, 10 months
JBoss hornetq SVN: r10258 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-02-26 04:12:02 -0500 (Sat, 26 Feb 2011)
New Revision: 10258
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
add check for tests still broadcasting at teardown
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-02-26 08:26:15 UTC (rev 10257)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-02-26 09:12:02 UTC (rev 10258)
@@ -914,6 +914,19 @@
fail("test left serverlocator running, this could effect other tests");
// System.exit(0);
}
+ else if (stackTraceElement.getMethodName().contains("BroadcastGroupImpl.run") && !alreadyFailedThread.contains(thread))
+ {
+ alreadyFailedThread.add(thread);
+ System.out.println(threadDump(this.getName() + " has left threads running. Look at thread " +
+ thread.getName() +
+ " id = " +
+ thread.getId() +
+ " is still broadcasting " +
+ this.getName() +
+ " on this following dump"));
+ fail("test left broadcastgroupimpl running, this could effect other tests");
+ // System.exit(0);
+ }
}
}
13 years, 10 months
JBoss hornetq SVN: r10257 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-02-26 03:26:15 -0500 (Sat, 26 Feb 2011)
New Revision: 10257
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/SessionFactoryTest.java
Log:
fixed locator leak
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/SessionFactoryTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/SessionFactoryTest.java 2011-02-26 01:43:43 UTC (rev 10256)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/SessionFactoryTest.java 2011-02-26 08:26:15 UTC (rev 10257)
@@ -99,6 +99,8 @@
ServerLocator csi = (ServerLocator)ois.readObject();
Assert.assertNotNull(csi);
+
+ csi.close();
locator.close();
}
13 years, 10 months
JBoss hornetq SVN: r10256 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-02-25 20:43:43 -0500 (Fri, 25 Feb 2011)
New Revision: 10256
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
removing check
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-02-25 22:38:28 UTC (rev 10255)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-02-26 01:43:43 UTC (rev 10256)
@@ -949,7 +949,7 @@
}
- assertFalse("Thread Failed", failedThread);
+ //assertFalse("Thread Failed", failedThread);
super.tearDown();
}
13 years, 10 months
JBoss hornetq SVN: r10255 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-02-25 17:38:28 -0500 (Fri, 25 Feb 2011)
New Revision: 10255
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
Log:
Adding test to lookup for leaking threads (temporary commit, will be removed)
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-02-25 22:23:58 UTC (rev 10254)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/UnitTestCase.java 2011-02-25 22:38:28 UTC (rev 10255)
@@ -949,7 +949,7 @@
}
- //assertFalse("Thread Failed", failedThread);
+ assertFalse("Thread Failed", failedThread);
super.tearDown();
}
13 years, 10 months
JBoss hornetq SVN: r10254 - in branches/Branch_2_2_EAP: native/src and 3 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-02-25 17:23:58 -0500 (Fri, 25 Feb 2011)
New Revision: 10254
Added:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/asyncio/impl/HornetQFileLock.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/AIOFileLockNodeManager.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/core/server/impl/FileLockTest.java
Modified:
branches/Branch_2_2_EAP/native/bin/libHornetQAIO64.so
branches/Branch_2_2_EAP/native/src/JNI_AsynchronousFileImpl.cpp
branches/Branch_2_2_EAP/native/src/Version.h
branches/Branch_2_2_EAP/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/FileLockNodeManager.java
branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
Log:
JBPAPP-5956 - Workaround for gfs2 bug with fctl (adding a native call for flock)
Modified: branches/Branch_2_2_EAP/native/bin/libHornetQAIO64.so
===================================================================
(Binary files differ)
Modified: branches/Branch_2_2_EAP/native/src/JNI_AsynchronousFileImpl.cpp
===================================================================
--- branches/Branch_2_2_EAP/native/src/JNI_AsynchronousFileImpl.cpp 2011-02-25 11:40:04 UTC (rev 10253)
+++ branches/Branch_2_2_EAP/native/src/JNI_AsynchronousFileImpl.cpp 2011-02-25 22:23:58 UTC (rev 10254)
@@ -18,8 +18,8 @@
#include <fcntl.h>
#include <string>
#include <time.h>
+#include <sys/file.h>
-
#include "org_hornetq_core_asyncio_impl_AsynchronousFileImpl.h"
@@ -38,9 +38,48 @@
return (AIOController *) env->GetDirectBufferAddress(controllerAddress);
}
+/* Inaccessible static: log */
+/* Inaccessible static: totalMaxIO */
+/* Inaccessible static: loaded */
+/* Inaccessible static: EXPECTED_NATIVE_VERSION */
+/*
+ * Class: org_hornetq_core_asyncio_impl_AsynchronousFileImpl
+ * Method: openFile
+ * Signature: (Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_openFile
+ (JNIEnv * env , jclass , jstring jstrFileName)
+{
+ std::string fileName = convertJavaString(env, jstrFileName);
+ return open(fileName.data(), O_RDWR | O_CREAT, 0666);
+}
/*
+ * Class: org_hornetq_core_asyncio_impl_AsynchronousFileImpl
+ * Method: closeFile
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_closeFile
+ (JNIEnv * , jclass , jint handle)
+{
+ close(handle);
+}
+
+/*
+ * Class: org_hornetq_core_asyncio_impl_AsynchronousFileImpl
+ * Method: flock
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_hornetq_core_asyncio_impl_AsynchronousFileImpl_flock
+ (JNIEnv * , jclass , jint handle)
+{
+ return flock(handle, LOCK_EX | LOCK_NB) == 0;
+}
+
+
+
+/*
* Class: org_jboss_jaio_libaioimpl_LibAIOController
* Method: init
* Signature: (Ljava/lang/String;Ljava/lang/Class;)J
Modified: branches/Branch_2_2_EAP/native/src/Version.h
===================================================================
--- branches/Branch_2_2_EAP/native/src/Version.h 2011-02-25 11:40:04 UTC (rev 10253)
+++ branches/Branch_2_2_EAP/native/src/Version.h 2011-02-25 22:23:58 UTC (rev 10254)
@@ -3,6 +3,6 @@
// This definition needs to match org.hornetq.core.asyncio.impl.AsynchronousFileImpl.EXPECTED_NATIVE_VERSION
// Or else the native module won't be loaded because of version mismatches
-#define _VERSION_NATIVE_AIO 30
+#define _VERSION_NATIVE_AIO 31
#endif
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java 2011-02-25 11:40:04 UTC (rev 10253)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/asyncio/impl/AsynchronousFileImpl.java 2011-02-25 22:23:58 UTC (rev 10254)
@@ -14,6 +14,7 @@
package org.hornetq.core.asyncio.impl;
import java.nio.ByteBuffer;
+import java.nio.channels.FileLock;
import java.util.PriorityQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Semaphore;
@@ -51,7 +52,7 @@
/** This definition needs to match Version.h on the native sources.
Or else the native module won't be loaded because of version mismatches */
- private static int EXPECTED_NATIVE_VERSION = 30;
+ private static int EXPECTED_NATIVE_VERSION = 31;
/** Used to determine the next writing sequence */
private final AtomicLong nextWritingSequence = new AtomicLong(0);
@@ -615,8 +616,29 @@
// completely done, or we might get beautiful GPFs
pollerLatch.await();
}
+
+ public static FileLock lock(int handle)
+ {
+ if (flock(handle))
+ {
+ return new HornetQFileLock(handle);
+ }
+ else
+ {
+ return null;
+ }
+ }
// Native ----------------------------------------------------------------------------
+
+
+ // Functions used for locking files .....
+ public static native int openFile(String fileName);
+
+ public static native void closeFile(int handle);
+
+ private static native boolean flock(int handle);
+ // Functions used for locking files ^^^^^^^^
private static native void resetBuffer(ByteBuffer directByteBuffer, int size);
Added: branches/Branch_2_2_EAP/src/main/org/hornetq/core/asyncio/impl/HornetQFileLock.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/asyncio/impl/HornetQFileLock.java (rev 0)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/asyncio/impl/HornetQFileLock.java 2011-02-25 22:23:58 UTC (rev 10254)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.asyncio.impl;
+
+import java.io.IOException;
+import java.nio.channels.FileLock;
+
+/**
+ * A HornetQFileLock
+ *
+ * @author clebertsuconic
+ *
+ *
+ */
+public class HornetQFileLock extends FileLock
+{
+
+ private final int handle;
+
+ /**
+ * @param channel
+ * @param position
+ * @param size
+ * @param shared
+ */
+ protected HornetQFileLock(final int handle)
+ {
+ super(null, 0, 0, false);
+ this.handle = handle;
+ }
+
+ @Override
+ public boolean isValid()
+ {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see java.nio.channels.FileLock#release()
+ */
+ @Override
+ public void release() throws IOException
+ {
+ AsynchronousFileImpl.closeFile(handle);
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/AIOFileLockNodeManager.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/AIOFileLockNodeManager.java (rev 0)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/AIOFileLockNodeManager.java 2011-02-25 22:23:58 UTC (rev 10254)
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.core.server.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.channels.FileLock;
+
+import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
+
+/**
+ * This is using the HornetQ Libaio Native to perform calls to flock on Linux system
+ * At the current version of RHEL there's a bug on GFS2 and because of that fctl is not functional
+ * what will cause issues on Failover over Shared Storage.
+ *
+ * This will provide an alternative to perform locks through our native module until fctl is fixed on Linux.
+ *
+ * https://bugzilla.redhat.com/show_bug.cgi?id=678585
+ *
+ * @author clebertsuconic
+ *
+ *
+ */
+public class AIOFileLockNodeManager extends FileLockNodeManager
+{
+
+ /**
+ * @param directory
+ */
+ public AIOFileLockNodeManager(final String directory)
+ {
+ super(directory);
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+ @Override
+ protected FileLock tryLock(final int lockPos) throws Exception
+ {
+ File file = newFileForRegionLock(lockPos);
+
+ int handle = AsynchronousFileImpl.openFile(file.getAbsolutePath());
+
+ if (handle < 0)
+ {
+ throw new IOException("couldn't open file " + file.getAbsolutePath());
+ }
+
+ FileLock lock = AsynchronousFileImpl.lock(handle);
+
+ if (lock == null)
+ {
+ AsynchronousFileImpl.closeFile(handle);
+ }
+
+ return lock;
+
+ }
+
+ @Override
+ protected FileLock lock(final int liveLockPos) throws IOException
+ {
+ File file = newFileForRegionLock(liveLockPos);
+
+ int handle = AsynchronousFileImpl.openFile(file.getAbsolutePath());
+
+ if (handle < 0)
+ {
+ throw new IOException("couldn't open file " + file.getAbsolutePath());
+ }
+
+ while (!interrupted)
+ {
+ FileLock lockFile = AsynchronousFileImpl.lock(handle);
+ if (lockFile != null)
+ {
+ return lockFile;
+ }
+ else
+ {
+ try
+ {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e)
+ {
+ return null;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param liveLockPos
+ * @return
+ */
+ protected File newFileForRegionLock(final int liveLockPos)
+ {
+ File file = newFile("server." + liveLockPos + ".lock");
+ return file;
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/FileLockNodeManager.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/FileLockNodeManager.java 2011-02-25 11:40:04 UTC (rev 10253)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/FileLockNodeManager.java 2011-02-25 22:23:58 UTC (rev 10254)
@@ -13,12 +13,6 @@
package org.hornetq.core.server.impl;
-import org.hornetq.api.core.SimpleString;
-import org.hornetq.core.logging.Logger;
-import org.hornetq.core.server.NodeManager;
-import org.hornetq.utils.UUID;
-import org.hornetq.utils.UUIDGenerator;
-
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
@@ -26,6 +20,12 @@
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.server.NodeManager;
+import org.hornetq.utils.UUID;
+import org.hornetq.utils.UUIDGenerator;
+
/**
* @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
* Date: Oct 13, 2010
@@ -35,13 +35,13 @@
{
private static final Logger log = Logger.getLogger(FileLockNodeManager.class);
- private static final String SERVER_LOCK_NAME = "server.lock";
+ protected static final String SERVER_LOCK_NAME = "server.lock";
private static final String ACCESS_MODE = "rw";
- private static final int LIVE_LOCK_POS = 1;
+ private static final int LIVE_LOCK_POS = 1;
- private static final int BACKUP_LOCK_POS = 2;
+ private static final int BACKUP_LOCK_POS = 2;
private static final int LOCK_LENGTH = 1;
@@ -63,34 +63,34 @@
private final String directory;
- boolean interrupted = false;
+ protected boolean interrupted = false;
-
public FileLockNodeManager(final String directory)
{
this.directory = directory;
}
+ @Override
public void start() throws Exception
{
- if(isStarted())
+ if (isStarted())
{
return;
}
- File file = new File(directory, SERVER_LOCK_NAME);
+ File file = newFile(FileLockNodeManager.SERVER_LOCK_NAME);
boolean fileCreated = false;
if (!file.exists())
{
fileCreated = file.createNewFile();
- if(!fileCreated)
+ if (!fileCreated)
{
throw new IllegalStateException("Unable to create server lock file");
}
}
- RandomAccessFile raFile = new RandomAccessFile(file, ACCESS_MODE);
+ RandomAccessFile raFile = new RandomAccessFile(file, FileLockNodeManager.ACCESS_MODE);
channel = raFile.getChannel();
@@ -98,9 +98,9 @@
{
ByteBuffer id = ByteBuffer.allocateDirect(3);
byte[] bytes = new byte[3];
- bytes[0] = FIRST_TIME_START;
- bytes[1] = FIRST_TIME_START;
- bytes[2] = FIRST_TIME_START;
+ bytes[0] = FileLockNodeManager.FIRST_TIME_START;
+ bytes[1] = FileLockNodeManager.FIRST_TIME_START;
+ bytes[2] = FileLockNodeManager.FIRST_TIME_START;
id.put(bytes, 0, 3);
id.position(0);
channel.write(id, 0);
@@ -112,6 +112,7 @@
super.start();
}
+ @Override
public void stop() throws Exception
{
channel.close();
@@ -122,14 +123,15 @@
@Override
public boolean isAwaitingFailback() throws Exception
{
- return getState() == FAILINGBACK;
+ return getState() == FileLockNodeManager.FAILINGBACK;
}
+ @Override
public boolean isBackupLive() throws Exception
{
FileLock liveAttemptLock;
- liveAttemptLock = channel.tryLock(LIVE_LOCK_POS, LOCK_LENGTH, false);
- if(liveAttemptLock == null)
+ liveAttemptLock = tryLock(FileLockNodeManager.LIVE_LOCK_POS);
+ if (liveAttemptLock == null)
{
return true;
}
@@ -139,7 +141,13 @@
return false;
}
}
+
+ public boolean isLiveLocked()
+ {
+ return liveLock != null;
+ }
+
@Override
public void interrupt()
{
@@ -152,66 +160,69 @@
releaseBackupLock();
}
-
+ @Override
public void awaitLiveNode() throws Exception
{
do
{
byte state = getState();
- while (state == NOT_STARTED || state == FIRST_TIME_START)
+ while (state == FileLockNodeManager.NOT_STARTED || state == FileLockNodeManager.FIRST_TIME_START)
{
- log.debug("awaiting live node startup state='" + state + "'");
+ FileLockNodeManager.log.debug("awaiting live node startup state='" + state + "'");
Thread.sleep(2000);
state = getState();
}
- liveLock = lock(LIVE_LOCK_POS, 1);
+ liveLock = lock(FileLockNodeManager.LIVE_LOCK_POS);
state = getState();
- if (state == PAUSED)
+ if (state == FileLockNodeManager.PAUSED)
{
liveLock.release();
- log.debug("awaiting live node restarting");
+ FileLockNodeManager.log.debug("awaiting live node restarting");
Thread.sleep(2000);
}
- else if (state == FAILINGBACK)
+ else if (state == FileLockNodeManager.FAILINGBACK)
{
liveLock.release();
- log.debug("awaiting live node failing back");
+ FileLockNodeManager.log.debug("awaiting live node failing back");
Thread.sleep(2000);
}
- else if (state == LIVE)
+ else if (state == FileLockNodeManager.LIVE)
{
- log.debug("acquired live node lock state = " + (char)state);
+ FileLockNodeManager.log.debug("acquired live node lock state = " + (char)state);
break;
}
}
while (true);
}
+ @Override
public void startBackup() throws Exception
{
- log.info("Waiting to become backup node");
+ FileLockNodeManager.log.info("Waiting to become backup node");
- backupLock = lock(BACKUP_LOCK_POS, LOCK_LENGTH);
- log.info("** got backup lock");
+ backupLock = lock(FileLockNodeManager.BACKUP_LOCK_POS);
+ FileLockNodeManager.log.info("** got backup lock");
readNodeId();
}
+ @Override
public void startLiveNode() throws Exception
{
setFailingBack();
- log.info("Waiting to obtain live lock");
+ FileLockNodeManager.log.info("Waiting to obtain live lock");
- liveLock = lock(LIVE_LOCK_POS, LOCK_LENGTH);
+ liveLock = lock(FileLockNodeManager.LIVE_LOCK_POS);
- log.info("Live Server Obtained live lock");
+ FileLockNodeManager.log.info("Live Server Obtained live lock");
setLive();
}
+ @Override
public void pauseLiveServer() throws Exception
{
setPaused();
@@ -221,20 +232,36 @@
}
}
+ @Override
public void crashLiveServer() throws Exception
{
- liveLock.release();
+ if (liveLock != null)
+ {
+ liveLock.release();
+ liveLock = null;
+ }
}
+ @Override
public void stopBackup() throws Exception
{
- backupLock.release();
+ if (backupLock != null)
+ {
+ backupLock.release();
+ backupLock = null;
+ }
+
}
+ public String getDirectory()
+ {
+ return directory;
+ }
+
private void setLive() throws Exception
{
ByteBuffer bb = ByteBuffer.allocateDirect(1);
- bb.put(LIVE);
+ bb.put(FileLockNodeManager.LIVE);
bb.position(0);
channel.write(bb, 0);
channel.force(true);
@@ -243,7 +270,7 @@
private void setFailingBack() throws Exception
{
ByteBuffer bb = ByteBuffer.allocateDirect(1);
- bb.put(FAILINGBACK);
+ bb.put(FileLockNodeManager.FAILINGBACK);
bb.position(0);
channel.write(bb, 0);
channel.force(true);
@@ -252,7 +279,7 @@
private void setPaused() throws Exception
{
ByteBuffer bb = ByteBuffer.allocateDirect(1);
- bb.put(PAUSED);
+ bb.put(FileLockNodeManager.PAUSED);
bb.position(0);
channel.write(bb, 0);
channel.force(true);
@@ -265,10 +292,12 @@
read = channel.read(bb, 0);
if (read <= 0)
{
- return NOT_STARTED;
+ return FileLockNodeManager.NOT_STARTED;
}
else
+ {
return bb.get(0);
+ }
}
private void releaseBackupLock() throws Exception
@@ -276,6 +305,7 @@
if (backupLock != null)
{
backupLock.release();
+ backupLock = null;
}
}
@@ -283,7 +313,7 @@
{
ByteBuffer id = ByteBuffer.allocateDirect(16);
int read = channel.read(id, 3);
- if(read != 16)
+ if (read != 16)
{
uuid = UUIDGenerator.getInstance().generateUUID();
nodeID = new SimpleString(uuid.toString());
@@ -306,7 +336,7 @@
{
ByteBuffer id = ByteBuffer.allocateDirect(16);
int read = channel.read(id, 3);
- if(read != 16)
+ if (read != 16)
{
throw new IllegalStateException("live server did not write id to file");
}
@@ -320,39 +350,77 @@
}
}
- private FileLock lock(int liveLockPos, int i) throws IOException
+ /**
+ * @return
+ */
+ protected File newFile(final String fileName)
{
- try
+ File file = new File(directory, fileName);
+ return file;
+ }
+
+ protected FileLock tryLock(final int lockPos) throws Exception
+ {
+ return channel.tryLock(lockPos, LOCK_LENGTH, false);
+ }
+
+
+ protected FileLock lock(final int liveLockPos) throws IOException
+ {
+ while (!interrupted)
{
- return channel.lock(liveLockPos, i, false);
+ FileLock lock = null;
+ try
+ {
+ lock = channel.tryLock(liveLockPos, 1, false);
+ }
+ catch (java.nio.channels.OverlappingFileLockException ex)
+ {
+ // This just means that another object on the same JVM is holding the lock
+ }
+
+ if (lock == null)
+ {
+ try
+ {
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e)
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return lock;
+ }
}
- catch (IOException e)
+
+ // todo this is here because sometimes channel.lock throws a resource deadlock exception but trylock works,
+ // need to investigate further and review
+ FileLock lock;
+ do
{
- //todo this is here because sometimes channel.lock throws a resource deadlock exception but trylock works, need to investigate further and review
- FileLock lock;
- do
+ lock = channel.tryLock(liveLockPos, 1, false);
+ if (lock == null)
{
- lock = channel.tryLock(liveLockPos, i, false);
- if (lock == null)
+ try
{
- try
- {
- Thread.sleep(500);
- }
- catch (InterruptedException e1)
- {
- //
- }
+ Thread.sleep(500);
}
- if (interrupted)
+ catch (InterruptedException e1)
{
- interrupted = false;
- throw new IOException(new InterruptedException());
+ //
}
}
- while(lock == null);
- return lock;
+ if (interrupted)
+ {
+ interrupted = false;
+ throw new IOException(new InterruptedException());
+ }
}
+ while (lock == null);
+ return lock;
}
+
}
-
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-02-25 11:40:04 UTC (rev 10253)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2011-02-25 22:23:58 UTC (rev 10254)
@@ -38,6 +38,7 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Pair;
import org.hornetq.api.core.SimpleString;
+import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.config.BridgeConfiguration;
import org.hornetq.core.config.Configuration;
@@ -87,6 +88,7 @@
import org.hornetq.core.server.Bindable;
import org.hornetq.core.server.Divert;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.JournalType;
import org.hornetq.core.server.MemoryManager;
import org.hornetq.core.server.NodeManager;
import org.hornetq.core.server.Queue;
@@ -289,7 +291,14 @@
*/
protected NodeManager createNodeManager(final String directory)
{
- return new FileLockNodeManager(directory);
+ if (configuration.getJournalType() == JournalType.ASYNCIO && AsynchronousFileImpl.isLoaded())
+ {
+ return new AIOFileLockNodeManager(directory);
+ }
+ else
+ {
+ return new FileLockNodeManager(directory);
+ }
}
private class NoSharedStoreLiveActivation implements Activation
Added: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/core/server/impl/FileLockTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/core/server/impl/FileLockTest.java (rev 0)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/core/server/impl/FileLockTest.java 2011-02-25 22:23:58 UTC (rev 10254)
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2010 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.unit.core.server.impl;
+
+import java.io.File;
+
+import org.hornetq.core.asyncio.impl.AsynchronousFileImpl;
+import org.hornetq.core.server.impl.AIOFileLockNodeManager;
+import org.hornetq.core.server.impl.FileLockNodeManager;
+import org.hornetq.tests.util.UnitTestCase;
+
+/**
+ * A FileLockTest
+ *
+ * @author clebertsuconic
+ *
+ *
+ */
+public class FileLockTest extends UnitTestCase
+{
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ File file = new File(getTestDir());
+ file.mkdirs();
+ }
+
+
+ public void testNIOLock() throws Exception
+ {
+ doTestLock(new FileLockNodeManager(getTestDir()), new FileLockNodeManager(getTestDir()));
+
+ }
+
+ public void testAIOLock() throws Exception
+ {
+ if (AsynchronousFileImpl.isLoaded())
+ {
+ doTestLock(new AIOFileLockNodeManager(getTestDir()), new AIOFileLockNodeManager(getTestDir()));
+ }
+
+ }
+
+ public void doTestLock(final FileLockNodeManager lockManager1, final FileLockNodeManager lockManager2) throws Exception
+ {
+ lockManager1.start();
+ lockManager2.start();
+
+ lockManager1.startLiveNode();
+
+ Thread t = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ lockManager2.startLiveNode();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ t.start();
+
+ assertTrue(lockManager1.isLiveLocked());
+ Thread.sleep(500);
+ assertFalse(lockManager2.isLiveLocked());
+
+ lockManager1.crashLiveServer();
+
+ t.join();
+
+ assertFalse(lockManager1.isLiveLocked());
+ assertTrue(lockManager2.isLiveLocked());
+
+ lockManager2.crashLiveServer();
+
+ lockManager1.stop();
+ lockManager2.stop();
+
+
+ }
+
+}
13 years, 10 months
JBoss hornetq SVN: r10253 - in branches/Branch_2_2_EAP: src/main/org/hornetq/ra and 1 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-02-25 06:40:04 -0500 (Fri, 25 Feb 2011)
New Revision: 10253
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/api/core/client/HornetQClient.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/ConnectionFactoryProperties.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAMCFProperties.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnectionFactory.java
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/ResourceAdapterTest.java
Log:
https://issues.jboss.org/browse/JBPAPP-5987 - fixed some more over ridden params that are set by default
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/api/core/client/HornetQClient.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/api/core/client/HornetQClient.java 2011-02-25 07:52:02 UTC (rev 10252)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/api/core/client/HornetQClient.java 2011-02-25 11:40:04 UTC (rev 10253)
@@ -84,6 +84,8 @@
public static final boolean DEFAULT_FAILOVER_ON_INITIAL_CONNECTION = false;
+ public static final boolean DEFAULT_IS_HA = false;
+
public static final boolean DEFAULT_USE_GLOBAL_POOLS = true;
public static final int DEFAULT_THREAD_POOL_MAX_SIZE = -1;
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/ConnectionFactoryProperties.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/ConnectionFactoryProperties.java 2011-02-25 07:52:02 UTC (rev 10252)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/ConnectionFactoryProperties.java 2011-02-25 11:40:04 UTC (rev 10253)
@@ -31,8 +31,6 @@
*/
private static boolean trace = ConnectionFactoryProperties.log.isTraceEnabled();
- private final static Boolean IS_HA = false;
-
private boolean hasBeenUpdated = false;
/**
@@ -45,7 +43,7 @@
*/
private Map<String, Object> connectionParameters;
- private Boolean ha = IS_HA;
+ private Boolean ha;
private String connectionLoadBalancingPolicyClassName;
@@ -93,7 +91,7 @@
private Double retryIntervalMultiplier;
- private Integer reconnectAttempts = -1;
+ private Integer reconnectAttempts;
private Boolean useGlobalPools;
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAMCFProperties.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAMCFProperties.java 2011-02-25 07:52:02 UTC (rev 10252)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAMCFProperties.java 2011-02-25 11:40:04 UTC (rev 10253)
@@ -58,8 +58,6 @@
public String strConnectionParameters;
- public String strBackupConnectionParameters;
-
/**
* The connection type
*/
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnectionFactory.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnectionFactory.java 2011-02-25 07:52:02 UTC (rev 10252)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQRAManagedConnectionFactory.java 2011-02-25 11:40:04 UTC (rev 10253)
@@ -680,6 +680,16 @@
mcfProperties.setThreadPoolMaxSize(threadPoolMaxSize);
}
+ public Boolean isHA()
+ {
+ return mcfProperties.isHA();
+ }
+
+ public void setHA(Boolean ha)
+ {
+ mcfProperties.setHA(ha);
+ }
+
/**
* Get the useTryLock.
*
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2011-02-25 07:52:02 UTC (rev 10252)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2011-02-25 11:40:04 UTC (rev 10253)
@@ -1354,6 +1354,11 @@
: getDiscoveryAddress();
Boolean ha = overrideProperties.isHA() != null ? overrideProperties.isHA() : getHA();
+
+ if(ha == null)
+ {
+ ha = HornetQClient.DEFAULT_IS_HA;
+ }
if (connectorClassName != null)
{
@@ -1469,7 +1474,8 @@
log.debug("TM located = " + tm);
}
}
-
+
+
private void setParams(final HornetQConnectionFactory cf,
final ConnectionFactoryProperties overrideProperties)
{
@@ -1552,6 +1558,11 @@
{
cf.setReconnectAttempts(val2);
}
+ else
+ {
+ //the global default is 0 but we should always try to reconnect JCA
+ cf.setReconnectAttempts(-1);
+ }
val2 = overrideProperties.getThreadPoolMaxSize() != null ? overrideProperties.getThreadPoolMaxSize()
: raProperties.getThreadPoolMaxSize();
if (val2 != null)
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/ResourceAdapterTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/ResourceAdapterTest.java 2011-02-25 07:52:02 UTC (rev 10252)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/ResourceAdapterTest.java 2011-02-25 11:40:04 UTC (rev 10253)
@@ -273,15 +273,7 @@
spec.setUseJNDI(false);
spec.setDestinationType("javax.jms.Queue");
spec.setDestination(MDBQUEUE);
- spec.setSetupAttempts(0);
- //just to force using override params
- spec.setBlockOnAcknowledge(true);
- CountDownLatch latch = new CountDownLatch(1);
- DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
- DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
- qResourceAdapter.endpointActivation(endpointFactory, spec);
- HornetQActivation activation = qResourceAdapter.getActivations().get(spec);
- HornetQConnectionFactory fac = activation.getConnectionFactory();
+ HornetQConnectionFactory fac = qResourceAdapter.createHornetQConnectionFactory(spec);
assertEquals(fac.getServerLocator().getDiscoveryGroupConfiguration().getGroupAddress(), "231.6.6.6");
assertEquals(fac.getServerLocator().getDiscoveryGroupConfiguration().getGroupPort(), 1234);
assertEquals(fac.getServerLocator().getDiscoveryGroupConfiguration().getRefreshTimeout(), 1l);
@@ -303,20 +295,144 @@
spec.setSetupAttempts(0);
spec.setDiscoveryAddress("231.6.6.6");
spec.setDiscoveryPort(1234);
+ spec.setDiscoveryInitialWaitTimeout(1l);
spec.setDiscoveryRefreshTimeout(1l);
- spec.setDiscoveryInitialWaitTimeout(1l);
- CountDownLatch latch = new CountDownLatch(1);
- DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch);
- DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false);
- qResourceAdapter.endpointActivation(endpointFactory, spec);
- HornetQActivation activation = qResourceAdapter.getActivations().get(spec);
- HornetQConnectionFactory fac = activation.getConnectionFactory();
+ HornetQConnectionFactory fac = qResourceAdapter.createHornetQConnectionFactory(spec);
assertEquals(fac.getServerLocator().getDiscoveryGroupConfiguration().getGroupAddress(), "231.6.6.6");
assertEquals(fac.getServerLocator().getDiscoveryGroupConfiguration().getGroupPort(), 1234);
assertEquals(fac.getServerLocator().getDiscoveryGroupConfiguration().getRefreshTimeout(), 1l);
assertEquals(fac.getServerLocator().getDiscoveryGroupConfiguration().getDiscoveryInitialWaitTimeout(), 1l);
qResourceAdapter.stop();
}
+
+ public void testResourceAdapterSetupNoHAOverride() throws Exception
+ {
+ HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
+ qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+ qResourceAdapter.setConnectionParameters("server-id=0");
+ qResourceAdapter.setHA(true);
+ HornetQRATestBase.MyBootstrapContext ctx = new HornetQRATestBase.MyBootstrapContext();
+ qResourceAdapter.start(ctx);
+ HornetQActivationSpec spec = new HornetQActivationSpec();
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Queue");
+ spec.setDestination(MDBQUEUE);
+
+ HornetQConnectionFactory fac = qResourceAdapter.createHornetQConnectionFactory(spec);
+
+ assertTrue(fac.isHA());
+
+ qResourceAdapter.stop();
+ assertFalse(spec.isHasBeenUpdated());
+ }
+
+ public void testResourceAdapterSetupNoHADefault() throws Exception
+ {
+ HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
+ qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+ qResourceAdapter.setConnectionParameters("server-id=0");
+ HornetQRATestBase.MyBootstrapContext ctx = new HornetQRATestBase.MyBootstrapContext();
+ qResourceAdapter.start(ctx);
+ HornetQActivationSpec spec = new HornetQActivationSpec();
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Queue");
+ spec.setDestination(MDBQUEUE);
+
+ HornetQConnectionFactory fac = qResourceAdapter.createHornetQConnectionFactory(spec);
+
+ assertFalse(fac.isHA());
+
+ qResourceAdapter.stop();
+ assertFalse(spec.isHasBeenUpdated());
+ }
+
+
+ public void testResourceAdapterSetupHAOverride() throws Exception
+ {
+ HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
+ qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+ qResourceAdapter.setConnectionParameters("server-id=0");
+ HornetQRATestBase.MyBootstrapContext ctx = new HornetQRATestBase.MyBootstrapContext();
+ qResourceAdapter.start(ctx);
+ HornetQActivationSpec spec = new HornetQActivationSpec();
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Queue");
+ spec.setDestination(MDBQUEUE);
+ spec.setHA(true);
+ HornetQConnectionFactory fac = qResourceAdapter.createHornetQConnectionFactory(spec);
+
+ assertTrue(fac.isHA());
+
+ qResourceAdapter.stop();
+ assertTrue(spec.isHasBeenUpdated());
+ }
+
+ public void testResourceAdapterSetupNoReconnectAttemptsOverride() throws Exception
+ {
+ HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
+ qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+ qResourceAdapter.setConnectionParameters("server-id=0");
+ qResourceAdapter.setReconnectAttempts(100);
+ HornetQRATestBase.MyBootstrapContext ctx = new HornetQRATestBase.MyBootstrapContext();
+ qResourceAdapter.start(ctx);
+ HornetQActivationSpec spec = new HornetQActivationSpec();
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Queue");
+ spec.setDestination(MDBQUEUE);
+
+ HornetQConnectionFactory fac = qResourceAdapter.createHornetQConnectionFactory(spec);
+
+ assertEquals(100, fac.getReconnectAttempts());
+
+ qResourceAdapter.stop();
+ assertFalse(spec.isHasBeenUpdated());
+ }
+
+ public void testResourceAdapterSetupReconnectAttemptDefault() throws Exception
+ {
+ HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
+ qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+ qResourceAdapter.setConnectionParameters("server-id=0");
+ HornetQRATestBase.MyBootstrapContext ctx = new HornetQRATestBase.MyBootstrapContext();
+ qResourceAdapter.start(ctx);
+ HornetQActivationSpec spec = new HornetQActivationSpec();
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Queue");
+ spec.setDestination(MDBQUEUE);
+
+ HornetQConnectionFactory fac = qResourceAdapter.createHornetQConnectionFactory(spec);
+
+ assertEquals(-1, fac.getReconnectAttempts());
+
+ qResourceAdapter.stop();
+ assertFalse(spec.isHasBeenUpdated());
+ }
+
+ public void testResourceAdapterSetupReconnectAttemptsOverride() throws Exception
+ {
+ HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
+ qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY);
+ qResourceAdapter.setConnectionParameters("server-id=0");
+ HornetQRATestBase.MyBootstrapContext ctx = new HornetQRATestBase.MyBootstrapContext();
+ qResourceAdapter.start(ctx);
+ HornetQActivationSpec spec = new HornetQActivationSpec();
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Queue");
+ spec.setDestination(MDBQUEUE);
+ spec.setReconnectAttempts(100);
+ HornetQConnectionFactory fac = qResourceAdapter.createHornetQConnectionFactory(spec);
+
+ assertEquals(100, fac.getReconnectAttempts());
+
+ qResourceAdapter.stop();
+ assertTrue(spec.isHasBeenUpdated());
+ }
@Override
public boolean isSecure()
13 years, 10 months
JBoss hornetq SVN: r10252 - in branches/Branch_2_2_EAP/examples/javaee: mdb-remote-failover and 11 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-02-25 02:52:02 -0500 (Fri, 25 Feb 2011)
New Revision: 10252
Added:
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/backup-server/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/backup-server/hornetq-configuration.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/backup-server/hornetq-jms.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.bat
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.sh
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/META-INF/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/META-INF/application.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/ant.properties
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/jndi.properties
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/live-server/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/live-server/hornetq-configuration.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/live-server/hornetq-jms.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/hornetq-configuration.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/hornetq-jms.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/jms-ds.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/ra.xml
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/MDBRemoteFailoverClientExample.java
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/server/
branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/server/MDBRemoteFailoverExample.java
Log:
added MDB failover example
Added: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/backup-server/hornetq-configuration.xml
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/backup-server/hornetq-configuration.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/backup-server/hornetq-configuration.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,108 @@
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<configuration xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+
+ <name>HornetQ.main.config</name>
+
+ <clustered>true</clustered>
+
+ <failover-on-shutdown>true</failover-on-shutdown>
+
+ <backup>true</backup>
+
+ <shared-store>true</shared-store>
+
+ <!--journal directories-->
+ <large-messages-directory>/tmp/shared/hornetq-data/large-messages</large-messages-directory>
+ <bindings-directory>/tmp/shared/hornetq-data/bindings</bindings-directory>
+ <journal-directory>/tmp/shared/hornetq-data/journal</journal-directory>
+ <paging-directory>/tmp/shared/hornetq-data/paging</paging-directory>
+
+ <!-- Connectors -->
+
+ <connectors>
+ <connector name="netty-connector">
+ <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ <param key="host" value="${jboss.bind.address:localhost}"/>
+ <param key="port" value="${hornetq.remoting.netty.port:5445}"/>
+ </connector>
+ <connector name="in-vm">
+ <factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+ <param key="server-id" value="${hornetq.server-id:0}"/>
+ </connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <!-- In VM acceptor -->
+ <acceptor name="in-vm">
+ <factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+ <param key="server-id" value="${hornetq.server-id:0}"/>
+ </acceptor>
+ <acceptor name="netty-acceptor">
+ <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="host" value="${jboss.bind.address:localhost}"/>
+ <param key="port" value="${hornetq.remoting.netty.port:5445}"/>
+ </acceptor>
+ </acceptors>
+
+ <broadcast-groups>
+ <broadcast-group name="bg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <broadcast-period>1000</broadcast-period>
+ <connector-ref>netty-connector</connector-ref>
+ </broadcast-group>
+ </broadcast-groups>
+
+ <discovery-groups>
+ <discovery-group name="dg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <refresh-timeout>60000</refresh-timeout>
+ </discovery-group>
+ </discovery-groups>
+
+ <cluster-connections>
+ <cluster-connection name="my-cluster">
+ <address>jms</address>
+ <connector-ref>netty-connector</connector-ref>
+ <discovery-group-ref discovery-group-name="dg-group1"/>
+ </cluster-connection>
+ </cluster-connections>
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example queue-->
+ <security-setting match="jms.queue.inQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue" roles="guest"/>
+ <permission type="deleteNonDurableQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ <security-setting match="jms.queue.outQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue" roles="guest"/>
+ <permission type="deleteNonDurableQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+</configuration>
Added: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/backup-server/hornetq-jms.xml
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/backup-server/hornetq-jms.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/backup-server/hornetq-jms.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,49 @@
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<configuration xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="netty-connector"/>
+ </connectors>
+
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+
+ <ha>true</ha>
+ <!-- Pause 1 second between connect attempts -->
+ <retry-interval>1000</retry-interval>
+
+ <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used to
+ implement an exponential back-off. For our purposes we just set to 1.0 so each reconnect
+ pause is the same length -->
+ <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+ <!-- Try reconnecting an unlimited number of times (-1 means "unlimited") -->
+ <reconnect-attempts>-1</reconnect-attempts>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="inQueue">
+ <entry name="/queue/inQueue"/>
+ </queue>
+
+ <queue name="outQueue">
+ <entry name="/queue/outQueue"/>
+ </queue>
+
+</configuration>
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.bat (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/build.bat)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.bat (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.bat 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,13 @@
+@echo off
+
+set "OVERRIDE_ANT_HOME=..\..\..\tools\ant"
+
+if exist "..\..\..\src\bin\build.bat" (
+ rem running from TRUNK
+ call ..\..\..\src\bin\build.bat %*
+) else (
+ rem running from the distro
+ call ..\..\..\bin\build.bat %*
+)
+
+set "OVERRIDE_ANT_HOME="
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.sh (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/build.sh)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.sh (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.sh 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+OVERRIDE_ANT_HOME=../../../tools/ant
+export OVERRIDE_ANT_HOME
+
+if [ -f "../../../src/bin/build.sh" ]; then
+ # running from TRUNK
+ ../../../src/bin/build.sh "$@"
+else
+ # running from the distro
+ ../../../bin/build.sh "$@"
+fi
+
+
+
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.xml (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/build.xml)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/build.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<project default="run" name="HornetQ Java EE MDB with remote failover Config Example">
+
+ <import file="../common/build.xml"/>
+ <property file="../../common/config/server.properties"/>
+
+ <property name="example.live.server.dir" value="live-server"/>
+ <property name="example.backup.server.dir" value="backup-server"/>
+ <target name="run" depends="validate-jboss,compile">
+
+ <property name="serverclasspath" refid="jms.runtime.classpath"/>
+
+ <java classname="org.hornetq.javaee.example.MDBRemoteFailoverClientExample" fork="true">
+ <jvmarg value="-Dhornetq.example.server.classpath=${serverclasspath}"/>
+ <jvmarg value="-Dhornetq.example.server.args=${server.args}"/>
+ <jvmarg value="-Dhornetq.example.logserveroutput=${hornetq.example.logserveroutput}"/>
+ <jvmarg value="-Dhornetq.example.runServer=${hornetq.example.runServer}"/>
+ <arg line="${hornetq.example.beans.file}"/>
+ <sysproperty key="java.library.path" value="${java.library.path}${path.separator}${aio.library.path}"/>
+ <classpath refid="jms.runtime.classpath"/>
+ </java>
+ </target>
+
+
+ <target name="copy-resources">
+ <copy todir="${example-profile}/deploy/jms-ra.rar/META-INF" overwrite="true">
+ <fileset dir="${example.server.dir}">
+ <include name="ra.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="deployLive" depends="validate-jboss, copy-live-profile">
+ <property name="example-profile" value="${jboss.home}/server/${example.name}-live"/>
+ <copy todir="${example-profile}/deploy/hornetq" overwrite="true">
+ <fileset dir="${example.live.server.dir}"/>
+ </copy>
+ <exec dir="${jboss.home}/bin" executable="sh" osfamily="unix">
+ <arg line="run.sh -Djboss.service.binding.set=ports-01 -c ${example.name}-live"/>
+ </exec>
+ <exec dir="${jboss.home}/bin" executable="cmd" osfamily="windows">
+ <arg line="/c run.bat -Djboss.service.binding.set=ports-01 -c ${example.name}-live"/>
+ </exec>
+ </target>
+
+ <target name="copy-live-profile" depends="live.profile.check" unless="donot.copy.profile">
+ <property name="profile" value="${jboss.home}/server/default"/>
+ <property name="example-profile" value="${jboss.home}/server/${example.name}-live"/>
+ <property name="deploy.dir" value="${example-profile}/deploy/"/>
+ <mkdir dir="${example-profile}"/>
+ <copy todir="${example-profile}">
+ <fileset dir="${profile}">
+ <exclude name="**/*hornetq-configuration.xml"/>
+ <exclude name="**/*hornetq-jms.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="live.profile.check">
+ <property name="example-profile" value="${jboss.home}/server/${example.name}-live"/>
+ <condition property="donot.copy.profile">
+ <available file="${example-profile}" type="dir"/>
+ </condition>
+ </target>
+
+ <target name="deployBackup" depends="validate-jboss, copy-backup-profile">
+ <property name="example-profile" value="${jboss.home}/server/${example.name}-backup"/>
+ <copy todir="${example-profile}/deploy/hornetq" overwrite="true">
+ <fileset dir="${example.backup.server.dir}"/>
+ </copy>
+ <exec dir="${jboss.home}/bin" executable="sh" osfamily="unix">
+ <arg line="run.sh -Djboss.service.binding.set=ports-02 -c ${example.name}-backup"/>
+ </exec>
+ <exec dir="${jboss.home}/bin" executable="cmd" osfamily="windows">
+ <arg line="/c run.bat -Djboss.service.binding.set=ports-02 -c ${example.name}-backup"/>
+ </exec>
+ </target>
+
+ <target name="copy-backup-profile" depends="backup.profile.check" unless="donot.copy.profile">
+ <property name="profile" value="${jboss.home}/server/default"/>
+ <property name="example-profile" value="${jboss.home}/server/${example.name}-backup"/>
+ <property name="deploy.dir" value="${example-profile}/deploy/"/>
+ <mkdir dir="${example-profile}"/>
+ <copy todir="${example-profile}">
+ <fileset dir="${profile}">
+ <exclude name="**/*hornetq-configuration.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="backup.profile.check">
+ <property name="example-profile" value="${jboss.home}/server/${example.name}-backup"/>
+ <condition property="donot.copy.profile">
+ <available file="${example-profile}" type="dir"/>
+ </condition>
+ </target>
+
+</project>
\ No newline at end of file
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/META-INF/application.xml (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/config/META-INF/application.xml)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/META-INF/application.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/META-INF/application.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,28 @@
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<application>
+ <display-name>My Application</display-name>
+
+ <module>
+ <web>
+ <web-uri>mdb-remote-failover-example.war</web-uri>
+ <context-root>/hornetq</context-root>
+ </web>
+ </module>
+ <module>
+ <java>mdb-remote-failover-example.jar</java>
+ </module>
+
+
+</application>
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/ant.properties (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/config/ant.properties)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/ant.properties (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/ant.properties 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,14 @@
+#
+# Copyright 2009 Red Hat, Inc.
+# Red Hat licenses this file to you under the Apache License, version
+# 2.0 (the "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+example.name=mdb-remote-failover
\ No newline at end of file
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/jndi.properties (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/config/client.jndi.properties)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/jndi.properties (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/config/jndi.properties 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,16 @@
+#
+# Copyright 2009 Red Hat, Inc.
+# Red Hat licenses this file to you under the Apache License, version
+# 2.0 (the "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1199
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/live-server/hornetq-configuration.xml (from rev 10233, branches/Branch_2_2_EAP/examples/jms/non-transaction-failover/server0/hornetq-configuration.xml)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/live-server/hornetq-configuration.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/live-server/hornetq-configuration.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,109 @@
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<configuration xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+
+ <name>HornetQ.main.config</name>
+
+ <clustered>true</clustered>
+
+ <!--we shutdown the server process so need this set to true-->
+ <failover-on-shutdown>true</failover-on-shutdown>
+
+ <shared-store>true</shared-store>
+
+ <!--journal directories-->
+ <large-messages-directory>/tmp/shared/hornetq-data/large-messages</large-messages-directory>
+ <bindings-directory>/tmp/shared/hornetq-data/bindings</bindings-directory>
+ <journal-directory>/tmp/shared/hornetq-data/journal</journal-directory>
+ <paging-directory>/tmp/shared/hornetq-data/paging</paging-directory>
+
+ <!-- Connectors -->
+
+ <connectors>
+ <connector name="netty-connector">
+ <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ <param key="host" value="${jboss.bind.address:localhost}"/>
+ <param key="port" value="${hornetq.remoting.netty.port:5445}"/>
+ </connector>
+
+ <connector name="in-vm">
+ <factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+ <param key="server-id" value="${hornetq.server-id:0}"/>
+ </connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+
+ <!-- In VM acceptor -->
+ <acceptor name="in-vm">
+ <factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+ <param key="server-id" value="${hornetq.server-id:0}"/>
+ </acceptor>
+ <acceptor name="netty-acceptor">
+ <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="host" value="${jboss.bind.address:localhost}"/>
+ <param key="port" value="${hornetq.remoting.netty.port:5445}"/>
+ </acceptor>
+ </acceptors>
+
+ <broadcast-groups>
+ <broadcast-group name="bg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <broadcast-period>1000</broadcast-period>
+ <connector-ref>netty-connector</connector-ref>
+ </broadcast-group>
+ </broadcast-groups>
+
+ <discovery-groups>
+ <discovery-group name="dg-group1">
+ <group-address>231.7.7.7</group-address>
+ <group-port>9876</group-port>
+ <refresh-timeout>60000</refresh-timeout>
+ </discovery-group>
+ </discovery-groups>
+
+ <cluster-connections>
+ <cluster-connection name="my-cluster">
+ <address>jms</address>
+ <connector-ref>netty-connector</connector-ref>
+ <discovery-group-ref discovery-group-name="dg-group1"/>
+ </cluster-connection>
+ </cluster-connections>
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example queue-->
+ <security-setting match="jms.queue.inQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue" roles="guest"/>
+ <permission type="deleteNonDurableQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ <security-setting match="jms.queue.outQueue">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createNonDurableQueue" roles="guest"/>
+ <permission type="deleteNonDurableQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+</configuration>
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/live-server/hornetq-jms.xml (from rev 10233, branches/Branch_2_2_EAP/examples/jms/non-transaction-failover/server0/hornetq-jms.xml)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/live-server/hornetq-jms.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/live-server/hornetq-jms.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,49 @@
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<configuration xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="netty-connector"/>
+ </connectors>
+
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+
+ <ha>true</ha>
+ <!-- Pause 1 second between connect attempts -->
+ <retry-interval>1000</retry-interval>
+
+ <!-- Multiply subsequent reconnect pauses by this multiplier. This can be used to
+ implement an exponential back-off. For our purposes we just set to 1.0 so each reconnect
+ pause is the same length -->
+ <retry-interval-multiplier>1.0</retry-interval-multiplier>
+
+ <!-- Try reconnecting an unlimited number of times (-1 means "unlimited") -->
+ <reconnect-attempts>-1</reconnect-attempts>
+ </connection-factory>
+
+ <!--the queue used by the example-->
+ <queue name="inQueue">
+ <entry name="/queue/inQueue"/>
+ </queue>
+
+ <queue name="outQueue">
+ <entry name="/queue/outQueue"/>
+ </queue>
+
+</configuration>
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/hornetq-configuration.xml (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/hornetq-configuration.xml)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/hornetq-configuration.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/hornetq-configuration.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,63 @@
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<configuration xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+
+ <name>HornetQ.main.config</name>
+
+ <bindings-directory>${jboss.server.data.dir}/messaging/bindings</bindings-directory>
+
+ <journal-directory>${jboss.server.data.dir}/messaging/journal</journal-directory>
+
+ <large-messages-directory>${jboss.server.data.dir}/messaging/largemessages</large-messages-directory>
+
+ <paging-directory>${jboss.server.data.dir}/messaging/paging</paging-directory>
+
+ <!-- Connectors -->
+ <connectors>
+ <connector name="netty">
+ <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
+ </connector>
+
+ <connector name="in-vm">
+ <factory-class>org.hornetq.core.remoting.impl.invm.InVMConnectorFactory</factory-class>
+ </connector>
+
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <!-- In VM acceptor -->
+ <acceptor name="in-vm">
+ <factory-class>org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+ <param key="server-id" value="0"/>
+ </acceptor>
+
+ <!-- Netty TCP Acceptor -->
+ <acceptor name="netty">
+ <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
+ <param key="port" value="${hornetq.remoting.netty.port:5445}"/>
+ </acceptor>
+ </acceptors>
+
+ <security-settings>
+ <security-setting match="jms.queue.#">
+ <permission type="consume" roles="guest,publisher"/>
+ <permission type="send" roles="guest,publisher"/>
+ </security-setting>
+ </security-settings>
+
+
+</configuration>
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/hornetq-jms.xml (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/hornetq-jms.xml)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/hornetq-jms.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/hornetq-jms.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,33 @@
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<configuration xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <connection-factory name="ConnectionFactory">
+ <connectors>
+ <connector-ref connector-name="netty"/>
+ </connectors>
+ <entries>
+ <entry name="ConnectionFactory"/>
+ <entry name="XAConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <queue name="A">
+ <entry name="/queue/A"/>
+ </queue>
+ <queue name="B">
+ <entry name="/queue/B"/>
+ </queue>
+</configuration>
\ No newline at end of file
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/jms-ds.xml (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/jms-ds.xml)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/jms-ds.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/jms-ds.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+
+<!-- This file will be deployed by the target deploy on build.xml -->
+<connection-factories>
+
+
+ <!--
+ JMS XA Resource adapter, use this for outbound JMS connections.
+ Inbound connections are defined at the @MDB activaction or at the resource-adapter properties.
+ -->
+ <tx-connection-factory>
+ <jndi-name>RemoteJmsXA</jndi-name>
+ <xa-transaction/>
+ <rar-name>hornetq-ra.rar</rar-name>
+ <connection-definition>org.hornetq.ra.HornetQRAConnectionFactory</connection-definition>
+ <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</config-property>
+ <config-property name="hA" type="java.lang.Boolean">true</config-property>
+ </tx-connection-factory>
+
+
+</connection-factories>
Copied: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/ra.xml (from rev 10233, branches/Branch_2_2_EAP/examples/javaee/jca-remote/server/ra.xml)
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/ra.xml (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/server/ra.xml 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<!-- This file will be installed by the example mdb-remote/build.xml, deploy target.
+ This is an example of how you could change the default configuration of a resource adapter
+ -->
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+ version="1.5">
+
+ <description>HornetQ 2.0 Resource Adapter Alternate Configuration</description>
+ <display-name>HornetQ 2.0 Resource Adapter Alternate Configuration</display-name>
+
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>JMS 1.1 Server</eis-type>
+ <resourceadapter-version>1.0</resourceadapter-version>
+
+ <license>
+ <description>
+Copyright 2009 Red Hat, Inc.
+ Red Hat licenses this file to you under the Apache License, version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+ </description>
+ <license-required>true</license-required>
+ </license>
+
+ <resourceadapter>
+ <resourceadapter-class>org.hornetq.ra.HornetQResourceAdapter</resourceadapter-class>
+ <config-property>
+ <description>The Discovery Address</description>
+ <config-property-name>discoveryAddress</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>231.7.7.7</config-property-value>
+ </config-property>
+ <config-property>
+ <description>The Discovery Port</description>
+ <config-property-name>discoveryPort</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>9876</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Do we support HA</description>
+ <config-property-name>hA</config-property-name>
+ <config-property-type>java.lang.Boolean</config-property-type>
+ <config-property-value>true</config-property-value>
+ </config-property>
+ <config-property>
+ <description>reconnect attempts</description>
+ <config-property-name>reconnectAttempts</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>-1</config-property-value>
+ </config-property>
+
+ <outbound-resourceadapter>
+ <connection-definition>
+ <managedconnectionfactory-class>org.hornetq.ra.HornetQRAManagedConnectionFactory</managedconnectionfactory-class>
+
+ <config-property>
+ <description>The default session type</description>
+ <config-property-name>SessionDefaultType</config-property-name>
+ <config-property-type>java.lang.String</config-property-type>
+ <config-property-value>javax.jms.Queue</config-property-value>
+ </config-property>
+ <config-property>
+ <description>Try to obtain a lock within specified number of seconds; less than or equal to 0 disable this functionality</description>
+ <config-property-name>UseTryLock</config-property-name>
+ <config-property-type>java.lang.Integer</config-property-type>
+ <config-property-value>0</config-property-value>
+ </config-property>
+
+ <connectionfactory-interface>org.hornetq.ra.HornetQRAConnectionFactory</connectionfactory-interface>
+ <connectionfactory-impl-class>org.hornetq.ra.HornetQRAConnectionFactoryImpl</connectionfactory-impl-class>
+ <connection-interface>javax.jms.Session</connection-interface>
+ <connection-impl-class>org.hornetq.ra.HornetQRASession</connection-impl-class>
+ </connection-definition>
+ <transaction-support>XATransaction</transaction-support>
+ <authentication-mechanism>
+ <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+ <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+ </authentication-mechanism>
+ <reauthentication-support>false</reauthentication-support>
+ </outbound-resourceadapter>
+
+ <inbound-resourceadapter>
+ <messageadapter>
+ <messagelistener>
+ <messagelistener-type>javax.jms.MessageListener</messagelistener-type>
+ <activationspec>
+ <activationspec-class>org.hornetq.ra.inflow.HornetQActivationSpec</activationspec-class>
+ <required-config-property>
+ <config-property-name>destination</config-property-name>
+ </required-config-property>
+ </activationspec>
+ </messagelistener>
+ </messageadapter>
+ </inbound-resourceadapter>
+
+ </resourceadapter>
+</connector>
Added: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/MDBRemoteFailoverClientExample.java
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/MDBRemoteFailoverClientExample.java (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/MDBRemoteFailoverClientExample.java 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.javaee.example;
+
+import javax.jms.*;
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
+ * Date: 2/24/11
+ * Time: 2:44 PM
+ */
+public class MDBRemoteFailoverClientExample
+{
+ public static void main(String[] args) throws Exception
+ {
+ Connection connection = null;
+ InitialContext initialContext = null;
+ try
+ {
+ //Step 1. Create an initial context to perform the JNDI lookup.
+ initialContext = new InitialContext();
+
+ //Step 2. Perfom a lookup on the queue
+ Queue queue = (Queue) initialContext.lookup("/queue/inQueue");
+
+ //Step 3. Perform a lookup on the Connection Factory
+ ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
+
+ //Step 4.Create a JMS Connection
+ connection = cf.createConnection();
+
+ //Step 5. Create a JMS Session
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ //Step 6. Create a JMS Message Producer
+ MessageProducer producer = session.createProducer(queue);
+
+ //Step 7. Create a Text Message
+ TextMessage message = session.createTextMessage("This is a text message");
+
+ System.out.println("Sent message: " + message.getText());
+
+ //Step 8. Send the Message
+ producer.send(message);
+
+ //Step 15. We lookup the reply queue
+ queue = (Queue) initialContext.lookup("/queue/outQueue");
+
+ //Step 16. We create a JMS message consumer
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+
+ //Step 17. We start the connedction so we can receive messages
+ connection.start();
+
+ //Step 18. We receive the message and print it out
+ message = (TextMessage) messageConsumer.receive(5000);
+
+ System.out.println("message.getText() = " + message.getText());
+
+ System.out.println("Kill Live Server and press enter");
+
+ System.in.read();
+
+ //Step 7. Create a Text Message
+ message = session.createTextMessage("This is another text message");
+
+ System.out.println("Sent message: " + message.getText());
+
+ //Step 8. Send the Message
+ producer.send(message);
+
+ //Step 16. We create a JMS message consumer
+ messageConsumer = session.createConsumer(queue);
+
+ //Step 18. We receive the message and print it out
+ message = (TextMessage) messageConsumer.receive(5000);
+
+ System.out.println("message.getText() = " + message.getText());
+
+ }
+ finally
+ {
+ //Step 19. Be sure to close our JMS resources!
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if(connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+}
Added: branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/server/MDBRemoteFailoverExample.java
===================================================================
--- branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/server/MDBRemoteFailoverExample.java (rev 0)
+++ branches/Branch_2_2_EAP/examples/javaee/mdb-remote-failover/src/org/hornetq/javaee/example/server/MDBRemoteFailoverExample.java 2011-02-25 07:52:02 UTC (rev 10252)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.javaee.example.server;
+
+import org.hornetq.api.jms.HornetQJMSClient;
+import org.jboss.ejb3.annotation.ResourceAdapter;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
+import javax.jms.*;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.com">Andy Taylor</a>
+ * Date: 2/24/11
+ * Time: 2:44 PM
+ */
+@MessageDriven(name = "MDBRemoteFailoverExample",
+ activationConfig =
+ {
+ @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/inQueue") ,
+ @ActivationConfigProperty(propertyName = "hA", propertyValue = "true")
+ })
+@TransactionManagement(value= TransactionManagementType.CONTAINER)
+@TransactionAttribute(value= TransactionAttributeType.REQUIRED)
+@ResourceAdapter("hornetq-ra.rar")
+public class MDBRemoteFailoverExample implements MessageListener
+{
+
+ @Resource(mappedName = "java:RemoteJmsXA")
+ ConnectionFactory connectionFactory;
+ Queue replyQueue;
+
+ public void onMessage(Message message)
+ {
+ Connection conn = null;
+ try
+ {
+ replyQueue = HornetQJMSClient.createQueue("outQueue");
+ //Step 9. We know the client is sending a text message so we cast
+ TextMessage textMessage = (TextMessage)message;
+
+ //Step 10. get the text from the message.
+ String text = textMessage.getText();
+
+ System.out.println("message " + text);
+
+ //Step 11. we create a JMS connection
+ conn = connectionFactory.createConnection();
+
+ //Step 12. We create a JMS session
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ //Step 13. we create a producer for the reply queue
+ MessageProducer producer = sess.createProducer(replyQueue);
+
+ //Step 14. we create a message and send it
+ producer.send(sess.createTextMessage("this is a reply"));
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ if(conn != null)
+ {
+ try
+ {
+ conn.close();
+ }
+ catch (JMSException e)
+ {
+ }
+ }
+ }
+ }
+}
13 years, 10 months
JBoss hornetq SVN: r10251 - branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/ra.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2011-02-24 12:59:00 -0500 (Thu, 24 Feb 2011)
New Revision: 10251
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
Log:
fixing test
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2011-02-24 13:52:49 UTC (rev 10250)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/unit/ra/ResourceAdapterTest.java 2011-02-24 17:59:00 UTC (rev 10251)
@@ -392,6 +392,8 @@
activation.start();
activation.stop();
+
+ ra.stop();
locator.close();
13 years, 10 months
JBoss hornetq SVN: r10250 - in branches/Branch_2_2_EAP: tests/src/org/hornetq/tests/integration/ra and 1 other directory.
by do-not-reply@jboss.org
Author: ataylor
Date: 2011-02-24 08:52:49 -0500 (Thu, 24 Feb 2011)
New Revision: 10250
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerSecurityTest.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerXATest.java
Log:
fixed tests to stop RA and NPE check on resource adapter stop
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2011-02-24 12:23:57 UTC (rev 10249)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/ra/HornetQResourceAdapter.java 2011-02-24 13:52:49 UTC (rev 10250)
@@ -228,7 +228,10 @@
activations.clear();
- defaultHornetQConnectionFactory.close();
+ if (defaultHornetQConnectionFactory != null)
+ {
+ defaultHornetQConnectionFactory.close();
+ }
HornetQResourceAdapter.log.info("HornetQ resource adapter stopped");
}
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerSecurityTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerSecurityTest.java 2011-02-24 12:23:57 UTC (rev 10249)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerSecurityTest.java 2011-02-24 13:52:49 UTC (rev 10250)
@@ -62,6 +62,7 @@
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
assertEquals(((LocalQueueBinding)binding).getQueue().getConsumerCount(), 0);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
public void testSimpleMessageReceivedOnQueueWithSecuritySucceeds() throws Exception
@@ -91,5 +92,6 @@
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
assertEquals(((LocalQueueBinding)binding).getQueue().getConsumerCount(), 15);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
}
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java 2011-02-24 12:23:57 UTC (rev 10249)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerTest.java 2011-02-24 13:52:49 UTC (rev 10250)
@@ -65,6 +65,8 @@
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "teststring");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+
+ qResourceAdapter.stop();
}
public void testInvalidAckMode() throws Exception
@@ -82,6 +84,7 @@
{
//pass
}
+ qResourceAdapter.stop();
}
public void testSimpleMessageReceivedOnQueueInLocalTX() throws Exception
@@ -117,6 +120,7 @@
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "teststring");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
public void testSimpleMessageReceivedOnQueueWithSelector() throws Exception
@@ -152,6 +156,7 @@
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "red");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
public void testEndpointDeactivated() throws Exception
@@ -174,6 +179,7 @@
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
assertEquals(((LocalQueueBinding) binding).getQueue().getConsumerCount(), 0);
assertTrue(endpoint.released);
+ qResourceAdapter.stop();
}
public void testMaxSessions() throws Exception
@@ -195,6 +201,7 @@
Binding binding = server.getPostOffice().getBinding(MDBQUEUEPREFIXEDSIMPLE);
assertEquals(((LocalQueueBinding) binding).getQueue().getConsumerCount(), 1);
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
public void testSimpleTopic() throws Exception
@@ -224,6 +231,7 @@
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "test");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
public void testDurableSubscription() throws Exception
@@ -279,6 +287,7 @@
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "3");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
public void testNonDurableSubscription() throws Exception
@@ -325,6 +334,7 @@
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "3");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
public void testSelectorChangedWithTopic() throws Exception
@@ -380,6 +390,7 @@
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "3");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
public void testSelectorNotChangedWithTopic() throws Exception
@@ -429,6 +440,7 @@
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "2");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerXATest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerXATest.java 2011-02-24 12:23:57 UTC (rev 10249)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/ra/HornetQMessageHandlerXATest.java 2011-02-24 13:52:49 UTC (rev 10250)
@@ -68,6 +68,7 @@
endpoint.prepare();
endpoint.commit();
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
public void testXARollback() throws Exception
@@ -104,6 +105,7 @@
assertNotNull(endpoint.lastMessage);
assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "teststring");
qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+ qResourceAdapter.stop();
}
class XADummyEndpoint extends DummyMessageEndpoint
13 years, 10 months