Return-Path: X-Original-To: apmail-activemq-users-archive@www.apache.org Delivered-To: apmail-activemq-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BB86510B93 for ; Thu, 24 Oct 2013 17:41:56 +0000 (UTC) Received: (qmail 57081 invoked by uid 500); 24 Oct 2013 17:41:50 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 57041 invoked by uid 500); 24 Oct 2013 17:41:49 -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 57033 invoked by uid 99); 24 Oct 2013 17:41:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Oct 2013 17:41:49 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of christian.posta@gmail.com designates 209.85.215.41 as permitted sender) Received: from [209.85.215.41] (HELO mail-la0-f41.google.com) (209.85.215.41) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Oct 2013 17:41:45 +0000 Received: by mail-la0-f41.google.com with SMTP id el20so2242957lab.0 for ; Thu, 24 Oct 2013 10:41:23 -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; bh=+SuVB8+ZbQUGE2nKN56VrgEcCShuG5GR6LcdEioPgF8=; b=ONREwOEc/SnvRkfRB+ac6BfHqa8/uq/xWF1IMT67Yft8cF/KLwDVsxRQkP6KkMm/h3 o+Y261sFh5YApq/29MpNcdrSoRaVpcg3tPibGk2cipVbmdX7H+nVxps1h2vKaEnN7gE0 pmK23Dgg62PKUWKnji8xDEZNjAalztb8QhNJhveGm0VosIEE28VNCh/Z/Ss3unirFVrA NQkXCOygl8oI+GudgxN5OgAfxjTf2xOXTNDy7FW6EdCtgz7PPCkoQR8pFhU1+an6Tiib CTze0KpiZ19pvelNqL2mLwWAvt/YeJjnqIJeWP62AjusZzBZLCQcPiyrve58E7C0waKq 0U/g== MIME-Version: 1.0 X-Received: by 10.152.115.146 with SMTP id jo18mr506860lab.56.1382636483352; Thu, 24 Oct 2013 10:41:23 -0700 (PDT) Received: by 10.114.2.239 with HTTP; Thu, 24 Oct 2013 10:41:23 -0700 (PDT) In-Reply-To: References: Date: Thu, 24 Oct 2013 10:41:23 -0700 Message-ID: Subject: Re: Add network connector dynamically over JMX From: Christian Posta To: "users@activemq.apache.org" Content-Type: multipart/alternative; boundary=001a11c3561a719d7c04e9802494 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c3561a719d7c04e9802494 Content-Type: text/plain; charset=ISO-8859-1 I've opened the issue here: https://issues.apache.org/jira/browse/AMQ-4823 and fixed it on origin/trunk. On Thu, Oct 24, 2013 at 9:30 AM, Christian Posta wrote: > Yah, seems like the mbeans aren't registered properly when creating > through JMX. > > The bridge does get created, but it's not visible in jconsole. > > Can you create a JIRA for this? > > > On Thu, Oct 24, 2013 at 4:11 AM, Bratislav Stojanovic < > bratislav1983@gmail.com> wrote: > >> Hi all, >> >> Does anybody know how to do this? Here's the code I've tried, but it >> doesn't work : >> >> JMXServiceURL url = new >> JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root"); >> Map env = new HashMap(); >> String[] creds = {"...", "..."}; >> env.put(JMXConnector.CREDENTIALS, creds); >> JMXConnector jmxc = JMXConnectorFactory.connect(url, env); >> >> MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); >> >> // Get domains from MBeanServer >> System.out.println("\nDomains:"); >> String domains[] = mbsc.getDomains(); >> Arrays.sort(domains); >> for (String domain : domains) { >> System.out.println("\tDomain = " + domain); >> } >> >> // Get MBeanServer's default domain >> System.out.println("\nMBeanServer default domain = " + >> mbsc.getDefaultDomain()); >> >> // Get MBean count >> // >> System.out.println("\nMBean count = " + mbsc.getMBeanCount()); >> >> // Query MBean names >> // >> System.out.println("\nQuery MBeanServer MBeans:"); >> Set names = >> new TreeSet(mbsc.queryNames(null, null)); >> for (ObjectName name : names) { >> System.out.println("\tObjectName = " + name); >> } >> >> >> // find mbean >> ObjectName mbeanName = null; >> for (ObjectName name : names) { >> if >> >> (name.toString().equals("org.apache.activemq:type=Broker,brokerName=broker")) >> { >> mbeanName = name; >> } >> } >> >> if (mbeanName == null) { >> System.err.println("No mbean found"); >> return; >> } >> >> BrokerViewMBean mbeanProxy =JMX.newMBeanProxy(mbsc, mbeanName, >> BrokerViewMBean.class, true); >> >> >> >> System.out.println(mbeanProxy.addNetworkConnector("static:failover:(tcp://localhost:61617)")); >> >> ObjectName mbeanName2 = new >> >> ObjectName("org.apache.activemq:type=Broker,brokerName=broker,connector=networkConnectors,connectorName=NC"); >> NetworkConnectorViewMBean mbeanProxy2 =JMX.newMBeanProxy(mbsc, >> mbeanName2, NetworkConnectorViewMBean.class, true); >> >> mbeanProxy2.start(); // start NC >> jmxc.close(); >> >> It will fail on the second proxy with the message : >> >> Exception in thread "main" javax.management.InstanceNotFoundException: >> >> org.apache.activemq:type=Broker,brokerName=broker,connector=networkConnectors,connectorName=NC >> >> I'm using activemq 5.9.0 running inside karaf 2.3.3. >> >> Please help! >> >> -- >> Bratislav Stojanovic, M.Sc. >> > > > > -- > *Christian Posta* > http://www.christianposta.com/blog > twitter: @christianposta > -- *Christian Posta* http://www.christianposta.com/blog twitter: @christianposta --001a11c3561a719d7c04e9802494--