[hornetq-commits] JBoss hornetq SVN: r7864 - in trunk/examples/javaee: jca-config and 8 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Aug 21 08:52:43 EDT 2009


Author: ataylor
Date: 2009-08-21 08:52:42 -0400 (Fri, 21 Aug 2009)
New Revision: 7864

Added:
   trunk/examples/javaee/jca-config/server2/hornetq-configuration.xml
   trunk/examples/javaee/jca-config/src/org/hornetq/
   trunk/examples/javaee/jca-config/src/org/hornetq/javaee/
   trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/
   trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/MDBRemoteClientExample.java
   trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server/
   trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server/MDBQueueA.java
   trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/
   trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/MDBQueueB.java
   trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/StatelessSender.java
   trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/StatelessSenderService.java
Modified:
   trunk/examples/javaee/common/build.xml
   trunk/examples/javaee/jca-config/build.xml
   trunk/examples/javaee/jca-config/server/hornetq-configuration.xml
Log:
readded jca-config example and build fix

Modified: trunk/examples/javaee/common/build.xml
===================================================================
--- trunk/examples/javaee/common/build.xml	2009-08-21 11:51:41 UTC (rev 7863)
+++ trunk/examples/javaee/common/build.xml	2009-08-21 12:52:42 UTC (rev 7864)
@@ -91,7 +91,7 @@
    <target name="jar" depends="compile">
       <jar destfile="${build.dir}/${example.name}-example.jar"
            basedir="${classes.dir}"
-           includes="org/jboss/javaee/example/server/**/*">
+           includes="org/hornetq/javaee/example/server/**/*">
       </jar>
    </target>
 

Modified: trunk/examples/javaee/jca-config/build.xml
===================================================================
--- trunk/examples/javaee/jca-config/build.xml	2009-08-21 11:51:41 UTC (rev 7863)
+++ trunk/examples/javaee/jca-config/build.xml	2009-08-21 12:52:42 UTC (rev 7864)
@@ -19,7 +19,7 @@
    <target name="jar2" depends="compile">
       <jar destfile="${build.dir}/jca-config-example2.jar"
            basedir="${classes.dir}"
-           includes="org/jboss/javaee/example/server2/**/*">
+           includes="org/hornetq/javaee/example/server2/**/*">
       </jar>
    </target>
    <target name="ear2" depends="jar2">
@@ -42,9 +42,10 @@
             <exclude name="**/tmp/**"/>
          </fileset>
       </copy>
-      <copy todir="${deploy.dir2}/deploy/hornetq.sar">
+      <copy todir="${deploy.dir2}/deploy/hornetq.sar" overwrite="true">
          <fileset dir="server2">
             <include name="jms-remote-ds.xml"/>
+            <include name="hornetq-configuration.xml"/>
          </fileset>
       </copy>
       <copy todir="${deploy.dir2}/deploy/jms-ra.rar/META-INF">

Modified: trunk/examples/javaee/jca-config/server/hornetq-configuration.xml
===================================================================
--- trunk/examples/javaee/jca-config/server/hornetq-configuration.xml	2009-08-21 11:51:41 UTC (rev 7863)
+++ trunk/examples/javaee/jca-config/server/hornetq-configuration.xml	2009-08-21 12:52:42 UTC (rev 7864)
@@ -33,7 +33,7 @@
       <!-- Netty TCP Acceptor -->
       <acceptor name="netty">
          <factory-class>org.hornetq.integration.transports.netty.NettyAcceptorFactory</factory-class>
-         <param key="hornetq.remoting.netty.port" value="${hornetq.remoting.netty.port}" type="Integer"/>
+         <param key="hornetq.remoting.netty.port" value="${hornetq.remoting.netty.port:5445}" type="Integer"/>
       </acceptor>
    </acceptors>
 

Copied: trunk/examples/javaee/jca-config/server2/hornetq-configuration.xml (from rev 7854, trunk/examples/javaee/jca-config/server/hornetq-configuration.xml)
===================================================================
--- trunk/examples/javaee/jca-config/server2/hornetq-configuration.xml	                        (rev 0)
+++ trunk/examples/javaee/jca-config/server2/hornetq-configuration.xml	2009-08-21 12:52:42 UTC (rev 7864)
@@ -0,0 +1,56 @@
+<!--
+  ~ Copyright (c) 2009. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+  ~ Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
+  ~ Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
+  ~ Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
+  ~ Vestibulum commodo. Ut rhoncus gravida arcu.
+  -->
+
+<configuration xmlns="urn:hornetq"
+               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+               xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+
+   <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.integration.transports.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="hornetq.remoting.invm.serverid" value="0" type="Integer"/>
+      </acceptor>
+
+      <!-- Netty TCP Acceptor -->
+      <acceptor name="netty">
+         <factory-class>org.hornetq.integration.transports.netty.NettyAcceptorFactory</factory-class>
+         <param key="hornetq.remoting.netty.port" value="${hornetq.remoting.netty.port:5446}" type="Integer"/>
+      </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>

