User: hiram   
  Date: 01/03/01 23:04:49

  Modified:    src/examples MyMessage.java TestClient.java build.bat
                        build.sh
  Added:       src/examples ClusterReceiver.java ClusterReply.java
                        ClusterRequest.java ClusterSender.java
                        cluster-run.bat
  Log:
  - Changed Source references of GPL to LGPL.
  - The cluster work that I had been doing is now accesible via a Pub-Sub JMS api.
  - Take a look at the Cluster* examples in the sample directory to test it out.
  
  Revision  Changes    Path
  1.2       +2 -2      jbossmq/src/examples/MyMessage.java
  
  Index: MyMessage.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jbossmq/src/examples/MyMessage.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MyMessage.java    2001/01/26 00:42:36     1.1
  +++ MyMessage.java    2001/03/02 07:04:47     1.2
  @@ -1,7 +1,7 @@
   /*
    * JBossMQ, the OpenSource JMS implementation
    *
  - * Distributable under GPL license.
  + * Distributable under LGPL license.
    * See terms of license at gnu.org.
    */
   
  @@ -21,7 +21,7 @@
    *   @author Norbert Lataille ([EMAIL PROTECTED])
    *   @author Hiram Chirino ([EMAIL PROTECTED])
    * 
  - *   @version $Revision: 1.1 $
  + *   @version $Revision: 1.2 $
    */
   public class MyMessage implements Serializable, Message {
        // Constants -----------------------------------------------------
  
  
  
  1.2       +1 -1      jbossmq/src/examples/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jbossmq/src/examples/TestClient.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestClient.java   2001/01/26 00:42:45     1.1
  +++ TestClient.java   2001/03/02 07:04:47     1.2
  @@ -1,7 +1,7 @@
   /*
    * JBossMQ, the OpenSource JMS implementation
    *
  - * Distributable under GPL license.
  + * Distributable under LGPL license.
    * See terms of license at gnu.org.
    */
   
  
  
  
  1.2       +1 -1      jbossmq/src/examples/build.bat
  
  Index: build.bat
  ===================================================================
  RCS file: /products/cvs/ejboss/jbossmq/src/examples/build.bat,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.bat 2001/01/26 00:42:33     1.1
  +++ build.bat 2001/03/02 07:04:47     1.2
  @@ -1 +1 @@
  -javac -classpath 
".;..\conf\default;..\client\jnp-client.jar;..\client\jbossmq-client.jar;..\lib\ext\jms.jar;..\lib\ext\jta-spec1_0_1.jar;..\lib\ext\gnu-regexp-1.0.8.jar"
 *.java
  +javac -classpath 
".;..\conf\default;..\client\jnp-client.jar;..\client\jbossmq-client.jar;..\lib\ext\jbossmq.jar;..\lib\ext\jms.jar;..\lib\ext\jta-spec1_0_1.jar;..\lib\ext\gnu-regexp-1.0.8.jar"
 *.java
  
  
  
  1.2       +1 -1      jbossmq/src/examples/build.sh
  
  Index: build.sh
  ===================================================================
  RCS file: /products/cvs/ejboss/jbossmq/src/examples/build.sh,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.sh  2001/01/26 00:42:33     1.1
  +++ build.sh  2001/03/02 07:04:48     1.2
  @@ -1,2 +1,2 @@
   #!/bin/sh
  -javac -classpath 
".:../conf:../conf/default:../client/jbossmq-client.jar:../client/jnp-client.jar:../lib/ext/jms.jar:../lib/ext/gnu-regexp-1.0.8.jar"
 *.java
  +javac -classpath 
".:../conf:../conf/default:../client/jbossmq-client.jar:../lib/ext/jbossmq.jar:../client/jnp-client.jar:../lib/ext/jms.jar:../lib/ext/gnu-regexp-1.0.8.jar"
 *.java
  
  
  
  1.1                  jbossmq/src/examples/ClusterReceiver.java
  
  Index: ClusterReceiver.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  import javax.jms.*;
  
  /**
   * @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   * @version $Revision: 1.1 $
   */
  public class ClusterReceiver {
  
        public static void main(java.lang.String[] args) throws Exception {
  
                TopicConnectionFactory connectionFactory = new 
org.jbossmq.cluster.jms.ClusterTopicConnectionFactory();
                TopicConnection connection = connectionFactory.createTopicConnection();
                TopicSession session = connection.createTopicSession(false, 0);
                Topic topic = session.createTopic("testTopic");
                TopicSubscriber subcriber = session.createSubscriber(topic);
                TextMessage message;
                connection.start();
  
                System.out.println("Waiting for messages");
                boolean done = false;
                while (!done) {
                        message = (TextMessage) subcriber.receive();
                        System.out.println("Got :" + message.getText());
                }
  
        }
  }
  
  
  1.1                  jbossmq/src/examples/ClusterReply.java
  
  Index: ClusterReply.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  import javax.jms.*;
  
  /**
   * @version $Revision: 1.1 $
   */
  public class ClusterReply {
  
        /**
         * @param args  
         */
        public static void main(String[] args) {
                ClusterReply r = new ClusterReply();
                r.run();
        }
  
        public void run() {
                TopicConnectionFactory  topicConnectionFactory = null;
                TopicConnection         topicConnection = null;
                TopicSession            topicSession = null;
                Topic                   topic = null;
                TopicSubscriber         topicSubscriber = null;
                TextMessage             message = null; 
                Topic                   tempTopic = null;
                TopicPublisher          replyPublisher = null;
                TextMessage             reply = null; 
                final String            REPLY_TEXT = new String("Here is a reply");
  
                try {
                        topicConnectionFactory = new 
org.jbossmq.cluster.jms.ClusterTopicConnectionFactory();
                        topicConnection = 
topicConnectionFactory.createTopicConnection();
                        topicSession = topicConnection.createTopicSession(false,0);
                        topic = topicSession.createTopic("testTopic");
                } catch (Exception e) {
                        System.out.println("Connection problem: " + e.toString());
                        if (topicConnection != null) {
                                try {
                                        topicConnection.close();
                                } catch (JMSException ee) {}
                        }
                        System.exit(1);
                }
  
                /* 
                 * Create a TopicSubscriber.
                 * Start delivery of incoming messages.
                 * Call receive, which blocks until it obtains a message.
                 * Display the message obtained.
                 * Extract the temporary reply topic from the JMSReplyTo field of 
                 * the message header.
                 * Use the temporary topic to create a sender for the reply message.
                 * Create the reply message, setting the JMSCorrelationID to the 
                 * value of the incoming message's JMSMessageID.
                 * Send the reply message.
                 * Finally, close the connection. 
                 */    
                try {
                        topicSubscriber = topicSession.createSubscriber(topic);
                        topicConnection.start();
                        message = (TextMessage) topicSubscriber.receive();
                        System.out.println("REPLY: Message received: " 
                                + message.getText());
                        tempTopic = (Topic) message.getJMSReplyTo();
                        replyPublisher = topicSession.createPublisher(tempTopic);
                        reply = topicSession.createTextMessage();
                        reply.setText(REPLY_TEXT);
                        reply.setJMSCorrelationID(message.getJMSMessageID());
                        System.out.println("REPLY: Sending reply: " + reply.getText());
                        replyPublisher.publish(reply);
                } catch (JMSException e) {
                        System.out.println("Exception occurred: " + e.toString());
                } catch (Exception ee) {
                        System.out.println("Unexpected exception: " + ee.toString());
                        ee.printStackTrace();
                } finally {
                        if (topicConnection != null) {
                                try {
                                        topicConnection.close();
                                } catch (JMSException e) {
                                }
                        }
                }
        }
  }
  
  
  1.1                  jbossmq/src/examples/ClusterRequest.java
  
  Index: ClusterRequest.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  import javax.jms.*;
  
  /**
   */
  public class ClusterRequest {
  
        /**
         * @param args  
         */
        public static void main(String[] args) {
  
                ClusterRequest t = new ClusterRequest();
                t.run();
  
        }
  
        /**
         * Runs the thread.
         */
        public void run() {
  
                TopicConnectionFactory connectionFactory;
                TopicConnection connection;
                TopicSession session;
                Topic topic;
                TopicRequestor topicRequestor;
                TextMessage message;
                TextMessage reply;
  
                final String MSG_TEXT = new String("Here is a request");
                String replyID;
  
                try {
                        connectionFactory = new 
org.jbossmq.cluster.jms.ClusterTopicConnectionFactory();
                        connection = connectionFactory.createTopicConnection();
                        session = connection.createTopicSession(false, 0);
                        topic = session.createTopic("testTopic");
                } catch (Exception e) {
                        System.out.println("Exception occurred: " + e.toString());
                        return;
                }
  
                try {
                        topicRequestor = new TopicRequestor(session, topic);
                        message = session.createTextMessage();
                        message.setText(MSG_TEXT);
                        System.out.println("REQUEST: Sending message: " + 
message.getText());
                        connection.start();
                        reply = (TextMessage) topicRequestor.request(message);
                        System.out.println("REQUEST: Reply received: " + 
reply.getText());
                        replyID = new String(reply.getJMSCorrelationID());
                        if (replyID.equals(message.getJMSMessageID())) {
                                System.out.println("REQUEST: OK: Reply matches sent 
message");
                        } else {
                                System.out.println("REQUEST: ERROR: Reply does not 
match sent message");
                        }
                } catch (JMSException e) {
                        System.out.println("Exception occurred: " + e.toString());
                } catch (Exception ee) {
                        System.out.println("Unexpected exception: " + ee.toString());
                        ee.printStackTrace();
                } finally {
                        if (connection != null) {
                                try {
                                        connection.close();
                                } catch (JMSException e) {
                                }
                        }
                }
        }
  }
  
  
  1.1                  jbossmq/src/examples/ClusterSender.java
  
  Index: ClusterSender.java
  ===================================================================
  /*
   * JBossMQ, the OpenSource JMS implementation
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  
  import javax.jms.*;
  
  /**
   * @author Hiram Chirino ([EMAIL PROTECTED])
   * 
   * @version $Revision: 1.1 $
   */
  public class ClusterSender {
  
        /**
         * Starts the application.
         * @param args an array of command-line arguments
         */
        public static void main(java.lang.String[] args) throws Exception {
  
                TopicConnectionFactory connectionFactory = new 
org.jbossmq.cluster.jms.ClusterTopicConnectionFactory();
                TopicConnection connection = connectionFactory.createTopicConnection();
                TopicSession session = connection.createTopicSession(false, 0);
                Topic topic = session.createTopic("testTopic");
                TopicPublisher publisher = session.createPublisher(topic);
                TextMessage message = session.createTextMessage();
  
                String t = "Hello World";
                for (int i = 0; i < 5; i++) {
                        message.setText(t + " #" + i);
                        publisher.publish(message);
                }
                System.out.println("Messages sent");
  
                synchronized (connectionFactory) {
                        connectionFactory.wait();
                }
        }
  }
  
  
  1.1                  jbossmq/src/examples/cluster-run.bat
  
  Index: cluster-run.bat
  ===================================================================
  java -cp 
".;..\conf\default;..\client\jnp-client.jar;..\lib\ext\jbossmq.jar;..\lib\ext\jms.jar;..\lib\ext\gnu-regexp-1.0.8.jar;..\lib\xml.jar;..\lib\ext\oswego-concurrent.jar"
 %1 %2 %3 %4 %5 %6 %7 %8 %9
  
  
  

Reply via email to