[jboss-cvs] JBoss Messaging SVN: r4080 - in trunk/docs/examples: messaging and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 18 05:46:17 EDT 2008


Author: ataylor
Date: 2008-04-18 05:46:17 -0400 (Fri, 18 Apr 2008)
New Revision: 4080

Added:
   trunk/docs/examples/messaging/
   trunk/docs/examples/messaging/build.xml
   trunk/docs/examples/messaging/src/
   trunk/docs/examples/messaging/src/org/
   trunk/docs/examples/messaging/src/org/jboss/
   trunk/docs/examples/messaging/src/org/jboss/messaging/
   trunk/docs/examples/messaging/src/org/jboss/messaging/example/
   trunk/docs/examples/messaging/src/org/jboss/messaging/example/SimpleClient.java
Log:
added simple core client example

Added: trunk/docs/examples/messaging/build.xml
===================================================================
--- trunk/docs/examples/messaging/build.xml	                        (rev 0)
+++ trunk/docs/examples/messaging/build.xml	2008-04-18 09:46:17 UTC (rev 4080)
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- =========================================================================================== -->
+<!--                                                                                             -->
+<!-- JBoss, Home of Professional Open Source                                                     -->
+<!-- Copyright 2005, JBoss Inc., and individual contributors as indicated                        -->
+<!-- by the @authors tag. See the copyright.txt in the distribution for a                        -->
+<!-- full listing of individual contributors.                                                    -->
+<!--                                                                                             -->
+<!-- This is free software; you can redistribute it and/or modify it                             -->
+<!-- under the terms of the GNU Lesser General Public License as                                 -->
+<!-- published by the Free Software Foundation; either version 2.1 of                            -->
+<!-- the License, or (at your option) any later version.                                         -->
+<!--                                                                                             -->
+<!-- This software is distributed in the hope that it will be useful,                            -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of                              -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU                            -->
+<!-- Lesser General Public License for more details.                                             -->
+<!--                                                                                             -->
+<!-- You should have received a copy of the GNU Lesser General Public                            -->
+<!-- License along with this software; if not, write to the Free                                 -->
+<!-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA                          -->
+<!-- 02110-1301 USA, or see the FSF site: http://www.fsf.org.                                    -->
+<!--                                                                                             -->
+<!-- =========================================================================================== -->
+
+
+<!-- =========================================================================================== -->
+<!--                                                                                             -->
+<!-- $Id: build.xml 4037 2008-04-11 13:12:57Z ataylor $ -->
+<!--                                                                                             -->
+<!-- =========================================================================================== -->
+
+
+<project default="compile" name="JBoss Messaging JMS Examples">
+
+   <property file="../build.properties"/>
+
+   <property name="src.dir" value="src"/>
+   <property name="build.dir" value="build"/>
+
+   <path id="compile.classpath">
+      <fileset dir="${lib.dir}">
+         <include name="**/*.jar"/>
+      </fileset>
+   </path>
+
+   <path id="runtime.classpath">
+      <path refid="compile.classpath"/>
+      <pathelement location="${build.dir}"/>
+      <pathelement location="${client.jar}"/>
+   </path>
+
+   <target name="clean">
+      <delete dir="${build.dir}"/>
+   </target>
+
+   <target name="init">
+      <mkdir dir="${build.dir}"/>
+   </target>
+
+
+   <target name="compile" depends="init">
+      <javac srcdir="${src.dir}" destdir="${build.dir}" debug="on"
+         source="1.5">
+         <classpath refid="compile.classpath"/>
+      </javac>
+   </target>
+
+    <target name="SimpleClient" depends="compile">
+      <java classname="org.jboss.messaging.example.SimpleClient" fork="true">
+         <classpath refid="runtime.classpath"/>
+      </java>
+   </target>
+
+</project>
\ No newline at end of file

Added: trunk/docs/examples/messaging/src/org/jboss/messaging/example/SimpleClient.java
===================================================================
--- trunk/docs/examples/messaging/src/org/jboss/messaging/example/SimpleClient.java	                        (rev 0)
+++ trunk/docs/examples/messaging/src/org/jboss/messaging/example/SimpleClient.java	2008-04-18 09:46:17 UTC (rev 4080)
@@ -0,0 +1,55 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY WARRANTY; without even the implied warranty of
+   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   * Lesser General Public License for more details.
+   *
+   * You should have received a copy of the GNU Lesser General Public
+   * License along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+package org.jboss.messaging.example;
+
+import org.jboss.messaging.core.client.*;
+import org.jboss.messaging.core.client.impl.*;
+import org.jboss.messaging.core.remoting.TransportType;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.message.impl.MessageImpl;
+import org.jboss.messaging.jms.client.JBossTextMessage;
+
+/**
+ * Uses the core messaging API to send and receive a message to a queue.
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class SimpleClient
+{
+   public static void main(String[] args) throws Exception
+   {
+      Location location = new LocationImpl(TransportType.TCP, "localhost", 5400);
+      ConnectionParams connectionParams = new ConnectionParamsImpl();
+      ClientConnectionFactory connectionFactory = new ClientConnectionFactoryImpl(0, location, connectionParams);
+      ClientConnection clientConnection = connectionFactory.createConnection();
+      ClientSession clientSession = clientConnection.createClientSession(false, true, true, 100, true, false);
+      ClientProducer clientProducer = clientSession.createProducer("queuejms.testQueue");
+      Message message = new MessageImpl(JBossTextMessage.TYPE, false, 0,
+            System.currentTimeMillis(), (byte) 1);
+      message.setPayload("Hello!".getBytes());
+      clientProducer.send(message);
+      ClientConsumer clientConsumer = clientSession.createConsumer("queuejms.testQueue", null, false, false, false);
+      clientConnection.start();
+      Message msg = clientConsumer.receive(5000);
+      System.out.println("msg.getPayload() = " + new String(msg.getPayload()));
+      clientConnection.close();
+   }
+}




More information about the jboss-cvs-commits mailing list