Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 83251 invoked from network); 7 Oct 2002 10:38:32 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 7 Oct 2002 10:38:32 -0000 Received: (qmail 18381 invoked by uid 97); 7 Oct 2002 10:39:11 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 18365 invoked by uid 97); 7 Oct 2002 10:39:10 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 18354 invoked by uid 97); 7 Oct 2002 10:39:09 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 7 Oct 2002 10:38:23 -0000 Message-ID: <20021007103823.97679.qmail@icarus.apache.org> From: jstrachan@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet Main.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N jstrachan 2002/10/07 03:38:23 Modified: messenger/src/conf subscribe.xml MessengerSpiritWave.xml messenger maven.xml messenger/src/java/org/apache/commons/messagelet Main.java Added: messenger/src/test/org/apache/commons/messenger LoggingMDO.java Log: Added a simple example to the maven build for consuming JMS messages using the simple command line Messagelet engine and a simple LoggingMDO. Revision Changes Path 1.9 +11 -5 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.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- subscribe.xml 9 Jul 2002 11:53:35 -0000 1.8 +++ subscribe.xml 7 Oct 2002 10:38:23 -0000 1.9 @@ -1,6 +1,11 @@ + + + + + @@ -9,12 +14,12 @@ - output.A - output.B - output.C - output.D + output.A + output.B + output.C + output.D - + @@ -30,6 +35,7 @@ + 1.5 +2 -2 jakarta-commons-sandbox/messenger/src/conf/MessengerSpiritWave.xml Index: MessengerSpiritWave.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/conf/MessengerSpiritWave.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MessengerSpiritWave.xml 8 Jul 2002 16:19:05 -0000 1.4 +++ MessengerSpiritWave.xml 7 Oct 2002 10:38:23 -0000 1.5 @@ -2,11 +2,11 @@ - + - + 1.3 +9 -4 jakarta-commons-sandbox/messenger/maven.xml Index: maven.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/messenger/maven.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- maven.xml 8 Jul 2002 15:15:24 -0000 1.2 +++ maven.xml 7 Oct 2002 10:38:23 -0000 1.3 @@ -1,15 +1,19 @@ - + Using JMS from lib dir ${jms.lib.dir} and config dir ${jms.classes.dir} + Connecting via ${messenger.xml} + + - + @@ -21,7 +25,8 @@ - + @@ -37,7 +42,7 @@ - + 1.1 jakarta-commons-sandbox/messenger/src/test/org/apache/commons/messenger/LoggingMDO.java Index: LoggingMDO.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: LoggingMDO.java,v 1.4 2002/05/17 15:05:46 jstrachan Exp $ */ package org.apache.commons.messenger; import javax.jms.Message; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.messagelet.MessengerMDO; import org.apache.commons.messenger.Messenger; /** *

LoggingMDO is a simple MDO which * logs the fact that it consumed a message.

* * @author James Strachan * @version $Revision: 1.4 $ */ public class LoggingMDO extends MessengerMDO { /** Logger to which logging messages will go */ private static final Log log = LogFactory.getLog(LoggingMDO.class); public void onMessage(Message message) { log.info( "Received message: " + message ); System.out.println( "Received message: " + message ); } } 1.5 +24 -3 jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/Main.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Main.java 14 Aug 2002 14:36:12 -0000 1.4 +++ Main.java 7 Oct 2002 10:38:23 -0000 1.5 @@ -57,7 +57,7 @@ private String subscriptionsConfig = "subscriptions.xml"; /** Should we use a stopwatch to output performance metrics */ - private boolean useStopWatch = true; + private boolean useStopWatch = false; public static void main(String[] args) { @@ -88,12 +88,12 @@ /** * 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 ); @@ -109,7 +109,10 @@ log.error( "Caught exception trying to start messenger: " + name + ". Exception: " + e, e ); } } + + //waitForever(); } + public Messenger getMessenger(String name) throws JMSException { return getMessengerManager().getMessenger( name ); @@ -204,6 +207,8 @@ messenger.addListener( destination, listener ); } + + log.info( "Subscribed with listener: " + listener ); } protected MessengerManager createMessengerManager() throws JMSException { @@ -257,4 +262,20 @@ return listener; } + /** + * This method blocks the current thread indefinitely until the JVM is terminated. + */ + protected void waitForever() { + Object lock = new Object(); + synchronized (lock) { + while (true) { + try { + lock.wait(); + } + catch (Exception e) { + log.warn( "Main thread interupted: " + e, e ); + } + } + } + } } -- To unsubscribe, e-mail: For additional commands, e-mail: