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 1F02C108F3 for ; Thu, 24 Oct 2013 16:31:13 +0000 (UTC) Received: (qmail 70096 invoked by uid 500); 24 Oct 2013 16:31:10 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 69128 invoked by uid 500); 24 Oct 2013 16:31:09 -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 68233 invoked by uid 99); 24 Oct 2013 16:31:08 -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 16:31:08 +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.54 as permitted sender) Received: from [209.85.215.54] (HELO mail-la0-f54.google.com) (209.85.215.54) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Oct 2013 16:31:03 +0000 Received: by mail-la0-f54.google.com with SMTP id gx14so2085783lab.41 for ; Thu, 24 Oct 2013 09:30:42 -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=o3NTj3m10EM+rhcJvDm4b9mn1v4PjJtm0xFI7EKmnck=; b=C/7jrDTpxQX2wKmNstblngxVUwu3zi8B225KxYuJf3twKZ1CmWzbfJbFLqyf8zFgKQ Aqn2Y9OrzdxJLwDKGIXcuW0YRcn6kOjoQAauoEy3dXw+vhIlk3cklRAcjSV9KmlTOnvW eWusRoWvJ2uEbm/kDj/QYG+5e2keXbSxbLbKq5V1dEBM5SYJRtLCvC3YyGCQ2or29/Hi SEPPPyvENPSscAuvnuGa2NRbzPH99aKWuhi38SCpdN/GGYrivSkKW2SIJWgRevtwYf64 uPnUUXwLt8gVPSTnK/mn4aGpJAVSZlEfASvneAFgCz/5bMuyG15Ns0i2xMLbXfP8jWlt YyAw== MIME-Version: 1.0 X-Received: by 10.152.29.38 with SMTP id g6mr2373211lah.25.1382632242163; Thu, 24 Oct 2013 09:30:42 -0700 (PDT) Received: by 10.114.2.239 with HTTP; Thu, 24 Oct 2013 09:30:42 -0700 (PDT) In-Reply-To: References: Date: Thu, 24 Oct 2013 09:30:42 -0700 Message-ID: Subject: Re: Add network connector dynamically over JMX From: Christian Posta To: "users@activemq.apache.org" Content-Type: multipart/alternative; boundary=089e0158c004a6378a04e97f2778 X-Virus-Checked: Checked by ClamAV on apache.org --089e0158c004a6378a04e97f2778 Content-Type: text/plain; charset=ISO-8859-1 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 --089e0158c004a6378a04e97f2778--