Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed hajndi example as no longer valid

  • Loading branch information...
commit 2d3d6cb9e2d2a9915b466e643b9862ee37bf0bcf 1 parent 8c5478c
@andytaylor authored
View
13 examples/javaee/hajndi/build.bat
@@ -1,13 +0,0 @@
-@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="
View
15 examples/javaee/hajndi/build.sh
@@ -1,15 +0,0 @@
-#!/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
-
-
-
View
50 examples/javaee/hajndi/build.xml
@@ -1,50 +0,0 @@
-<?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 HAJNDI Example">
-
- <import file="../common/build.xml"/>
-
- <target name="deploy">
- <property name="deploy.dir" value="${jboss.home}/server/all-with-hornetq/deploy/" />
- <property name="deploy.dir2" value="${jboss.home}/server/all-with-hornetq_2/deploy/" />
-
- <!-- copy 1st server resources configuration -->
- <copy file="${example.config.dir}/hornetq-queues.xml" todir="${deploy.dir}/hornetq.sar/" overwrite="yes"/>
- <copy file="${example.config.dir}/hornetq-jms.xml" todir="${deploy.dir}/hornetq.sar/" overwrite="yes"/>
-
- <!-- copy 2nd server resources configuration -->
- <copy file="${example.config.dir}/hornetq-queues.xml" todir="${deploy.dir2}/hornetq.sar/" overwrite="yes"/>
- <copy file="${example.config.dir}/hornetq-jms.xml" todir="${deploy.dir2}/hornetq.sar/" overwrite="yes"/>
- </target>
-
- <target name="undeploy">
- <property name="deploy.dir" value="${jboss.home}/server/all-with-hornetq/deploy/" />
- <property name="deploy.dir2" value="${jboss.home}/server/all-with-hornetq_2/deploy/" />
-
- <!-- delete 1st server resources configuration -->
- <delete file="${deploy.dir}/hornetq.sar/hornetq-queues.xml" failonerror="false"/>
- <delete file="${deploy.dir}/hornetq.sar/hornetq-jms.xml" failonerror="false"/>
-
- <!-- delete 2nd server resources configuration -->
- <delete file="${deploy.dir2}/hornetq.sar/hornetq-queues.xml" failonerror="false"/>
- <delete file="${deploy.dir2}/hornetq.sar/hornetq-jms.xml" failonerror="false"/>
- </target>
-
- <target name="run">
- <antcall target="runExample">
- <param name="example.classname" value="org.hornetq.javaee.example.HAJNDIExample"/>
- </antcall>
- </target>
-
-</project>
View
27 examples/javaee/hajndi/config/META-INF/application.xml
@@ -1,27 +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.
- -->
-<application>
- <display-name>My Application</display-name>
-
- <module>
- <web>
- <web-uri>hajndi-example.war</web-uri>
- <context-root>/hornetq</context-root>
- </web>
- </module>
- <module>
- <java>hajndi-example.jar</java>
- </module>
-
-
-</application>
View
14 examples/javaee/hajndi/config/hornetq-jms.xml
@@ -1,14 +0,0 @@
-<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-connector"/>
- </connectors>
- <entries>
- <entry name="ConnectionFactory"/>
- <entry name="XAConnectionFactory"/>
- </entries>
- </connection-factory>
-</configuration>
View
24 examples/javaee/hajndi/config/hornetq-queues.xml
@@ -1,24 +0,0 @@
-<configuration xmlns="urn:hornetq"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="urn:hornetq ../../../../src/schemas/hornetq-configuration.xsd ">
-
- <security-settings>
- <security-setting match="jms.queue.testQueue">
- <permission type="consume" roles="guest,publisher"/>
- <permission type="send" roles="guest,publisher"/>
- </security-setting>
- </security-settings>
-
- <address-settings>
- <!--default for catch all-->
- <address-setting match="#">
- <dead-letter-address>jms.queue.DLQ</dead-letter-address>
- <expiry-address>jms.queue.ExpiryQueue</expiry-address>
- <redelivery-delay>0</redelivery-delay>
- <max-size-bytes>-1</max-size-bytes>
- <page-size-bytes>10485760</page-size-bytes>
- <message-counter-history-day-limit>10</message-counter-history-day-limit>
- </address-setting>
- </address-settings>
-
-</configuration>
View
98 examples/javaee/hajndi/readme.html
@@ -1,98 +0,0 @@
-<html>
- <head>
- <title>HornetQ Java EE HA-JNDI 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>Java EE HA-JNDI Example</h1>
-
- <p>This example demonstrates the use of High Availability JNDI (HA-JNDI) to lookup HornetQ
- JMS Connection Factories, Queues and Topics.</p>
- <p>With normal JNDI you need to configure the client with the specific connection parameters
- (i.e. host and port) of the JNDI server from which you want to perform look-ups.</p>
- <p>This means if that server crashes, or is not available you won't be able to perform lookups.</p>
- <p>One solution would be for the client to maintain the connection params of all JNDI servers
- in the cluster, but this is not practical.</p>
- <p>With HA-JNDI the client can be simplify configured with UDP address parameters and can transparently
- perform JNDI lookups without having to worry about a particular server being unavailable.</p>
- <p>HA-JNDI is a service of JBoss Application Server and is not available by default when running against
- a stand-alone HornetQ instance.</p>
- <p>An alternative approach is to avoid JNDI together and directly instantiate JMS Connection Factory,
- Queue and Topic instances on the client side. HornetQ Connection Factory instances can
- also be configured to use UDP discovery so the specific details of the available servers are
- not required on the client side.</p>
- <p>For more information on instantiating Connection Factory objects directly please see the user
- manual and the <i>Instantiate Connection Factory</i> example.</p>
- <p>For more information on HA-JNDI, please consult the <a href="http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Clustering_Guide/5/html/clustering-jndi.html">JBoss Application Server Clustering Documentation</a>.</p>
- <p>This example demonstrates a simple symmetric clustering configuration, and failover on JNDI (HAJNDI).</p>
-
- <h2>Example configuration</h2>
-
- <p>To run the example, you need to download JBoss AS 5.x and create a clustered configuration for HornetQ.</p>
-
- <p>Please refer to HornetQ Quickstart guide to <a href="../../../docs/quickstart-guide/en/html_single/index.html#installation.jboss">install it in JBoss AS 5<a></p>
-
- <p>To run this example, we will need two clustered profiles, one for each server instance:</li>
- <li>Copy the directory <code>$JBOSS_HOME/server/all-with-hornetq</code> to <code>$JBOSS_HOME/server/all-with-hornetq_2</code></li>
- <li>Start the first server with <code>./run.sh -c all-with-hornetq</code></li>
- <li>Start the second server with <code>./run.sh -c all-with-hornetq_2 -Djboss.service.binding.set=ports-01</code></li>
- </ol>
- <h2>Example step by step</h2>
- <ol>
- <li>Create a JNDI Context using HAJNDI Properties.
- <p>This JNDI is performing auto-discovery of the servers, by using the default UDP properties.</p>
- <p>You will find more information about these properties at the </p>
- </li>
- <pre class="prettyprint">
- Hashtable jndiParameters = new Hashtable();
- jndiParameters.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- jndiParameters.put("java.naming.factory.url.pkgs=", "org.jboss.naming:org.jnp.interfaces");
-
- initialContext = new InitialContext(jndiParameters);
- </pre>
-
-
- <li>Perform lookups in a loop. As long as you have at least one server alive, these lookups will still work fine
- <pre class="prettyprint">
- for (int i = 0; i &lt; 100; i++)
- {
- ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
- </pre>
- </li>
-
- <li>Create and close a JMS Connection, just to show the downloaded Connection Factory is working
- <pre class="prettyprint">
- connection = cf.createConnection();
- connection.close();
- </pre>
- </li>
-
-
- <li>As the example sleeps here, use this time to kill one of the servers. You will realise that lookups will still work as long as you have a live server
-
- <pre class="prettyprint">
- System.out.println("Connection " + i + " was created and closed. If you kill any of the servers now, the lookup operation on Step 2 will still work fine");
- Thread.sleep(5000);
- </pre>
- </li>
-
- <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
-
- <pre class="prettyprint">
- finally
- {
- if (initialContext != null)
- {
- initialContext.close();
- }
- if (connection != null)
- {
- connection.close();
- }
- }
- </pre>
- </ol>
- </body>
-</html>
View
80 examples/javaee/hajndi/src/org/hornetq/javaee/example/HAJNDIExample.java
@@ -1,80 +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.javaee.example;
-
-import java.util.Hashtable;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.naming.InitialContext;
-
-/**
- *
- * This example demonstrates the use of HA-JNDI to look-up JMS Connection Factories from JNDI.
- *
- * For more information please see the readme.html file.
- *
- * @author <a href="mailto:csuconic@jboss.org">Clebert Suconic</a>
- */
-public class HAJNDIExample
-{
- public static void main(final String[] args) throws Exception
- {
- Connection connection = null;
- InitialContext initialContext = null;
-
- try
- {
- // Step 1. Create an initial context to perform the JNDI lookup.
- // This JNDI is performing auto-discovery of the servers, by using the default UDP properties.
- // You will find more information at the JBoss Application Server Documentation:
- // http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Clustering_Guide/5/html/clustering-jndi.html
-
- Hashtable<String, String> jndiParameters = new Hashtable<String, String>();
- jndiParameters.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- jndiParameters.put("java.naming.factory.url.pkgs=", "org.jboss.naming:org.jnp.interfaces");
-
- initialContext = new InitialContext(jndiParameters);
-
- for (int i = 0; i < 100; i++)
- {
- // Step 2. Perform a lookup on the Connection Factory
- ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
-
- // Step 3. Create a JMS Connection
- connection = cf.createConnection();
- connection.close();
-
- // Step 4. Kill any of the servers. The Lookups will still be performed ok as long as you keep at least one
- // server alive.
- System.out.println("Connection " + i +
- " was created. If you kill any of the servers now, the lookup operation on Step 2 will still work fine");
- Thread.sleep(5000);
- }
-
- System.out.println("Done");
- }
- finally
- {
- // Step 5. Be sure to close our JMS resources!
- if (initialContext != null)
- {
- initialContext.close();
- }
- if (connection != null)
- {
- connection.close();
- }
- }
- }
-}
Please sign in to comment.
Something went wrong with that request. Please try again.