commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/messenger/src/conf subscribe.xml
Date Mon, 08 Jul 2002 14:37:37 GMT
jstrachan    2002/07/08 07:37:37

  Modified:    messenger/src/java/org/apache/commons/messagelet
                        BridgeMDO.java
               messenger/src/java/org/apache/commons/messenger
                        MessengerSupport.java MessengerSession.java
                        MessengerManager.java
               messenger/src/java/org/apache/commons/messagelet/impl
                        SubscriptionDigester.java
               messenger project.xml
               messenger/src/conf subscribe.xml
  Added:       messenger/src/java/org/apache/commons/messagelet
                        DistributeBridgeMDO.java Main.java
               messenger project-ng.xml maven.xml
  Log:
  Added support for MessageProducer caching to boost performance. This is optional and is
enabled by default. 
  
  It can be disabled via the cacheProducers="false" attribute for example
  
  <messenger cacheProducers="false">
  	...
  
  Also I've added a DistributeBridgeMDO. This is like BridgeMDO, messages are consumed from
one destination and published to another destination (maybe using a different JMS provider
and connection). 
  However the DistributeBridgeMDO allows load balancing of, say, queues. Thats to say the
messages can be randomized onto a number of possible output destinations. This can sometimes
boost JMS throughput performance.
  For example messages could be consumed on IN.A and sent to any of OUT.A, OUT.B, OUT.C, OUT.D.
