Author: jmesnil
Date: 2010-07-19 08:12:07 -0400 (Mon, 19 Jul 2010)
New Revision: 9411
Modified:
branches/2_2_0_HA_Improvements/examples/core/embedded-remote/
branches/2_2_0_HA_Improvements/examples/core/embedded-remote/readme.html
branches/2_2_0_HA_Improvements/examples/core/embedded-remote/src/org/hornetq/core/example/EmbeddedRemoteExample.java
branches/2_2_0_HA_Improvements/examples/core/embedded/
branches/2_2_0_HA_Improvements/examples/core/embedded/readme.html
branches/2_2_0_HA_Improvements/examples/core/embedded/src/org/hornetq/core/example/EmbeddedExample.java
branches/2_2_0_HA_Improvements/examples/core/microcontainer/
branches/2_2_0_HA_Improvements/examples/core/microcontainer/readme.html
branches/2_2_0_HA_Improvements/examples/core/microcontainer/src/org/hornetq/core/example/EmbeddedMicroContainerExample.java
Log:
HA refactoring
* fix core examples to use ServerLocator API
Property changes on: branches/2_2_0_HA_Improvements/examples/core/embedded
___________________________________________________________________
Name: svn:ignore
- logs
build
+ logs
build
data
Modified: branches/2_2_0_HA_Improvements/examples/core/embedded/readme.html
===================================================================
--- branches/2_2_0_HA_Improvements/examples/core/embedded/readme.html 2010-07-19 12:10:34
UTC (rev 9410)
+++ branches/2_2_0_HA_Improvements/examples/core/embedded/readme.html 2010-07-19 12:12:07
UTC (rev 9411)
@@ -39,7 +39,8 @@
<li>As we are not using a JNDI environment we instantiate the objects
directly</li>
<pre class="prettyprint">
- ClientSessionFactory sf = HornetQClient.createClientSessionFactory(new
TransportConfiguration(InVMConnectorFactory.class.getName()));
+ ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(InVMConnectorFactory.class.getName()));
+ ClientSessionFactory sf = serverLocator.createSessionFactory();
</pre>
<li>Create a Core Queue</li>
@@ -80,12 +81,9 @@
<li>Be sure to close our resources!</li>
<pre class="prettyprint">
- finally
+ if (sf != null)
{
- if (connection != null)
- {
- connection.close();
- }
+ sf.close();
}
</pre>
Modified:
branches/2_2_0_HA_Improvements/examples/core/embedded/src/org/hornetq/core/example/EmbeddedExample.java
===================================================================
---
branches/2_2_0_HA_Improvements/examples/core/embedded/src/org/hornetq/core/example/EmbeddedExample.java 2010-07-19
12:10:34 UTC (rev 9410)
+++
branches/2_2_0_HA_Improvements/examples/core/embedded/src/org/hornetq/core/example/EmbeddedExample.java 2010-07-19
12:12:07 UTC (rev 9411)
@@ -13,10 +13,15 @@
package org.hornetq.core.example;
import java.util.Date;
-import java.util.HashMap;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
@@ -51,8 +56,9 @@
server.start();
// Step 3. As we are not using a JNDI environment we instantiate the objects
directly
- ClientSessionFactory sf = HornetQClient.createClientSessionFactory(new
TransportConfiguration(InVMConnectorFactory.class.getName()));
-
+ ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(InVMConnectorFactory.class.getName()));
+ ClientSessionFactory sf = serverLocator.createSessionFactory();
+
// Step 4. Create a core queue
ClientSession coreSession = sf.createSession(false, false, false);
@@ -94,9 +100,9 @@
finally
{
// Step 9. Be sure to close our resources!
- if (session != null)
+ if (sf != null)
{
- session.close();
+ sf.close();
}
// Step 10. Stop the server
@@ -109,13 +115,4 @@
System.exit(-1);
}
}
-
- {
- HashMap<String, Object> map = new HashMap<String, Object>();
- map.put("host", "localhost");
- map.put("port", 5445);
- TransportConfiguration config = new
TransportConfiguration(InVMConnectorFactory.class.getName(), map);
- ClientSessionFactory sf = HornetQClient.createClientSessionFactory(config);
- }
-
}
Property changes on: branches/2_2_0_HA_Improvements/examples/core/embedded-remote
___________________________________________________________________
Name: svn:ignore
- build
+ build
data
Modified: branches/2_2_0_HA_Improvements/examples/core/embedded-remote/readme.html
===================================================================
--- branches/2_2_0_HA_Improvements/examples/core/embedded-remote/readme.html 2010-07-19
12:10:34 UTC (rev 9410)
+++ branches/2_2_0_HA_Improvements/examples/core/embedded-remote/readme.html 2010-07-19
12:12:07 UTC (rev 9411)
@@ -52,7 +52,8 @@
<li>As we are not using a JNDI environment we instantiate the objects
directly</li>
<pre class="prettyprint">
- ClientSessionFactory sf = HornetQClient.createClientSessionFactory(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ ClientSessionFactory sf = serverLocator.createSessionFactory();
</pre>
<li>Create a Core Queue</li>
@@ -93,12 +94,9 @@
<li>Be sure to close our resources!</li>
<pre class="prettyprint">
- finally
+ if (sf != null)
{
- if (connection != null)
- {
- connection.close();
- }
+ sf.close();
}
</pre>
Modified:
branches/2_2_0_HA_Improvements/examples/core/embedded-remote/src/org/hornetq/core/example/EmbeddedRemoteExample.java
===================================================================
---
branches/2_2_0_HA_Improvements/examples/core/embedded-remote/src/org/hornetq/core/example/EmbeddedRemoteExample.java 2010-07-19
12:10:34 UTC (rev 9410)
+++
branches/2_2_0_HA_Improvements/examples/core/embedded-remote/src/org/hornetq/core/example/EmbeddedRemoteExample.java 2010-07-19
12:12:07 UTC (rev 9411)
@@ -15,7 +15,13 @@
import java.util.Date;
import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientConsumer;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
+import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.common.example.SpawnedVMSupport;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
@@ -42,7 +48,8 @@
process = EmbeddedRemoteExample.startRemoteEmbedded();
// Step 4. As we are not using a JNDI environment we instantiate the objects
directly
- ClientSessionFactory sf = HornetQClient.createClientSessionFactory(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ ClientSessionFactory sf = serverLocator.createSessionFactory();
// Step 5. Create a core queue
ClientSession coreSession = sf.createSession(false, false, false);
@@ -85,9 +92,9 @@
finally
{
// Step 10. Be sure to close our resources!
- if (session != null)
+ if (sf != null)
{
- session.close();
+ sf.close();
}
if (process != null)
Property changes on: branches/2_2_0_HA_Improvements/examples/core/microcontainer
___________________________________________________________________
Name: svn:ignore
- build
+ build
data
Modified: branches/2_2_0_HA_Improvements/examples/core/microcontainer/readme.html
===================================================================
--- branches/2_2_0_HA_Improvements/examples/core/microcontainer/readme.html 2010-07-19
12:10:34 UTC (rev 9410)
+++ branches/2_2_0_HA_Improvements/examples/core/microcontainer/readme.html 2010-07-19
12:12:07 UTC (rev 9411)
@@ -24,7 +24,8 @@
<li>As we are not using a JNDI environment we instantiate the objects
directly</li>
<pre class="prettyprint">
- ClientSessionFactory sf = HornetQClient.createClientSessionFactory (new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ ClientSessionFactory sf = serverLocator.createSessionFactory();
</pre>
<li>Create a Core Queue</li>
@@ -65,12 +66,9 @@
<li>Be sure to close our resources!</li>
<pre class="prettyprint">
- finally
+ if (sf != null)
{
- if (connection != null)
- {
- connection.close();
- }
+ sf.close();
}
</pre>
Modified:
branches/2_2_0_HA_Improvements/examples/core/microcontainer/src/org/hornetq/core/example/EmbeddedMicroContainerExample.java
===================================================================
---
branches/2_2_0_HA_Improvements/examples/core/microcontainer/src/org/hornetq/core/example/EmbeddedMicroContainerExample.java 2010-07-19
12:10:34 UTC (rev 9410)
+++
branches/2_2_0_HA_Improvements/examples/core/microcontainer/src/org/hornetq/core/example/EmbeddedMicroContainerExample.java 2010-07-19
12:12:07 UTC (rev 9411)
@@ -42,7 +42,8 @@
hornetQ.run();
// Step 2. As we are not using a JNDI environment we instantiate the objects
directly
- ClientSessionFactory sf = HornetQClient.createClientSessionFactory(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NettyConnectorFactory.class.getName()));
+ ClientSessionFactory sf = serverLocator.createSessionFactory();
// Step 3. Create a core queue
ClientSession coreSession = sf.createSession(false, false, false);
@@ -86,9 +87,9 @@
finally
{
// Step 8. Be sure to close our resources!
- if (session != null)
+ if (sf != null)
{
- session.close();
+ sf.close();
}
// Step 9. Shutdown the container
Show replies by date