Added: trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/MDBRemoteClientExample.java
===================================================================
--- trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/MDBRemoteClientExample.java	                        (rev 0)
+++ trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/MDBRemoteClientExample.java	2009-08-21 12:52:42 UTC (rev 7864)
@@ -0,0 +1,60 @@
+/*
+ * 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 org.hornetq.javaee.example.server2.StatelessSenderService;
+
+import javax.jms.Connection;
+import javax.naming.InitialContext;
+
+/**
+ *
+ * MDB Remote & JCA Configuration Example.
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ */
+public class MDBRemoteClientExample
+{
+   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. Getting a reference to the Stateless Bean
+         StatelessSenderService sender = (StatelessSenderService)initialContext.lookup("jca-config-example2/StatelessSender/remote");
+
+         //Step 3. Calling a Stateless Session Bean. You will have more steps on the SessionBean
+         sender.sendHello("Hello there MDB!");
+
+         System.out.println("Step 3: Invoking the Stateless Bean");
+
+         initialContext.close();
+      }
+      finally
+      {
+         //Step 11. Be sure to close our JMS resources!
+         if (initialContext != null)
+         {
+            initialContext.close();
+         }
+         if(connection != null)
+         {
+            connection.close();
+         }
+      }
+   }
+}

Added: trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server/MDBQueueA.java
===================================================================
--- trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server/MDBQueueA.java	                        (rev 0)
+++ trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server/MDBQueueA.java	2009-08-21 12:52:42 UTC (rev 7864)
@@ -0,0 +1,52 @@
+/*
+ * 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 javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+/**
+ * MDB that is connected to the remote queue.
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ */
+
+//Step 9. The message is received on the MDB, using a local queue.
+ at MessageDriven(name = "MDB_QueueA",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/A"),
+                        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
+                     })
+public class MDBQueueA implements MessageListener
+{
+   public void onMessage(Message message)
+   {
+      try
+      {
+         TextMessage tm = (TextMessage)message;
+
+         String text = tm.getText();
+
+         System.out.println("Step 10: (MDBQueueA.java) Message received using the default adapter. Message = \"" + text + "\"" );
+
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+}

Added: trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/MDBQueueB.java
===================================================================
--- trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/MDBQueueB.java	                        (rev 0)
+++ trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/MDBQueueB.java	2009-08-21 12:52:42 UTC (rev 7864)
@@ -0,0 +1,52 @@
+/*
+ * 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.server2;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+/**
+ * MDB that is connected to the remote queue.
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ */
+
+//Step 10. The message is received on the MDB, using a remote queue.
+ at MessageDriven(name = "MDB_QueueB",
+               activationConfig =
+                     {
+                        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
+                        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/B"),
+                        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")
+                     })
+public class MDBQueueB implements MessageListener
+{
+   public void onMessage(Message message)
+   {
+      try
+      {
+         TextMessage tm = (TextMessage)message;
+
+         String text = tm.getText();
+
+         System.out.println("Step 11: (MDBQueueB.java) Message received using the remote adapter. Message = \"" + text + "\"" );
+
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+}

Added: trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/StatelessSender.java
===================================================================
--- trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/StatelessSender.java	                        (rev 0)
+++ trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/StatelessSender.java	2009-08-21 12:52:42 UTC (rev 7864)
@@ -0,0 +1,97 @@
+/*
+ * 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.server2;
+
+
+
+import org.hornetq.jms.HornetQQueue;
+
+import javax.annotation.Resource;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+/**
+ * A Stateless Bean that will connect to a remote JBM.
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+ at Remote(StatelessSenderService.class)
+ at Stateless
+public class StatelessSender implements StatelessSenderService
+{
+
+   /**
+    *  Resource to be deployed by jms-remote-ds.xml
+    *  */
+   @Resource(mappedName="java:RemoteJmsXA")
+   private ConnectionFactory connectionFactory;
+
+
+   /* (non-Javadoc)
+    * @see org.jboss.javaee.example.server.StatelessSenderService#sendHello(java.lang.String)
+    */
+   public void sendHello(String message) throws Exception
+   {
+      // Step 4. Define the destinations that will receive the message (instead of using JNDI to the remote server)
+      HornetQQueue destQueueA = new HornetQQueue("A");
+      HornetQQueue destQueueB = new HornetQQueue("B");
+
+      // Step 5. Create a connection to a remote server using a connection-factory (look at the deployed file jms-remote-ds.xml)
+      Connection conn = connectionFactory.createConnection("guest", "guest");
+
+      // Step 6. Send a message to a QueueA on the remote server, which will be received by MDBQueueA
+      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      MessageProducer prodA = sess.createProducer(destQueueA);
+      prodA.send(sess.createTextMessage(message));
+
+      System.out.println("Step 7 (StatelessSender.java): Sent message \"" + message + "\" to QueueA");
+
+      // Step 6. Send a message to a QueueB on the remote server, which will be received by MDBQueueA
+      MessageProducer prodB = sess.createProducer(destQueueB);
+      prodB.send(sess.createTextMessage(message));
+
+      System.out.println("Step 8 (StatelessSender.java): Sent message \"" + message + "\" to QueueB");
+
+      // Step 7. Close the connection. (Since this is a JCA connection, this will just place the connection back to a connection pool)
+      conn.close();
+      System.out.println("Step 9 (StatelessSender.java): Closed Connection (sending it back to pool)");
+
+   }
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Added: trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/StatelessSenderService.java
===================================================================
--- trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/StatelessSenderService.java	                        (rev 0)
+++ trunk/examples/javaee/jca-config/src/org/hornetq/javaee/example/server2/StatelessSenderService.java	2009-08-21 12:52:42 UTC (rev 7864)
@@ -0,0 +1,29 @@
+/*
+ * 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.server2;
+
+/**
+ * A StatelessSenderService
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public interface StatelessSenderService
+{
+
+   public void sendHello(String message) throws Exception;
+
+}



More information about the hornetq-commits mailing list