Then 4 server clusters could run off each of the 4 output queues which typically boosts throughput
(using 4 queues rather than 1) for complex JMS processors.
  
  Also added some extra stuff to keep the build in sync with Maven's CVS HEAD.
  
  Revision  Changes    Path
  1.3       +17 -4     jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/BridgeMDO.java
  
  Index: BridgeMDO.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/BridgeMDO.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BridgeMDO.java	17 May 2002 15:05:46 -0000	1.2
  +++ BridgeMDO.java	8 Jul 2002 14:37:36 -0000	1.3
  @@ -80,9 +80,7 @@
               if ( outputMessenger == null ) {
                   throw new ServletException( "No output Messenger is defined for this Bridge"
);
               }
  -            if ( getOutputDestination() == null ) {
  -                throw new ServletException( "No output Destination is defined for this
Bridge" );
  -            }
  +            validateOutputDestination();
               
               // enable transacted mode 
               messenger.getSessionFactory().setTransacted( true );     
  @@ -107,7 +105,12 @@
           try {
               Message outputMessage = createOutputMessage(message);
               if ( outputMessage != null ) {
  -                getOutputMessenger().send( getOutputDestination(), outputMessage );
  +                Destination destination = getOutputDestination();
  +                
  +                if ( log.isDebugEnabled() ) {
  +                    log.debug( "Sending message to: " + destination );
  +                }
  +                getOutputMessenger().send( destination, outputMessage );
               }
               acknowledge(message);
               acknowledge(outputMessage);
  @@ -368,6 +371,16 @@
       protected void acknowledge(Message message) throws JMSException {
           message.acknowledge();
       }            
  +    
  +    /**
  +     * Validates that there is a valid output destintation that we can use.
  +     * Derivations of this class could use multiple destinations
  +     */
  +    protected void validateOutputDestination() throws JMSException, ServletException {
  +        if ( getOutputDestination() == null ) {
  +            throw new ServletException( "No output Destination is defined for this Bridge"
);
  +        }
  +    }
   }
   
   
  
  
  
  1.1                  jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/DistributeBridgeMDO.java
  
  Index: DistributeBridgeMDO.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   * 
   * $Id: MessengerMDO.java,v 1.2 2001/10/26 11:52:16 jstrachan Exp $
   */
  package org.apache.commons.messagelet;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import javax.jms.Destination;
  import javax.jms.JMSException;
  import javax.jms.Message;
  import javax.servlet.ServletException;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.apache.commons.messenger.Messenger;
  import org.apache.commons.messenger.MessengerManager;
  
  
  /** 
   * <p><code>DistributeBridgeMDO</code> is an MDO which 
   * consumes JMS from one destination and randomly distributes
   * them across a number of other destinations.
   * This MDO can be used to provide a simple load balancing mechanism
   * consuming from one destination and sending messages to a number of different
   * physical destinations.
   * </p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.2 $
   */
  public class DistributeBridgeMDO extends BridgeMDO {
  
      /** Logger */
      private static final Log log = LogFactory.getLog(DistributeBridgeMDO.class);
  
      /** a List of output Destination objects */
      private List outputDestinations = new ArrayList();
        
      public DistributeBridgeMDO() {
      }
      
      // Properties
      //-------------------------------------------------------------------------
  
      /**
       * @return a List of output Destinations
       */    
      public List getOutputDestinations() {
          return outputDestinations;
      }
      
      /**
       * Adds a new output subject
       */
      public void addOutputSubject(String subject) throws JMSException {
          Destination destination = getOutputMessenger().getDestination( subject );
          outputDestinations.add( destination );
      }
      
      
      
      /**
       * Randomly chooses a destination from the list of destinations
       */
      public Destination getOutputDestination() throws JMSException {
          int size = outputDestinations.size();
          if ( size < 1 ) {
              throw new JMSException( "No output destinations are available" );
          }
          
          int index = Math.round( (float) (Math.random() * size ) );
          return (Destination) outputDestinations.get(index);        
      }
      
      
      // Implementation methods
      //-------------------------------------------------------------------------
  
      protected void validateOutputDestination() throws JMSException, ServletException {
          int size = outputDestinations.size();
          if ( size < 1 ) {
              throw new JMSException( "No output destinations are available" );
          }
      }
  }
  
  
  
  
  
  1.1                  jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/Main.java
  
  Index: Main.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   * 
   * $Id: ManagerServlet.java,v 1.12 2002/05/15 14:36:34 jstrachan Exp $
   */
  package org.apache.commons.messagelet;
  
  import java.net.URL;
  import java.util.Iterator;
  
  import javax.jms.Destination;
  import javax.jms.Message;
  import javax.jms.MessageConsumer;
  import javax.jms.MessageListener;
  import javax.jms.JMSException;
  
  import javax.servlet.ServletContext;
  import javax.servlet.ServletException;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.apache.commons.messagelet.impl.Subscription;
  import org.apache.commons.messagelet.impl.SubscriptionDigester;
  import org.apache.commons.messagelet.impl.SubscriptionList;
  import org.apache.commons.messenger.Messenger;
  import org.apache.commons.messenger.MessengerManager;
  
  /** 
   * <p><code>Main</code> is a simple command line program that will
   * create a number of subscriptions and consume messages using just regular 
   * MDO and MessageListener classes.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.12 $
   */
  public class Main {
  
      /** Logger */
      private static final Log log = LogFactory.getLog(DistributeBridgeMDO.class);
  
      /** The JMS connections */    
      private MessengerManager manager;
  
      /** The JMS Subscriptions */
      private SubscriptionList subscriptionList;
      
      /** The URI that connections are loaded from */
      private String connectionsConfig = "Messenger.xml";
      
      /** The URI where subscriptions are loaded from */
      private String subscriptionsConfig = "subscriptions.xml";
      
      public static void main(String[] args) {
          Main main = new Main();
          if ( args.length <= 0 ) {
              System.out.println( "Usage <subscriptionConfigFile> [<connectionsConfigFile>]"
);
              return;
          }
          if ( args.length > 0 ) {
              main.setSubscriptionsConfig( args[0] );
          }
          if ( args.length > 1 ) {
              main.setConnectionsConfig( args[1] );
          }
  
          try {
              main.run();
          }        
          catch (Exception e) {
              log.error( "Caught: " + e, e );
          }
      }
      
      public Main() {
      }
  
  
      /**
       * Starts all the JMS connections and consumes JMS messages, 
       * passing them onto the MessageListener and Message Driven Objects
       * */
      public void run() throws Exception {
  
          // force lazy construction
          getMessengerManager();
  
          // load the subscriptions....
          subscriptionList = createSubscriptionList();
          subscribe( subscriptionList );
          
          // now lets start all the connections...
          for (Iterator iter = manager.getMessengerNames(); iter.hasNext(); ) {
              String name = (String) iter.next();
              Messenger messenger = manager.getMessenger( name );
              try {
                  messenger.getConnection().start();
              }
              catch (JMSException e) {
                  log.error( "Caught exception trying to start messenger: " + name + ". Exception:
" + e, e );
              }
          }
      }
      
      public Messenger getMessenger(String name) throws JMSException {
          return getMessengerManager().getMessenger( name );
      }
      
      
      // Properties
      //-------------------------------------------------------------------------    
      
      public String getConnectionsConfig() {
          return connectionsConfig;
      }
      
      public void setConnectionsConfig(String connectionsConfig) {
          this.connectionsConfig = connectionsConfig;
      }
      
      public String getSubscriptionsConfig() {
          return subscriptionsConfig;
      }
      
      public void setSubscriptionsConfig(String subscriptionsConfig) {
          this.subscriptionsConfig = subscriptionsConfig;
      }
      
      public MessengerManager getMessengerManager() throws JMSException {
          if ( manager == null ) {
              manager = createMessengerManager();
              MessengerManager.setInstance( manager );
          }
          return manager;
      }
      
      public void setMessengerManager(MessengerManager manager) {
          this.manager = manager;
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------    
      protected void subscribe( SubscriptionList list ) throws JMSException, ServletException
{
          for (Iterator iter = list.getSubscriptions().iterator(); iter.hasNext(); ) {
              Subscription subscription = (Subscription) iter.next();
              subscribe( subscription );
          }
      }
      
      protected void subscribe( Subscription subscription ) throws JMSException, ServletException
{
          String name = subscription.getConnection();
          Messenger messenger = getMessenger( name );
          if ( messenger == null ) {
              throw new JMSException( "No such Messenger called: " + name + " for subscription:
" + subscription );
          }
          MessageListener listener = subscription.getMessageListener();
          if ( listener == null ) {
              throw new JMSException( "No MessageListener is defined for subscription: " +
subscription );
          }
          
          // if its an MDO the initialise it!
          if ( listener instanceof MessageDrivenObject ) {
              MessageDrivenObject mdo = (MessageDrivenObject) listener;
              if ( mdo instanceof MessengerMDO ) {
                  MessengerMDO messengerMDO = (MessengerMDO) mdo;
                  messengerMDO.setMessenger( messenger );
                  messengerMDO.setMessengerManager( getMessengerManager() );
              }
              mdo.init( getServletContext() );
          }
          
          String subject = subscription.getSubject();
          if ( subject == null || subject.length() == 0 ) {
              throw new JMSException( "No destination defined for subscription: " + subscription
);
          }
          
          Destination destination = messenger.getDestination( subject );
          if ( destination == null ) {
              throw new JMSException( "No destination could be found for name: " + subject
+ " for subscription: " + subscription );
          }
  
          // #### at this point we may wish to create a thread pool of multiple threads
          // #### each consuming from the same Destination in parallel
          
          String selector = subscription.getSelector();
          if ( selector != null && selector.length() > 0 ) {
              log.info( "Subscribing to messenger: " + name + " destination: " + subject +
" selector: " + selector );
              
              messenger.addListener( destination, selector, listener );
          }
          else {
              log.info( "Subscribing to messenger: " + name + " destination: " + subject );
              
              messenger.addListener( destination, listener );
          }
      }
      
      protected MessengerManager createMessengerManager() throws JMSException {
          String config = connectionsConfig;
          
          log.info( "Creating the JMS connections from the file: " + config );
          
          try {
              return MessengerManager.load( config );
          }
          catch (JMSException e) {
              log.error( "Could not parse Messenger connection XML deployment document for
URL: " + config, e );
              
              throw new JMSException(
                  "Could not parse Messenger connection XML deployment document for URL: "
+ config
                  + " reason: " + e
              );
          }
      }
      
      protected SubscriptionList createSubscriptionList() throws JMSException {
          String config = subscriptionsConfig;
          
          log.info( "Loading the JMS subscriptions from: " + config );
          
          try {
              SubscriptionDigester digester = new SubscriptionDigester();
              return (SubscriptionList) digester.parse( config );
          }
          catch (Exception e) {
              log.error( "Could not parse Messenger subscription XML deployment document for
URL: " + config, e );
              
              throw new JMSException(
                  "Could not parse Messenger subscription XML deployment document for URL:
" + config
                  + " reason: " + e
              );
          }
      }
      
      protected ServletContext getServletContext() {
          return null;
      }
  }
  
  
  
  1.26      +60 -40    jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerSupport.java
  
  Index: MessengerSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerSupport.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- MessengerSupport.java	27 Jun 2002 15:30:08 -0000	1.25
  +++ MessengerSupport.java	8 Jul 2002 14:37:36 -0000	1.26
  @@ -78,6 +78,9 @@
       /** A Map of ListenerKey objects to MessageConsumer objects */
       private Map listeners = new HashMap();
       
  +    /** whether MessageProducer instances should be cached or not */
  +    private boolean cacheProducers = true;
  +    
       public MessengerSupport() {
       }
       
  @@ -130,7 +133,7 @@
           Session session = borrowSession();
           MessageProducer producer = null;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               if (isTopic(producer)) {
                   ((TopicPublisher) producer).publish(message);
               }
  @@ -139,22 +142,23 @@
               }
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
       }
   
       public Message call( Destination destination, Message message ) throws JMSException
{
           Session session = borrowSession();
  +        MessageProducer producer = null;
           try {
               Destination replyTo = getReplyToDestination();
               
               message.setJMSReplyTo(replyTo);
   
  -            MessageProducer producer = getMessageProducer( session, destination );
  +            producer = borrowMessageProducer( session, destination );
               MessageConsumer consumer = getReplyToConsumer();
   
  -            if ( isTopic( session ) ) {
  +            if (isTopic(producer)) {
                   ((TopicPublisher) producer).publish( message );
               }
               else {
  @@ -163,6 +167,7 @@
               return consumer.receive();
           }
           finally {
  +            returnMessageProducer(producer);
               returnSession( session );
           }
       }
  @@ -177,10 +182,10 @@
           try {
               Destination replyTo = getReplyToDestination();
               message.setJMSReplyTo(replyTo);
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               
               MessageConsumer consumer = getReplyToConsumer();
  -            if (isTopic(session)) {
  +            if (isTopic(producer)) {
                   ((TopicPublisher) producer).publish(message);
               }
               else {
  @@ -189,7 +194,7 @@
               return consumer.receive(timeoutMillis);
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
       }
  @@ -539,11 +544,11 @@
           MessageProducer producer = null;
           int deliveryMode = 0;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               deliveryMode = producer.getDeliveryMode();
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
           return deliveryMode;
  @@ -555,11 +560,11 @@
           Session session = borrowSession();
           MessageProducer producer = null;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               producer.setDeliveryMode(deliveryMode);
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
       }
  @@ -570,11 +575,11 @@
           MessageProducer producer = null;
           int priority = 0;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               priority = producer.getPriority();
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
           return priority;
  @@ -586,11 +591,11 @@
           Session session = borrowSession();
           MessageProducer producer = null;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               producer.setPriority(priority);
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
       }
  @@ -601,11 +606,11 @@
           MessageProducer producer = null;
           long timeToLive = 0;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               timeToLive = producer.getTimeToLive();
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
           return timeToLive;
  @@ -619,11 +624,11 @@
           Session session = borrowSession();
           MessageProducer producer = null;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               producer.setTimeToLive(timeToLive);
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
       }
  @@ -635,11 +640,11 @@
           MessageProducer producer = null;
           boolean value = false;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               value = producer.getDisableMessageTimestamp();
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
           return value;
  @@ -651,11 +656,11 @@
           Session session = borrowSession();
           MessageProducer producer = null;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               producer.setDisableMessageTimestamp(value);
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
       }
  @@ -671,7 +676,7 @@
           Session session = borrowSession();
           MessageProducer producer = null;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               if (isTopic(producer)) {
                   ((TopicPublisher) producer).publish(
                       message,
  @@ -684,7 +689,7 @@
               }
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
       }
  @@ -696,11 +701,11 @@
           MessageProducer producer = null;
           boolean value = false;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               value = producer.getDisableMessageID();
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
           return value;
  @@ -712,11 +717,11 @@
           Session session = borrowSession();
           MessageProducer producer = null;
           try {
  -            producer = getMessageProducer(session, destination);
  +            producer = borrowMessageProducer(session, destination);
               producer.setDisableMessageID(value);
           }
           finally {
  -            producer.close();
  +            returnMessageProducer(producer);
               returnSession(session);
           }
       }
  @@ -791,6 +796,16 @@
           this.noLocal = noLocal;
       }
       
  +    /** Gets whether MessageProducer instances should be cached or not, which defaults
to true */
  +    public boolean isCacheProducers() {
  +        return cacheProducers;
  +    }
  +
  +    /** Sets whether MessageProducer instances should be cached or not, which defaults
to true */
  +    public void setCacheProducers(boolean cacheProducers) {
  +        this.cacheProducers = cacheProducers;
  +    }
  +
       
       // Implementation methods
       //-------------------------------------------------------------------------
  @@ -828,18 +843,23 @@
       
       
       /** @return a message producer for the given session and destination */
  -    protected MessageProducer getMessageProducer(
  +    protected MessageProducer borrowMessageProducer(
           Session session,
           Destination destination)
           throws JMSException {
  -        return createMessageProducer(session, destination);
  -        /**
  -                MessageProducer producer = (MessageProducer) producers.get( destination
);
  -                if ( producer == null ) {
  -                    producer = createMessageProducer( session, destination );
  -                }
  -                return producer;
  -        */
  +            
  +        if ( isCacheProducers() ) {
  +            return getMessengerSession().getMessageProducer(destination);            
  +        }
  +        else {            
  +            return createMessageProducer(session, destination);
  +        }
  +    }
  +    
  +    protected void returnMessageProducer(MessageProducer producer) throws JMSException
{
  +        if ( ! isCacheProducers() ) {
  +            producer.close();
  +        }
       }
       
       /** @return a newly created message producer for the given session and destination
*/
  
  
  
  1.3       +22 -1     jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerSession.java
  
  Index: MessengerSession.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerSession.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MessengerSession.java	27 Jun 2002 15:30:08 -0000	1.2
  +++ MessengerSession.java	8 Jul 2002 14:37:36 -0000	1.3
  @@ -52,6 +52,9 @@
       /** An optional cache of requestors */
       private Map requestorsMap;    
   
  +    /** the cache of producers */
  +    private Map producers;
  +    
       /** The inbox which is used for the call() methods */
       private Destination replyToDestination;
   
  @@ -99,6 +102,24 @@
           this.replyToConsumer = replyToConsumer;
       }
           
  +    /**
  +     * @return the MessageProducer for the given destination.
  +     */
  +    public MessageProducer getMessageProducer(Destination destination) throws JMSException
{
  +        MessageProducer producer = null;
  +        if ( producers == null ) {
  +            producers = new HashMap();
  +        }
  +        else {
  +            producer = (MessageProducer) producers.get( destination );
  +        }
  +        if ( producer == null ) {
  +            producer = messenger.createMessageProducer( session, destination );
  +            producers.put( destination, producer );
  +        }
  +        return producer;
  +    }
  +    
       /** 
        * @return the reply to destination (a temporary queue) 
        * used to reply to this thread and session
  @@ -171,7 +192,7 @@
   		}
   	}
       
  -    
  +
       /** 
        * @return the map of requestors, indexed by destination.
        *  The Map will be lazily constructed
  
  
  
  1.10      +7 -7      jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerManager.java
  
  Index: MessengerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerManager.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MessengerManager.java	17 May 2002 15:05:45 -0000	1.9
  +++ MessengerManager.java	8 Jul 2002 14:37:36 -0000	1.10
  @@ -99,6 +99,11 @@
           return singleton;
       }
   
  +    /** Installs a new singleton MessengerManager instance */
  +    public static void setInstance(MessengerManager messengerManager) {
  +        singleton = messengerManager;
  +    }
  +
       public void close() {
           synchronized (messengers) {
               for ( Iterator iter = messengers.entrySet().iterator(); iter.hasNext(); ) {
  @@ -123,11 +128,6 @@
       
       // Implementation methods
       //-------------------------------------------------------------------------    
  -
  -    /** Installs a new singleton MessengerManager instance */
  -    protected static void setInstance(MessengerManager messengerManager) {
  -        singleton = messengerManager;
  -    }
       
       /** Factory method to create the singleton MessengerManager instance */
       protected static MessengerManager createInstance() throws JMSException {
  
  
  
  1.5       +10 -2     jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/impl/SubscriptionDigester.java
  
  Index: SubscriptionDigester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/impl/SubscriptionDigester.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SubscriptionDigester.java	15 May 2002 14:36:34 -0000	1.4
  +++ SubscriptionDigester.java	8 Jul 2002 14:37:36 -0000	1.5
  @@ -24,6 +24,7 @@
       private String subscriptionClass = "org.apache.commons.messagelet.impl.Subscription";
       private String listenerClass = "org.apache.commons.messagelet.impl.MessageServletDispatcher";
       private String bridgeClass = "org.apache.commons.messagelet.BridgeMDO";
  +    private String distributeBridgeClass = "org.apache.commons.messagelet.DistributeBridgeMDO";
   
       
       public SubscriptionDigester() {
  @@ -71,6 +72,13 @@
              "javax.jms.MessageListener"
           );
           
  +        path = "subscriptions/subscription/distributeBridge";
  +        addObjectCreate( path, distributeBridgeClass, "className" );
  +        addSetProperties( path );
  +        addSetNext( path, "setMessageListener",
  +           "javax.jms.MessageListener"
  +        );
           
  +        addCallMethod("subscriptions/subscription/distributeBridge/subject", "addOutputSubject",
0);        
       }
   }
  
  
  
  1.6       +32 -8     jakarta-commons-sandbox/messenger/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/project.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- project.xml	17 Jun 2002 17:40:45 -0000	1.5
  +++ project.xml	8 Jul 2002 14:37:36 -0000	1.6
  @@ -99,6 +99,19 @@
         <jar>jms-1.0.2b.jar</jar>
       </dependency>
   
  +    <dependency>
  +      <name>xmlParseAPIs</name>
  +      <type>required</type>
  +      <version>2.0.0</version>
  +      <jar>xmlParserAPIs-2.0.0.jar</jar>
  +    </dependency>
  +
  +    <dependency>
  +      <name>ant</name>
  +      <version>1.4.1</version>
  +      <jar>ant-1.4.1.jar</jar>
  +    </dependency>
  +
   <!-- runtime dependencies only required for testing and sample programs -->
   
   <!--
  @@ -109,14 +122,14 @@
         <jar>xercesImpl-2.0.0.jar</jar>
       </dependency>
   
  -    <dependency>
  -      <name>xmlParseAPIs</name>
  -      <type>required</type>
  -      <version>2.0.0</version>
  -      <jar>xmlParserAPIs-2.0.0.jar</jar>
  -    </dependency>
   -->
   
  +    <!-- for unit testing -->
  +    <dependency>
  +      <id>junit</id>
  +      <version>3.7</version>
  +    </dependency>
  +    
     </dependencies>
     
     <build>
  @@ -128,17 +141,28 @@
       <!-- Unit test classes -->
   
   	
  -    <unitTestPatterns>
   <!--
  -	TEMP HACK!
  +	TEMP HACK! - disabled unit tests until they work in Maven...
   -->    
  +    <unitTestPatterns>
         <unitTestPattern>include = **/DISABLED_Test*.java</unitTestPattern>
       </unitTestPatterns>
  +    <unitTest>
  +      <includes>
  +        <include>**/DISABLED_Test*.java</include>
  +      </includes>
  +    </unitTest>
  +    
       <!-- Integration unit test classes -->
       <integrationUnitTestPatterns></integrationUnitTestPatterns>
       
       <!-- J A R  R E S O U R C E S -->
       <!-- Resources that are packaged up inside the JAR file -->
  +    <resources>
  +      <includes>
  +        <include>**/*.properties</include>
  +      </includes>
  +    </resources>
   
       <jarResources>
         <jarResource>include = **/*.properties</jarResource>
  
  
  
  1.1                  jakarta-commons-sandbox/messenger/project-ng.xml
  
  Index: project-ng.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <project>
    <pomVersion>3</pomVersion>
    <name>commons-messenger</name>
    <id>commons-messenger</id>
    <currentVersion>1.0-dev</currentVersion>
    <organization>
  	  <name>Apache Software Foundation</name>
  	  <url>http://www.apache.org</url>
    </organization>
    <inceptionYear>2002</inceptionYear>
    <package>org.apache.commons</package>
    <shortDescription>Commons Messenger</shortDescription>
    <gumpRepositoryId>jakarta</gumpRepositoryId>
    
    <description>
    	Commons Messenger is a JMS framework for working with JMS in web applications and web
services
    </description>
    
    <url>http://jakarta.apache.org/commons/sandbox/messenger/</url>
    <cvsWebUrl>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/messenger/</cvsWebUrl>
    <cvsModule>jakarta-commons-sandbox/messenger</cvsModule>
    <issueTrackingUrl>http://nagoya.apache.org/</issueTrackingUrl>
    <siteAddress>jakarta.apache.org</siteAddress>
    <siteDirectory>/www/jakarta.apache.org/commons/sandbox/messenger/</siteDirectory>
    <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/messenger/</distributionDirectory>
    <repository>
      <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/messenger</connection>
      <url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/messenger/</url>
    </repository>
    
    <mailingLists>
      <mailingList>
        <name>Commons Dev List</name>
        <subscribe>commons-dev-subscribe@jakarta.apache.org</subscribe>
        <unsubscribe>commons-dev-unsubscribe@jakarta.apache.org</unsubscribe>
        <archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=commons-dev@jakarta.apache.org</archive>
      </mailingList>
    </mailingLists>
  
    
    <developers>
      <developer>
        <name>James Strachan</name>
        <id>jstrachan</id>
        <email>jstrachan@apache.org</email>
        <organization>SpiritSoft, Inc.</organization>
      </developer>
      <developer>
        <name>Saimon Moore</name>
        <id>saimon</id>
        <email>saimonmoore@yahoo.co.uk</email>
        <organization></organization>
      </developer>
    </developers>
    
    <dependencies>
      
      <dependency>
        <name>commons-logging</name>
        <type>required</type>
        <version>1.0</version>
        <jar>commons-logging-1.0.jar</jar>
      </dependency>
  
      <dependency>
        <name>commons-beanutils</name>
        <type>required</type>
        <version>1.3</version>
        <jar>commons-beanutils-1.3.jar</jar>
      </dependency>
  
      <dependency>
        <name>commons-collections</name>
        <type>required</type>
        <version>2.0</version>
        <jar>commons-collections-2.0.jar</jar>
      </dependency>
  
      <dependency>
        <name>commons-digester</name>
        <type>required</type>
        <version>1.2</version>
        <jar>commons-digester-1.2.jar</jar>
      </dependency>
  
      <dependency>
        <name>servletapi</name>
        <type>required</type>
        <version>2.3</version>
        <jar>servletapi-2.3.jar</jar>
      </dependency>
  
      <dependency>
        <name>jms</name>
        <type>required</type>
        <version>1.0.2b</version>
        <jar>jms-1.0.2b.jar</jar>
      </dependency>
  
  <!-- runtime dependencies only required for testing and sample programs -->
  
  <!--
      <dependency>
        <name>xercesImpl</name>
        <type>required</type>
        <version>2.0.0</version>
        <jar>xercesImpl-2.0.0.jar</jar>
      </dependency>
  
      <dependency>
        <name>xmlParseAPIs</name>
        <type>required</type>
        <version>2.0.0</version>
        <jar>xmlParserAPIs-2.0.0.jar</jar>
      </dependency>
  -->
  
    </dependencies>
    
    <build>
      <nagEmailAddress>commons-dev@jakarta.apache.org</nagEmailAddress>
      <sourceDirectory>src/java</sourceDirectory>
      <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
      <integrationUnitTestSourceDirectory/>
      <aspectSourceDirectory/>
      <!-- Unit test classes -->
  
  	
      <unitTestPatterns>
  <!--
  	TEMP HACK!
  -->    
        <unitTestPattern>include = **/DISABLED_Test*.java</unitTestPattern>
      </unitTestPatterns>
      <!-- Integration unit test classes -->
      <integrationUnitTestPatterns></integrationUnitTestPatterns>
      
      <!-- J A R  R E S O U R C E S -->
      <!-- Resources that are packaged up inside the JAR file -->
  
      <jarResources>
        <jarResource>include = **/*.properties</jarResource>
      </jarResources>
    </build>
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/messenger/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="java:jar" xmlns:j="jelly:core">
  
    <!-- runs a sample number of subscriptions -->	
    <goal name="subscribe" prereqs="java:compile">
    
    	<echo>
  		Using JMS from lib dir ${jms.lib.dir} and config dir ${jms.classes.dir}
      </echo>
      
      <path id="jms.classpath">
        <pathelement path="target/classes"/>
        <pathelement path="${maven.build.dest}"/>
  	  <path refid="maven.dependency.classpath"/>
  	  
        <!-- add the JARs required for a pluggable JMS provider -->
        <pathelement path="${jms.classes.dir}"/>
        <fileset dir="${jms.lib.dir}">
          <include name="**/*.jar"/>
        </fileset>
  	</path>
  	
      <java classname="org.apache.commons.messagelet.Main" fork="yes">
        <classpath refid="jms.classpath"/>
  
        <arg value="src/conf/subscribe.xml"/>
        <arg value="${messenger.xml}"/>
      </java>
    </goal>
  	
  </project>
  
  
  
  1.6       +26 -12    jakarta-commons-sandbox/messenger/src/conf/subscribe.xml
  
  Index: subscribe.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/conf/subscribe.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- subscribe.xml	17 May 2002 15:05:46 -0000	1.5
  +++ subscribe.xml	8 Jul 2002 14:37:36 -0000	1.6
  @@ -1,28 +1,42 @@
   <?xml version="1.0" encoding="UTF-8"?>
   <subscriptions>
  -  <!-- An example of how subscriptions can look... -->
  -  <subscription connection="queue" subject="my.queue" selector="b='12'">
   
  -    <!-- the output will reply to the original message -->
  -    <servlet url="/jms/bar.jsp"/>
  +  <!-- bridge to another JMS provider -->
  +  <subscription connection="queue" subject="my.input" selector="b='12'">
  +    <bridge outputConnection="queue" outputSubject="my.output"/>
     </subscription>
   
  -  <subscription connection="queue" subject="my.queue" selector="b='12'">
  -    <!-- send a reply on some other Messenger and destination -->
  -    <servlet url="/jms/foo.jsp" replyDestination="my.topic" replyMessenger="topic"/>
  -
  +  <!-- distribute messages to multiple output queues -->
  +  <subscription connection="queue" subject="my.input">
  +    <distributeBridge outputConnection="queue">
  +	  <subject>output.A</subject>		    	
  +	  <subject>output.B</subject>		    	
  +	  <subject>output.C</subject>		    	
  +	  <subject>output.D</subject>		    	
  +    </distributeBridge>
     </subscription>
   
  -  <subscription connection="inputQueue" subject="my.input" selector="b='12'">
   
  -    <!-- bridge to another JMS provider -->
   
  -    <bridge outputConnection="my.output" outputSubject="outputQueue"/>
  -    
  +
  +  <!-- An example of how subscriptions can look... -->
  +  <!-- the output of the servlet will reply to the original message -->
  +<!--  
  +  <subscription connection="queue" subject="my.queue" selector="b='12'">
  +    <servlet url="/jms/bar.jsp"/>
     </subscription>
  +-->
   
  +  <!-- send a reply on some other Messenger and destination -->
  +<!--  
  +  <subscription connection="queue" subject="my.queue" selector="b='12'">
  +    <servlet url="/jms/foo.jsp" replyDestination="my.topic" replyMessenger="topic"/>
  +  </subscription>
  +-->
   
  +<!--
     <subscription connection="topic" subject="my.queue" selector="b='12'">
       <listener className="com.acme.MyMessageListener"/>
     </subscription>
  +-->  
   </subscriptions>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message