Return-Path: Delivered-To: apmail-geronimo-activemq-dev-archive@www.apache.org Received: (qmail 20930 invoked from network); 21 Jul 2006 20:40:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Jul 2006 20:40:33 -0000 Received: (qmail 91912 invoked by uid 500); 21 Jul 2006 20:40:30 -0000 Delivered-To: apmail-geronimo-activemq-dev-archive@geronimo.apache.org Received: (qmail 91863 invoked by uid 500); 21 Jul 2006 20:40:29 -0000 Mailing-List: contact activemq-dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-dev@geronimo.apache.org Received: (qmail 91829 invoked by uid 99); 21 Jul 2006 20:40:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jul 2006 13:40:29 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of lists@nabble.com designates 72.21.53.35 as permitted sender) Received: from [72.21.53.35] (HELO talk.nabble.com) (72.21.53.35) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jul 2006 13:40:27 -0700 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1G41n4-0001vo-NF for activemq-dev@geronimo.apache.org; Fri, 21 Jul 2006 13:40:06 -0700 Message-ID: <5439965.post@talk.nabble.com> Date: Fri, 21 Jul 2006 13:40:06 -0700 (PDT) From: bmadigan To: activemq-dev@geronimo.apache.org Subject: Re: Virtual Topics (was Re: Failover topic subscribers) In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-Sender: bmadigan@orbitz.com X-Nabble-From: bmadigan References: <5332644.post@talk.nabble.com> <5404863.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thanks James, that test case works for me too. I wrote a use case that (I think) covers the base Virtual Topic functionality. There is a problem somewhere that causes this test to fail. Running it in debug I can see that the Message is dispatched, but not delivered for some reason. Most of the internals for virtual topics seem to be working fine though, so thats good news. If you run the test case below, you can see that the MessageListeners on the queue don't get any messages. There is some additional code to add the VirtualTopicBroker to the interceptor chain in BrokerService (or it can be added as a plugin). Test case: package org.apache.activemq.usecases; import org.apache.log4j.Logger; import org.apache.activemq.EmbeddedBrokerTestSupport; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; import javax.jms.Session; import javax.jms.Connection; import javax.jms.MessageProducer; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Message; public class VirtualTopicPubSubTest extends EmbeddedBrokerTestSupport { private Connection connection; public void testVirtualTopicCreation( )throws Exception{ if(connection == null){ connection = createConnection(); } String queueAName = "ActiveMQ.Virtual.A.TEST"; //create consumer 'cluster' ActiveMQQueue queue1 = new ActiveMQQueue(queueAName); ActiveMQQueue queue2 = new ActiveMQQueue(queueAName); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer c1 = session.createConsumer(queue1); MessageConsumer c2 = session.createConsumer(queue2); MessageCountListener exclusive1 = new MessageCountListener(); c1.setMessageListener(exclusive1); MessageCountListener exclusive2 = new MessageCountListener(); c2.setMessageListener(exclusive2); //create topic producer MessageProducer producer = session.createProducer(new ActiveMQTopic("TEST")); assertNotNull(producer); int total = 10; for(int i = 0; i < total; i++){ producer.send(session.createTextMessage("xxxxxxxxxxxxxxxxxx")); } int delivered = exclusive1.getCount( ) & exclusive2.getCount(); assertTrue("Expected "+total+" delivered, found "+delivered, delivered == total); } class MessageCountListener implements MessageListener{ private int count = 0; public void onMessage(Message m){ System.out.println("Got one! "+count); count++; } public int getCount(){ return count; } } protected void tearDown() throws Exception { if (connection != null) { connection.close(); } super.tearDown(); } the Broker: package org.apache.activemq.broker; import org.apache.activemq.broker.region.Destination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.Message; import java.util.Iterator; import java.util.Set; public class VirtualTopicBroker extends BrokerFilter implements BrokerPlugin { public static final String VIRTUAL_WILDCARD = "ActiveMQ.Virtual.*"; public VirtualTopicBroker(Broker next) { super(next); } public VirtualTopicBroker() { super(null); } public void send(ConnectionContext ctx, Message message) throws Exception { String name = message.getDestination().getPhysicalName(); String virtualName = VIRTUAL_WILDCARD+ name; Set destinations = getDestinations( new ActiveMQQueue(virtualName)); for (Iterator iter = destinations.iterator(); iter.hasNext();) { Destination dest = (Destination) iter.next(); dest.send(ctx, message); } next.send(ctx, message); } public Broker installPlugin(Broker broker) throws Exception { return new VirtualTopicBroker(broker); } } -- View this message in context: http://www.nabble.com/Re%3A-Virtual-Topics-%28was-Re%3A-Failover-topic-subscribers%29-tf1942508.html#a5439965 Sent from the ActiveMQ - Dev forum at Nabble.com.