From users-return-23585-apmail-activemq-users-archive=activemq.apache.org@activemq.apache.org Mon May 10 12:24:19 2010 Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 15606 invoked from network); 10 May 2010 12:24:19 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 May 2010 12:24:19 -0000 Received: (qmail 33129 invoked by uid 500); 10 May 2010 12:24:19 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 33030 invoked by uid 500); 10 May 2010 12:24:19 -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 32998 invoked by uid 99); 10 May 2010 12:24:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 May 2010 12:24:19 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of geoffrey.arnold@gmail.com designates 209.85.221.171 as permitted sender) Received: from [209.85.221.171] (HELO mail-qy0-f171.google.com) (209.85.221.171) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 May 2010 12:24:12 +0000 Received: by qyk1 with SMTP id 1so5935153qyk.5 for ; Mon, 10 May 2010 05:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:content-type :mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=Au8TSXyS5xfYcGdRj5iMsv2SWUmsFcPYcwOx2Kd9+h0=; b=d+XR+aWIyDU6u1zEobaCKzX4xQ0z9Q43GqpsoHkFs4v/RMQ2WR7h3VdTEuQl66QLnk jjWauSkEPDn54uFweU7fbU0vv4dqPCc5yJuBDXUbpIAtq8vIQKdyut3d+YxaeQKabw62 fZ2DdvFLxK1jwVJaNb8VW9wdEtaqTrnBKkv6M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=r2rZ/qm+EMY57isUAnOCiAGy9caEHegYQkQuDYDumr1zueOZqj19yjcx1VL4CCrQcX 7d9TP6qXFTSzekRMm5aZKiqwr70IfJscIoX7O5ZpsHX+5NtIfgubK5fsxIgGFzjFw+fq p7X2cnQExjKHqrHlB66Ci30IqebLCybbwGeao= Received: by 10.224.58.78 with SMTP id f14mr2502256qah.385.1273494231014; Mon, 10 May 2010 05:23:51 -0700 (PDT) Received: from [10.0.1.2] ([24.215.241.108]) by mx.google.com with ESMTPS id 20sm3219673qyk.12.2010.05.10.05.23.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 10 May 2010 05:23:49 -0700 (PDT) Sender: Geoffrey Arnold Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1078) Subject: Re: Programmatically stopping and restarting network connector From: Geoffrey Arnold In-Reply-To: Date: Mon, 10 May 2010 08:23:49 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <36F8230F-9B8D-420A-8938-BA9535D7745E@geoffreyarnold.com> References: <85F5B958-AFA7-44EC-9267-9827492826F7@geoffreyarnold.com> <3D746C4B-7348-4367-893F-F965A2D23F54@geoffreyarnold.com> To: users@activemq.apache.org X-Mailer: Apple Mail (2.1078) X-Virus-Checked: Checked by ClamAV on apache.org No problem, thanks Dejan! On May 10, 2010, at 8:17 AM, Dejan Bosanac wrote: > Hi Geoff, >=20 > I meant everything OK in the Jira. I still didn't managed to look at = the > test. Sorry for confusion. >=20 > Cheers > -- > Dejan Bosanac - http://twitter.com/dejanb >=20 > Open Source Integration - http://fusesource.com/ > ActiveMQ in Action - http://www.manning.com/snyder/ > Blog - http://www.nighttale.net >=20 >=20 > On Mon, May 10, 2010 at 2:07 PM, Geoffrey Arnold < > geoffrey@geoffreyarnold.com> wrote: >=20 >> Hi Dejan, >>=20 >> If you run the test, the second assertion (right before the finally = block) >> fails. Could you clarify what you mean by "everything is ok"? >>=20 >> Thanks, >> Geoff. >>=20 >> On May 10, 2010, at 3:08 AM, Dejan Bosanac wrote: >>=20 >>> Hi, >>>=20 >>> I see your test case attached to the issues. Seems like everything = is OK. >>>=20 >>> Cheers >>> -- >>> Dejan Bosanac - http://twitter.com/dejanb >>>=20 >>> Open Source Integration - http://fusesource.com/ >>> ActiveMQ in Action - http://www.manning.com/snyder/ >>> Blog - http://www.nighttale.net >>>=20 >>>=20 >>> On Sat, May 8, 2010 at 4:05 PM, Geoffrey Arnold < >> geoffrey@geoffreyarnold.com >>>> wrote: >>>=20 >>>> Looks like the attachment didn't come through... inlining test case >> here. >>>> Any thoughts? >>>>=20 >>>>=20 >>>>=20 >> = //////////////////////////////////////////////////////////////////////////= ///////// >>>> package org.activemq; >>>>=20 >>>> import org.apache.activemq.ActiveMQConnectionFactory; >>>> import org.apache.activemq.broker.BrokerService; >>>> import org.apache.activemq.network.NetworkConnector; >>>> import org.junit.Test; >>>> import org.springframework.jms.core.JmsOperations; >>>> import org.springframework.jms.core.JmsTemplate; >>>> import org.springframework.jms.core.MessageCreator; >>>>=20 >>>> import javax.jms.ConnectionFactory; >>>> import javax.jms.JMSException; >>>> import javax.jms.Message; >>>> import javax.jms.Session; >>>> import javax.management.MBeanServer; >>>> import java.lang.management.ManagementFactory; >>>> import java.net.URI; >>>>=20 >>>> import static org.junit.Assert.assertNotNull; >>>>=20 >>>> public class NetworkOfBrokersTest { >>>>=20 >>>> private static final MBeanServer PLATFORM_MBEAN_SERVER =3D >>>> ManagementFactory.getPlatformMBeanServer(); >>>> private static final String QUEUE_NAME =3D "testQueue"; >>>>=20 >>>> @Test >>>> public void testNetworkOfBrokersHandlesRestartOfNetworkConnector() >>>> throws Exception { >>>> // create consumer broker >>>> BrokerService consumerBrokerService =3D >>>> createBrokerService("consumerBrokerService"); >>>> consumerBrokerService.addConnector("tcp://localhost:61616"); >>>> consumerBrokerService.start(); >>>>=20 >>>> JmsOperations consumerJmsOperations =3D >>>>=20 >>>>=20 >> = createJmsOperations(createConnectionFactory(consumerBrokerService.getVmCon= nectorURI())); >>>>=20 >>>> // create producer broker in "network-of-brokers" = configuration >>>> BrokerService producerBrokerService =3D >>>> createBrokerService("producerBrokerService"); >>>> NetworkConnector networkConnector =3D >>>>=20 >> = producerBrokerService.addNetworkConnector("static:(tcp://localhost:61616)"= ); >>>> producerBrokerService.start(); >>>>=20 >>>> JmsOperations producerJmsOperations =3D >>>>=20 >>>>=20 >> = createJmsOperations(createConnectionFactory(producerBrokerService.getVmCon= nectorURI())); >>>>=20 >>>> try { >>>> // assert "network-of-brokers" configuration is working >>>>=20 >>>> = assertMessageSentByProducerIsReceivedByConsumer(consumerJmsOperations, >>>> producerJmsOperations); >>>>=20 >>>> // restart network connector via JMX >>>> = PLATFORM_MBEAN_SERVER.invoke(networkConnector.getObjectName(), >>>> "stop", new Object[0], new String[0]); >>>> = PLATFORM_MBEAN_SERVER.invoke(networkConnector.getObjectName(), >>>> "start", new Object[0], new String[0]); >>>>=20 >>>> // assert "network-of-brokers" configuration is working >>>>=20 >>>> = assertMessageSentByProducerIsReceivedByConsumer(consumerJmsOperations, >>>> producerJmsOperations); >>>> } >>>> finally { >>>> consumerBrokerService.stop(); >>>> producerBrokerService.stop(); >>>> } >>>> } >>>>=20 >>>> private static BrokerService createBrokerService(String = brokerName) { >>>> BrokerService brokerService =3D new BrokerService(); >>>> = brokerService.getManagementContext().setCreateConnector(false); >>>> brokerService.setBrokerName(brokerName); >>>> brokerService.setPersistent(false); >>>> brokerService.setTempDataStore(null); >>>> brokerService.setUseJmx(true); >>>> brokerService.setUseShutdownHook(false); >>>>=20 >>>> return brokerService; >>>> } >>>>=20 >>>> private static ConnectionFactory createConnectionFactory(URI >> brokerUrl) >>>> { >>>> ActiveMQConnectionFactory connectionFactory =3D new >>>> ActiveMQConnectionFactory(); >>>> connectionFactory.getPrefetchPolicy().setAll(1); >>>> connectionFactory.setBrokerURL(brokerUrl.toString()); >>>> connectionFactory.setDispatchAsync(false); >>>> connectionFactory.setUseAsyncSend(false); >>>>=20 >>>> return connectionFactory; >>>> } >>>>=20 >>>> private static JmsOperations createJmsOperations(ConnectionFactory >>>> connectionFactory) { >>>> JmsTemplate jmsTemplate =3D new JmsTemplate(); >>>> jmsTemplate.setConnectionFactory(connectionFactory); >>>> jmsTemplate.setDefaultDestinationName(QUEUE_NAME); >>>> jmsTemplate.setDeliveryPersistent(false); >>>> jmsTemplate.setReceiveTimeout(1000); >>>>=20 >>>> return jmsTemplate; >>>> } >>>>=20 >>>> private static void = assertMessageSentByProducerIsReceivedByConsumer( >>>> JmsOperations consumerJmsOperations, JmsOperations >>>> producerJmsOperations) { >>>>=20 >>>> producerJmsOperations.send( >>>> new MessageCreator() { >>>> @Override >>>> public Message createMessage(Session session) = throws >>>> JMSException { >>>> return session.createTextMessage(); >>>> } >>>> }); >>>> assertNotNull(consumerJmsOperations.receive()); >>>> } >>>> } >>>>=20 >>>> On May 5, 2010, at 12:42 PM, Geoffrey Arnold wrote: >>>>=20 >>>>> Issued opened with failing test: >>>>>=20 >>>>> https://issues.apache.org/activemq/browse/AMQ-2722 >>>>>=20 >>>>> Attaching JUnit test here too: >>>>>=20 >>>>> >>>>>=20 >>>>> On Apr 6, 2010, at 5:10 AM, Dejan Bosanac wrote: >>>>>=20 >>>>>> Hi, >>>>>>=20 >>>>>> can you raise a Jira for this (ideally with a test case that >>>> demonstrates >>>>>> the problem). >>>>>>=20 >>>>>> Cheers >>>>>> -- >>>>>> Dejan Bosanac - http://twitter.com/dejanb >>>>>>=20 >>>>>> Open Source Integration - http://fusesource.com/ >>>>>> ActiveMQ in Action - http://www.manning.com/snyder/ >>>>>> Blog - http://www.nighttale.net >>>>>>=20 >>>>>>=20 >>>>>> On Fri, Apr 2, 2010 at 11:16 PM, Geoffrey Arnold < >>>>>> geoffrey@geoffreyarnold.com> wrote: >>>>>>=20 >>>>>>> Hi All! >>>>>>>=20 >>>>>>> During upgrades we would like to be able to stop and restart the >>>> network >>>>>>> connector between embedded brokers running in separate VMs. >>>>>>>=20 >>>>>>> In the embedded broker of the producer VM we have a network = connector >>>>>>> pointing to the transport connector of an embedded broker in the >>>> consumer >>>>>>> VM. I have attempted to use JMX to stop and restart the network >>>> connector >>>>>>> in the producer VM, however the connection does not appear to be >>>>>>> reestablished. >>>>>>>=20 >>>>>>> What is the correct way to stop and restart this connection? >>>>>>>=20 >>>>>>> Thanks, >>>>>>> Geoff. >>>>>=20 >>>>=20 >>>>=20 >>=20 >>=20