From dev-return-31775-apmail-activemq-dev-archive=activemq.apache.org@activemq.apache.org Tue Jun 12 19:51:37 2012 Return-Path: X-Original-To: apmail-activemq-dev-archive@www.apache.org Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CBB4B9186 for ; Tue, 12 Jun 2012 19:51:37 +0000 (UTC) Received: (qmail 84582 invoked by uid 500); 12 Jun 2012 19:51:37 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 84552 invoked by uid 500); 12 Jun 2012 19:51:37 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 84544 invoked by uid 99); 12 Jun 2012 19:51:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jun 2012 19:51:37 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gary.tully@gmail.com designates 209.85.216.171 as permitted sender) Received: from [209.85.216.171] (HELO mail-qc0-f171.google.com) (209.85.216.171) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jun 2012 19:51:31 +0000 Received: by qcsp15 with SMTP id p15so1833296qcs.2 for ; Tue, 12 Jun 2012 12:51:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=DyIWpdKt7O+qhMzfL3fQRz6u6bwQET25GFh+WjPCNBo=; b=M4oYaAYJlJXAWIztS2zNXCnpfE5VPZoKJMFPnJao2qbWs/pOdUtUdZMqTfAfLFHlp7 hkVAruj7ssniOBNFfkbIJOa0qB6Jx17VubKg9sXmKs5ZqUmCwvcWTb8WAf+Y732kgIh7 s3sZXv8Rxd60qSsbfdQvnKMgmcUeTkvfCAD3yu+cCyWYzOmyc9sP/TDl1up1xMd447qa Z8/0zP1zMcDZA/0M+PXK+4dz3za/XjsjRjwKIDiWzVNTVU/T6rqQNJxAMP9JahtEtZOf 0z3vI06TXh4EPDN9MUl/0SuMo2HsuPsv8ChVEIkUX6M8ESu26rosXGPiIc1kYCMS/f1o gFCw== MIME-Version: 1.0 Received: by 10.224.39.75 with SMTP id f11mr22147088qae.70.1339530670097; Tue, 12 Jun 2012 12:51:10 -0700 (PDT) Received: by 10.229.237.196 with HTTP; Tue, 12 Jun 2012 12:51:09 -0700 (PDT) In-Reply-To: <1339522268761-4653208.post@n4.nabble.com> References: <1339522268761-4653208.post@n4.nabble.com> Date: Tue, 12 Jun 2012 20:51:09 +0100 Message-ID: Subject: Re: Questions re: VirtualTopics From: Gary Tully To: dev@activemq.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable The unit tests are always a great starting point for working code: have a peek at http://svn.apache.org/viewvc/activemq/trunk/activemq-core/sr= c/test/java/org/apache/activemq/broker/virtual/VirtualTopicPubSubTest.java?= view=3Dmarkup I think below you need to sent to a topic called: VirtualTopic.orders On 12 June 2012 18:31, rwolson wrote: > Good afternoon, > > I=92m attempting to use ActiveMQ 5.6.0 VirtualTopics for the first time. > Also, =A0I=92m somewhat a newbie to ActiveMQ and JMS. > > I created a class based upon an shown in ActiveMQ in Action, =A0page 285. > The code follows for reference: > public void sendAndConsumeVirtualTopic() throws JMSException { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0String brokerURI =3D ActiveMQConnectionFac= tory.DEFAULT_BROKER_URL; > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ConnectionFactory connectionFactory =3D ne= w > ActiveMQConnectionFactory(brokerURI); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Connection consumerConnection =3D connecti= onFactory.createConnection(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0consumerConnection.start(); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Session consumerSessionA =3D > consumerConnection.createSession(false,Session.AUTO_ACKNOWLEDGE); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Queue consumerAQueue =3D > consumerSessionA.createQueue("Consumer.A.VirtualTopic.orders"); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0MessageConsumer consumerA =3D > consumerSessionA.createConsumer(consumerAQueue); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0MessageListener listener =3D null; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0consumerA.setMessageListener(listener); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//setup the sender > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Connection senderConnection =3D connection= Factory.createConnection(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0senderConnection.start(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Session senerSession =3D senderConnection.= createSession(false, > Session.AUTO_ACKNOWLEDGE); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Topic ordersDestination =3D > senerSession.createTopic(ExamplePublishAndSubscribe.TOPIC1); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0MessageProducer producer =3D senerSession.= createProducer(ordersDestination); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0String[] arry =3D {"Alpha", "Bravo", "Char= lie", "Delta", "Echo", "Foxtrot", > "Golf", "Hotel", "India", "Juliett", "Kilo", "Lima", "Mike", "November", > "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor= ", > "Whiskey", "Xray", "Yankee", "Zulu"}; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0int index =3D 0; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0while(index < arry.length) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TextMessage message =3D se= nerSession.createTextMessage("Here is a message > [" + msgCount + "] " + arry[msgCount].toString() + " at: " + new Date()); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0producer.send(message); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0index++; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0consumerConnection.close(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0bStopped =3D true; > =A0 =A0 =A0 =A0} =A0 =A0 =A0 // end method > > I=92m successfully sending messages to Topics and the method creates a qu= eue. > However, =A0I don=92t see any messages in the queue. =A0Also, =A0the code= example > references a getMessageListener(), =A0but since it=92s not included withi= n the > book=92s source code, =A0I suspect maybe I=92m incorrectly initializing t= he > MessageListener. =A0So, =A0how do I setup the MessageListener? > > I included the following entries within the activemq.xml and know they=92= re > read because I initially generated an error. > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0prefix=3D"VirtualTopic.*." /> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > =A0 =A0 =A0 =A0 =A0 =A0 > > Do I need to define the queue within the destinationInterceptors? > > So, =A0the questions just in case they=92re hard to find: > - =A0 =A0 =A0 *how do I setup the MessageListener?* > - =A0 =A0 =A0 *Do I need to define the queue within the destinationInterc= eptors?* > > Thanks, > Rich > > > -- > View this message in context: http://activemq.2283324.n4.nabble.com/Quest= ions-re-VirtualTopics-tp4653208.html > Sent from the ActiveMQ - Dev mailing list archive at Nabble.com. --=20 http://fusesource.com http://blog.garytully.com