JBoss hornetq SVN: r8462 - trunk/examples/core/embedded.
by do-not-reply@jboss.org
Author: ataylor
Date: 2009-11-30 05:10:50 -0500 (Mon, 30 Nov 2009)
New Revision: 8462
Modified:
trunk/examples/core/embedded/build.xml
Log:
fixed classpath
Modified: trunk/examples/core/embedded/build.xml
===================================================================
--- trunk/examples/core/embedded/build.xml 2009-11-30 09:43:48 UTC (rev 8461)
+++ trunk/examples/core/embedded/build.xml 2009-11-30 10:10:50 UTC (rev 8462)
@@ -23,6 +23,7 @@
<path id="local.classpath">
<fileset dir="${hornetq.jars.dir}">
<include name="hornetq-core.jar"/>
+ <include name="netty.jar"/>
</fileset>
<pathelement location="${classes.dir}"/>
</path>
14 years, 11 months
JBoss hornetq SVN: r8461 - trunk/tests/src/org/hornetq/tests/integration/cluster/distribution.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2009-11-30 04:43:48 -0500 (Mon, 30 Nov 2009)
New Revision: 8461
Modified:
trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
Log:
speed up tests
* used consumer.receiveImmediate() instead of consumer.receive(1000) to speed up
tests
Modified: trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-11-30 09:38:20 UTC (rev 8460)
+++ trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-11-30 09:43:48 UTC (rev 8461)
@@ -804,8 +804,8 @@
ClientMessage message;
do
{
- message = holder.consumer.receive(1000);
-
+ message = holder.consumer.receiveImmediate();
+
if (message != null)
{
int count = (Integer)message.getObjectProperty(COUNT_PROP);
14 years, 11 months
JBoss hornetq SVN: r8460 - trunk/src/main/org/hornetq/integration/transports/netty.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-11-30 04:38:20 -0500 (Mon, 30 Nov 2009)
New Revision: 8460
Modified:
trunk/src/main/org/hornetq/integration/transports/netty/ChannelPipelineSupport.java
Log:
Reverted to the old frame decoder, since there seems to be a problem with the new one as evidenced by SendStressTest
Modified: trunk/src/main/org/hornetq/integration/transports/netty/ChannelPipelineSupport.java
===================================================================
--- trunk/src/main/org/hornetq/integration/transports/netty/ChannelPipelineSupport.java 2009-11-30 09:23:10 UTC (rev 8459)
+++ trunk/src/main/org/hornetq/integration/transports/netty/ChannelPipelineSupport.java 2009-11-30 09:38:20 UTC (rev 8460)
@@ -47,7 +47,7 @@
public static void addCodecFilter(final ChannelPipeline pipeline, final BufferHandler handler)
{
assert pipeline != null;
- pipeline.addLast("decoder", new HornetQFrameDecoder2());
+ pipeline.addLast("decoder", new HornetQFrameDecoder(handler));
}
public static void addSSLFilter(final ChannelPipeline pipeline, final SSLContext context, final boolean client) throws Exception
14 years, 11 months
JBoss hornetq SVN: r8459 - in trunk: src/main/org/hornetq/core/remoting/server/impl and 1 other directories.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2009-11-30 04:23:10 -0500 (Mon, 30 Nov 2009)
New Revision: 8459
Modified:
trunk/build-hornetq.properties
trunk/build-hornetq.xml
trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/SymmetricClusterTest.java
Log:
add sleep in remoting service
* sleep for 1s when stopping the remoting service to give more opportunity to
initializing connections to be done before sending them DISCONNECT packets
(only if using netty acceptors)
* increased test suite's global timeout to 2h (instead of 1h30)
Modified: trunk/build-hornetq.properties
===================================================================
--- trunk/build-hornetq.properties 2009-11-30 08:44:34 UTC (rev 8458)
+++ trunk/build-hornetq.properties 2009-11-30 09:23:10 UTC (rev 8459)
@@ -23,8 +23,8 @@
junit.haltonfailure=false
junit.fork=true
junit.includeantruntime=true
-# 90 mins
-junit.timeout=5400000
+# 120 mins
+junit.timeout=7200000
# 150 mins
clustering.junit.timeout=9000000
# 90 mins
Modified: trunk/build-hornetq.xml
===================================================================
--- trunk/build-hornetq.xml 2009-11-30 08:44:34 UTC (rev 8458)
+++ trunk/build-hornetq.xml 2009-11-30 09:23:10 UTC (rev 8459)
@@ -1224,8 +1224,6 @@
failureproperty="tests.failed">
<formatter type="plain" usefile="${junit.formatter.usefile}"/>
<fileset dir="${test.classes.dir}">
- <!-- cluster tests with backup are brittled and are temporarily excluded -->
- <exclude name="**/cluster/distribution/*WithBackupTest.class" />
<!-- exlcuded because of https://jira.jboss.org/jira/browse/HORNETQ-65 -->
<exclude name="**/cluster/failover/*StaticClusterWithBackupFailoverTest.class" />
<include name="${tests.param}"/>
Modified: trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2009-11-30 08:44:34 UTC (rev 8458)
+++ trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java 2009-11-30 09:23:10 UTC (rev 8459)
@@ -225,6 +225,21 @@
acceptor.pause();
}
+ boolean containsNettyAcceptors = false;
+ for (Acceptor acceptor : acceptors)
+ {
+ if (acceptor.getClass().toString().contains("NettyAcceptor"))
+ {
+ containsNettyAcceptors = true;
+ break;
+ }
+ }
+ if (containsNettyAcceptors)
+ {
+ // we sleep in case there are initializing connections which are in the thread pool
+ Thread.sleep(1000);
+ }
+
synchronized (server)
{
for (ConnectionEntry entry : connections.values())
Modified: trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-11-30 08:44:34 UTC (rev 8458)
+++ trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-11-30 09:23:10 UTC (rev 8459)
@@ -830,7 +830,7 @@
message.acknowledge();
}
- log.info("consumer " + consumerIDs[i] + " returns " + count);
+ // log.info("consumer " + consumerIDs[i] + " returns " + count);
}
else
{
Modified: trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/SymmetricClusterTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-11-30 08:44:34 UTC (rev 8458)
+++ trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/SymmetricClusterTest.java 2009-11-30 09:23:10 UTC (rev 8459)
@@ -1424,7 +1424,7 @@
startServers(3, 0);
- Thread.sleep(2000);
+ Thread.sleep(3000);
setupSessionFactory(0, isNetty());
setupSessionFactory(3, isNetty());
14 years, 11 months
JBoss hornetq SVN: r8458 - trunk.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2009-11-30 03:44:34 -0500 (Mon, 30 Nov 2009)
New Revision: 8458
Modified:
trunk/.classpath
Log:
updated eclipse's .classpath for reattach-node example
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2009-11-30 08:03:32 UTC (rev 8457)
+++ trunk/.classpath 2009-11-30 08:44:34 UTC (rev 8458)
@@ -58,7 +58,7 @@
<classpathentry kind="src" path="examples/jms/queue-message-redistribution/src"/>
<classpathentry kind="src" path="examples/jms/queue-requestor/src"/>
<classpathentry kind="src" path="examples/jms/queue-selector/src"/>
- <classpathentry kind="src" path="examples/jms/reconnect-same-node/src"/>
+ <classpathentry kind="src" path="examples/jms/reattach-node/src"/>
<classpathentry kind="src" path="examples/jms/request-reply/src"/>
<classpathentry kind="src" path="examples/jms/scheduled-message/src"/>
<classpathentry kind="src" path="examples/jms/security/src"/>
14 years, 11 months
JBoss hornetq SVN: r8457 - trunk/examples/jms.
by do-not-reply@jboss.org
Author: ataylor
Date: 2009-11-30 03:03:32 -0500 (Mon, 30 Nov 2009)
New Revision: 8457
Added:
trunk/examples/jms/reattach-node/
Removed:
trunk/examples/jms/reconnect-same-node/
Modified:
trunk/examples/jms/hornetq-jms-examples.iml
Log:
renamed example dir
Modified: trunk/examples/jms/hornetq-jms-examples.iml
===================================================================
--- trunk/examples/jms/hornetq-jms-examples.iml 2009-11-30 03:31:27 UTC (rev 8456)
+++ trunk/examples/jms/hornetq-jms-examples.iml 2009-11-30 08:03:32 UTC (rev 8457)
@@ -41,7 +41,7 @@
<sourceFolder url="file://$MODULE_DIR$/queue-requestor/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/queue-selector/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/queue/src" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/reconnect-same-node/src" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/reattach-node/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/request-reply/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/scheduled-message/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/security/src" isTestSource="false" />
Copied: trunk/examples/jms/reattach-node (from rev 8456, trunk/examples/jms/reconnect-same-node)
14 years, 11 months
JBoss hornetq SVN: r8456 - in trunk/tests/src/org/hornetq/tests/stress: client and 1 other directory.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-29 22:31:27 -0500 (Sun, 29 Nov 2009)
New Revision: 8456
Added:
trunk/tests/src/org/hornetq/tests/stress/client/
trunk/tests/src/org/hornetq/tests/stress/client/SendStressTest.java
Log:
Adding test to replicate issue described on http://www.jboss.org/index.html?module=bb&op=viewtopic&t=164372
Added: trunk/tests/src/org/hornetq/tests/stress/client/SendStressTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/stress/client/SendStressTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/stress/client/SendStressTest.java 2009-11-30 03:31:27 UTC (rev 8456)
@@ -0,0 +1,150 @@
+/*
+ * 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.tests.stress.client;
+
+import junit.framework.TestSuite;
+
+import org.hornetq.core.client.ClientConsumer;
+import org.hornetq.core.client.ClientMessage;
+import org.hornetq.core.client.ClientProducer;
+import org.hornetq.core.client.ClientSession;
+import org.hornetq.core.client.ClientSessionFactory;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.tests.util.ServiceTestBase;
+
+/**
+ * A SendStressTest
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class SendStressTest extends ServiceTestBase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Remove this method to re-enable those tests
+ public static TestSuite suite()
+ {
+ return new TestSuite();
+ }
+
+ public void testStressSendNetty() throws Exception
+ {
+ doTestStressSend(true);
+ }
+
+ public void testStressSendInVM() throws Exception
+ {
+ doTestStressSend(false);
+ }
+
+ public void doTestStressSend(final boolean netty) throws Exception
+ {
+ HornetQServer server = createServer(false, netty);
+
+ ClientSessionFactory sf = createFactory(netty);
+
+ ClientSession session = null;
+
+ final int batchSize = 2000;
+
+ final int numberOfMessages = 100000;
+
+ try
+ {
+ server.start();
+
+ session = sf.createSession(false, false);
+
+ session.createQueue("address", "queue");
+
+ ClientProducer producer = session.createProducer("address");
+
+ ClientMessage message = session.createClientMessage(false);
+
+ message.getBodyBuffer().writeBytes(new byte[1024]);
+
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ producer.send(message);
+ if (i % batchSize == 0)
+ {
+ System.out.println("Sent " + i);
+ session.commit();
+ }
+ }
+
+ session.commit();
+
+ session.close();
+
+ session = sf.createSession(false, false);
+
+ ClientConsumer consumer = session.createConsumer("queue");
+
+ session.start();
+
+ for (int i = 0; i < numberOfMessages; i++)
+ {
+ ClientMessage msg = consumer.receive(5000);
+ assertNotNull(msg);
+ msg.acknowledge();
+
+ if (i % batchSize == 0)
+ {
+ System.out.println("Consumed " + i);
+ session.commit();
+ }
+ }
+
+ session.commit();
+ }
+ finally
+ {
+ if (session != null)
+ {
+ try
+ {
+ sf.close();
+ session.close();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ server.stop();
+ }
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
14 years, 11 months
JBoss hornetq SVN: r8455 - trunk/tests/src/org/hornetq/tests/integration/cluster/distribution.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-29 19:00:16 -0500 (Sun, 29 Nov 2009)
New Revision: 8455
Modified:
trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
Log:
Showing a thread dump in case of waitforbindings failure
Modified: trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-11-29 15:09:08 UTC (rev 8454)
+++ trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusterTestBase.java 2009-11-30 00:00:16 UTC (rev 8455)
@@ -269,6 +269,9 @@
totConsumers;
log.error(msg);
+
+ // Sending thread dump.. trying to get some information about the server case the binding didn't arrive
+ System.out.println(threadDump(msg));
throw new IllegalStateException(msg);
}
14 years, 11 months
JBoss hornetq SVN: r8454 - in trunk/examples/jms/reconnect-same-node: src/org/hornetq/jms/example and 1 other directory.
by do-not-reply@jboss.org
Author: ataylor
Date: 2009-11-29 10:09:08 -0500 (Sun, 29 Nov 2009)
New Revision: 8454
Added:
trunk/examples/jms/reconnect-same-node/src/org/hornetq/jms/example/ReattachExample.java
Removed:
trunk/examples/jms/reconnect-same-node/src/org/hornetq/jms/example/ReconnectSameNodeExample.java
Modified:
trunk/examples/jms/reconnect-same-node/build.xml
trunk/examples/jms/reconnect-same-node/readme.html
Log:
renamed example
Modified: trunk/examples/jms/reconnect-same-node/build.xml
===================================================================
--- trunk/examples/jms/reconnect-same-node/build.xml 2009-11-28 22:57:54 UTC (rev 8453)
+++ trunk/examples/jms/reconnect-same-node/build.xml 2009-11-29 15:09:08 UTC (rev 8454)
@@ -21,13 +21,13 @@
<target name="run">
<antcall target="runExample">
- <param name="example.classname" value="org.hornetq.jms.example.ReconnectSameNodeExample"/>
+ <param name="example.classname" value="org.hornetq.jms.example.ReattachExample"/>
</antcall>
</target>
<target name="runRemote">
<antcall target="runExample">
- <param name="example.classname" value="org.hornetq.jms.example.ReconnectSameNodeExample"/>
+ <param name="example.classname" value="org.hornetq.jms.example.ReattachExample"/>
<param name="hornetq.example.runServer" value="false"/>
</antcall>
</target>
Modified: trunk/examples/jms/reconnect-same-node/readme.html
===================================================================
--- trunk/examples/jms/reconnect-same-node/readme.html 2009-11-28 22:57:54 UTC (rev 8453)
+++ trunk/examples/jms/reconnect-same-node/readme.html 2009-11-29 15:09:08 UTC (rev 8454)
@@ -1,36 +1,35 @@
<html>
<head>
- <title>HornetQ JMS Automatic Reconnect Same Server Example</title>
+ <title>HornetQ JMS Automatic Reattach Example</title>
<link rel="stylesheet" type="text/css" href="../../common/common.css" />
<link rel="stylesheet" type="text/css" href="../../common/prettify.css" />
<script type="text/javascript" src="../../common/prettify.js"></script>
</head>
<body onload="prettyPrint()">
- <h1>HornetQ JMS Reconnect Same Server Example</h1>
+ <h1>HornetQ JMS Reattach Example</h1>
<br>
<p>This example demonstrates how HornetQ connections can be configured to be resilient to
temporary network failures.</p>
<p>In the case of a network failure being detected, either as a result of a failure to read/write to the connection,
or the failure of a pong to arrive back from the server in good time after a ping is sent, instead of
failing the connection immediately and notifying any user ExceptionListener objects, HornetQ
- can be configured to automatically retry the connection, and reconnect to the server when it becomes
+ can be configured to automatically retry the connection, and reattach to the server when it becomes
available again across the network.</p>
- <p>In the case that the server didn't actually crash, i.e. the network was temporarily unavailable, the client will
- be able to resume all its sessions and connections where it left off, 100% transparently.</p>
- <p>In the case that the server <b>did</b> crash and was restarted, on reconnection the server session
- clearly won't still exist, so the session will be unable to continue transparently, and any registered
- ExceptionListener will be called, to allow any application layer reconnect logic to be called.</p>
- <p>This example starts a single server, connects to it and performs some JMS operations. We then
+ <p>When the client reattaches to the server it will be able to resume using its sessions and connections
+ where it left off</p>
+ <p>This is different to client reconnect as the sessions, consumers etc still exist on the server. With reconnect
+ The client recreates its sessions and consumers as needed.</p>
+ <p>This example starts a single server, connects to it and performs some JMS operations. We then
simulate failure of the network connection by temporarily stopping the network acceptor on the server.
(This is done by sending management messages, but that is not central to the purpose of the example).</p>
- <p>We then wait a few seconds, then restart the acceptor. The client reconnects and the session resumes
+ <p>We then wait a few seconds, then restart the acceptor. The client reattaches and the session resumes
as if nothing happened.</p>
- <p>The JMS Connection Factory is configured to reconnect automatically by specifying the various reconnect
- related attributes in the <code>hornetq-jms.xml</code> file.</p>
-
+ <p>The JMS Connection Factory is configured to reattach automatically by specifying the various reconnect
+ related attributes in the <code>hornetq-jms.xml</code> file.</p>
+
<p>For more details on how to configure this and for clustering in general
please consult the HornetQ user manual.</p>
-
+
<br>
<h2>Example step-by-step</h2>
<p><i>To run the example, simply type <code>./build.sh</code> (or <code>build.bat</code> on windows) from this directory</i></p>
@@ -91,10 +90,10 @@
<pre class="prettyprint">
<code>stopAcceptor(initialContext);</code>
</pre>
-
+
<li>We wait 10 seconds, before restarting the acceptor. During this period the client will be retrying
to connect. When the acceptor is restarted it will be successful in reconnecting.</li>
-
+
<pre class="prettyprint">
<code>
Thread.sleep(10000);
@@ -102,9 +101,9 @@
startAcceptor(initialContext);
</code>
</pre>
-
- <li>We receive the message after reconnection! Note that no exceptions were received by the client.</li>
-
+
+ <li>We receive the message after reattachment! Note that no exceptions were received by the client.</li>
+
<pre class="prettyprint">
<code>
TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
Copied: trunk/examples/jms/reconnect-same-node/src/org/hornetq/jms/example/ReattachExample.java (from rev 8453, trunk/examples/jms/reconnect-same-node/src/org/hornetq/jms/example/ReconnectSameNodeExample.java)
===================================================================
--- trunk/examples/jms/reconnect-same-node/src/org/hornetq/jms/example/ReattachExample.java (rev 0)
+++ trunk/examples/jms/reconnect-same-node/src/org/hornetq/jms/example/ReattachExample.java 2009-11-29 15:09:08 UTC (rev 8454)
@@ -0,0 +1,166 @@
+/*
+ * 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.jms.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+import org.hornetq.common.example.HornetQExample;
+import org.hornetq.jms.HornetQQueue;
+import org.hornetq.jms.server.management.impl.JMSManagementHelper;
+
+/**
+ * This examples demonstrates a connection created to a server. Failure of the network connection is then simulated
+ *
+ * The network is brought back up and the client reconnects and resumes transparently.
+ *
+ * @author <a href="tim.fox(a)jboss.com>Tim Fox</a>
+ */
+public class ReattachExample extends HornetQExample
+{
+ public static void main(String[] args)
+ {
+ new ReattachExample().run(args);
+ }
+
+ public boolean runExample() throws Exception
+ {
+ Connection connection = null;
+ InitialContext initialContext = null;
+
+ try
+ {
+ // Step 1. Create an initial context to perform the JNDI lookup.
+ initialContext = getContext(0);
+
+ // Step 2. Perform a lookup on the queue
+ Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
+
+ // 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 9. Create a JMS Message Consumer
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+
+ // Step 10. Start the Connection
+ connection.start();
+
+ // Step 11. To simulate a temporary problem on the network, we stop the remoting acceptor on the
+ // server which will close all connections
+ stopAcceptor(initialContext);
+
+ System.out.println("Acceptor now stopped, will wait for 10 seconds. This simulates the network connection failing for a while");
+
+ // Step 12. Wait a while then restart the acceptor
+ Thread.sleep(10000);
+
+ System.out.println("Re-starting acceptor");
+
+ startAcceptor(initialContext);
+
+ System.out.println("Restarted acceptor. The client will now reconnect.");
+
+ // Step 13. We receive the message
+ TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
+
+ System.out.println("Received message: " + messageReceived.getText());
+
+ return true;
+ }
+ finally
+ {
+ // Step 14. Be sure to close our JMS resources!
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+
+ private void stopAcceptor(InitialContext ic) throws Exception
+ {
+ this.stopStartAcceptor(ic, true);
+ }
+
+ private void startAcceptor(InitialContext ic) throws Exception
+ {
+ this.stopStartAcceptor(ic, false);
+ }
+
+ // To do this we send a management message to close the acceptor, we do this on a different
+ // connection factory which uses a different remoting connection so we can still send messages
+ // when the main connection has been stopped
+ private void stopStartAcceptor(InitialContext initialContext, boolean stop) throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory2");
+
+ Connection connection = null;
+ try
+ {
+ connection = cf.createConnection();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue managementQueue = new HornetQQueue("hornetq.management", "hornetq.management");
+
+ MessageProducer producer = session.createProducer(managementQueue);
+
+ connection.start();
+
+ Message m = session.createMessage();
+
+ String oper = stop ? "stop" : "start";
+
+ JMSManagementHelper.putOperationInvocation(m, "core.acceptor.netty-acceptor", oper);
+
+ producer.send(m);
+ }
+ finally
+ {
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+
+}
Deleted: trunk/examples/jms/reconnect-same-node/src/org/hornetq/jms/example/ReconnectSameNodeExample.java
===================================================================
--- trunk/examples/jms/reconnect-same-node/src/org/hornetq/jms/example/ReconnectSameNodeExample.java 2009-11-28 22:57:54 UTC (rev 8453)
+++ trunk/examples/jms/reconnect-same-node/src/org/hornetq/jms/example/ReconnectSameNodeExample.java 2009-11-29 15:09:08 UTC (rev 8454)
@@ -1,166 +0,0 @@
-/*
- * 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.jms.example;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-
-import org.hornetq.common.example.HornetQExample;
-import org.hornetq.jms.HornetQQueue;
-import org.hornetq.jms.server.management.impl.JMSManagementHelper;
-
-/**
- * This examples demonstrates a connection created to a server. Failure of the network connection is then simulated
- *
- * The network is brought back up and the client reconnects and resumes transparently.
- *
- * @author <a href="tim.fox(a)jboss.com>Tim Fox</a>
- */
-public class ReconnectSameNodeExample extends HornetQExample
-{
- public static void main(String[] args)
- {
- new ReconnectSameNodeExample().run(args);
- }
-
- public boolean runExample() throws Exception
- {
- Connection connection = null;
- InitialContext initialContext = null;
-
- try
- {
- // Step 1. Create an initial context to perform the JNDI lookup.
- initialContext = getContext(0);
-
- // Step 2. Perform a lookup on the queue
- Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
-
- // 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 9. Create a JMS Message Consumer
- MessageConsumer messageConsumer = session.createConsumer(queue);
-
- // Step 10. Start the Connection
- connection.start();
-
- // Step 11. To simulate a temporary problem on the network, we stop the remoting acceptor on the
- // server which will close all connections
- stopAcceptor(initialContext);
-
- System.out.println("Acceptor now stopped, will wait for 10 seconds. This simulates the network connection failing for a while");
-
- // Step 12. Wait a while then restart the acceptor
- Thread.sleep(10000);
-
- System.out.println("Re-starting acceptor");
-
- startAcceptor(initialContext);
-
- System.out.println("Restarted acceptor. The client will now reconnect.");
-
- // Step 13. We receive the message
- TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
-
- System.out.println("Received message: " + messageReceived.getText());
-
- return true;
- }
- finally
- {
- // Step 14. Be sure to close our JMS resources!
- if (initialContext != null)
- {
- initialContext.close();
- }
-
- if (connection != null)
- {
- connection.close();
- }
- }
- }
-
- private void stopAcceptor(InitialContext ic) throws Exception
- {
- this.stopStartAcceptor(ic, true);
- }
-
- private void startAcceptor(InitialContext ic) throws Exception
- {
- this.stopStartAcceptor(ic, false);
- }
-
- // To do this we send a management message to close the acceptor, we do this on a different
- // connection factory which uses a different remoting connection so we can still send messages
- // when the main connection has been stopped
- private void stopStartAcceptor(InitialContext initialContext, boolean stop) throws Exception
- {
- ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory2");
-
- Connection connection = null;
- try
- {
- connection = cf.createConnection();
-
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Queue managementQueue = new HornetQQueue("hornetq.management", "hornetq.management");
-
- MessageProducer producer = session.createProducer(managementQueue);
-
- connection.start();
-
- Message m = session.createMessage();
-
- String oper = stop ? "stop" : "start";
-
- JMSManagementHelper.putOperationInvocation(m, "core.acceptor.netty-acceptor", oper);
-
- producer.send(m);
- }
- finally
- {
- if (connection != null)
- {
- connection.close();
- }
- }
- }
-
-}
14 years, 11 months
JBoss hornetq SVN: r8453 - trunk/src/main/org/hornetq/core/journal/impl.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-11-28 17:57:54 -0500 (Sat, 28 Nov 2009)
New Revision: 8453
Modified:
trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java
Log:
Replacing perfBlast
Modified: trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-28 22:04:18 UTC (rev 8452)
+++ trunk/src/main/org/hornetq/core/journal/impl/JournalImpl.java 2009-11-28 22:57:54 UTC (rev 8453)
@@ -3370,13 +3370,29 @@
{
lockAppend.lock();
-// HornetQBuffer bb = newBuffer(128 * 1024);
-//
-// for (int i = 0; i < pages; i++)
-// {
-// appendRecord(bb, false, false, null, null);
-// }
+ final ByteArrayEncoding byteEncoder = new ByteArrayEncoding(new byte[128 * 1024]);
+
+ JournalInternalRecord blastRecord = new JournalInternalRecord()
+ {
+ @Override
+ public int getEncodeSize()
+ {
+ return byteEncoder.getEncodeSize();
+ }
+
+ public void encode(HornetQBuffer buffer)
+ {
+ byteEncoder.encode(buffer);
+ }
+ };
+
+
+ for (int i = 0; i < pages; i++)
+ {
+ appendRecord(blastRecord, false, false, null, null);
+ }
+
lockAppend.unlock();
}
catch (Exception e)
14 years, 11 months