Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 48626 invoked from network); 18 Jun 2007 02:03:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jun 2007 02:03:25 -0000 Received: (qmail 84142 invoked by uid 500); 18 Jun 2007 02:03:27 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 84112 invoked by uid 500); 18 Jun 2007 02:03:27 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 84103 invoked by uid 99); 18 Jun 2007 02:03:27 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Jun 2007 19:03:27 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [204.127.192.83] (HELO rwcrmhc13.comcast.net) (204.127.192.83) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Jun 2007 19:03:22 -0700 Received: from rmailcenter99.comcast.net ([204.127.197.199]) by comcast.net (rwcrmhc13) with SMTP id <20070618020301m1300acq8se>; Mon, 18 Jun 2007 02:03:01 +0000 Received: from [67.180.78.177] by rmailcenter99.comcast.net; Mon, 18 Jun 2007 02:03:01 +0000 From: uma_rk@comcast.net To: users@activemq.apache.org Subject: Sharing embedded broker across webapp contexts Date: Mon, 18 Jun 2007 02:03:01 +0000 Message-Id: <061820070203.3429.4675E7D50002B2F700000D652213528573059DA10E039A@comcast.net> X-Mailer: AT&T Message Center Version 1 (Oct 4 2006) X-Authenticated-Sender: dW1hX3JrQGNvbWNhc3QubmV0 X-Virus-Checked: Checked by ClamAV on apache.org I am using activemq 4.1.1 on JDK6 with Tomcat 5.5.x. I have a couple of webapp contexts in a servlet container that use activemq broker. I have been using an external broker but would like to embed the broker in the servlet container. I have the following questions. 1) Assume I have webapps A and B. Is it necessary that only one of the two webapps assume the responsibility of starting the broker? I mean, I would like to embed the starting of the broker in a jarfile that is shared by both the webapps. Its hence easy for me to keep the jarfile agnostic to which webapp its operating in and execute the broker start code at context startup. Stated simply, would this sequence cause two different brokers to attempt to start? Should I build mechanisms to make sure the broker.start() is executed only once? Webapp A: context load { // Time t Broker broker = new broker("tcp://localhost:61616"); //pseudocode broker.start(); } Webapp B: context load { // Time t + 5 Broker broker = new broker("tcp://localhost:61616"); //pseudocode broker.start(); } 2) Assume webapp A starts the broker. Also, let's say Class X is defined in a jarfile common to both the webapps. Would this cause class cast exception if webapp B received an instance of class X from the broker? (since I assume the broker would use the webapp A classloader to load class X)? If so how do I avoid this class loading issue? Do I need to place the activemq jarfiles as well as the application jarfiles which contains classes of the messages dispatched over activemq to be in a shared system classpath common to both the webapp contexts? 3) In a setup such as this where multiple webapps share the same embedded broker, is it mandatory that they use an external broker? What are the other gotchas in using the embedded broker in this fashion? Regards /U