Package org.apache.activemq.broker.jmx

Examples of org.apache.activemq.broker.jmx.ManagementContext


    private void configureMBeanServer(BrokerService brokerService, int port) throws IOException {
        // shared fs master/slave
        brokerService.getPersistenceAdapter().setDirectory(
                new File(brokerService.getDataDirectoryFile(), "shared"));

        ManagementContext managementContext = brokerService.getManagementContext();

        // have mbean servers remain alive - like in karaf container
        MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(managementContext.getJmxDomainName());

        Registry registry = LocateRegistry.createRegistry(port + 1);

        JMXConnectorServer connectorServer =
                        JMXConnectorServerFactory.newJMXConnectorServer(
                                new JMXServiceURL(
                                    "service:jmx:rmi://localhost:"  + port + "/jndi/rmi://localhost:" + (port + 1) + "/jmxrmi"),
                                null, mbeanServer);

        connectorServer.start();
        serverList.addFirst(connectorServer);

        managementContext.setMBeanServer(mbeanServer);
        managementContext.setCreateConnector(false);
    }
View Full Code Here


        protected BrokerService createBroker() throws Exception {
        BrokerService answer = new BrokerService();
        answer.setPersistent(isPersistent());
        answer.addConnector(bindAddress);
        ManagementContext context = new ManagementContext();
        context.setConnectorPort(1199);
        answer.setManagementContext(context);
        return answer;
    }
View Full Code Here

                    }
                }
            }
           
            // Do not allow creation of another ConnectorServer
            ManagementContext mgmtctx = new ManagementContext(mbeanServerReference != null ? mbeanServerReference.getMBeanServer() : null);
            mgmtctx.setCreateConnector(false);
            brokerService.setManagementContext(mgmtctx);

            // Do not allow the broker to use a shutown hook, the kernel will stop it
            brokerService.setUseShutdownHook(isUseShutdownHook());
View Full Code Here

        this.brokerObjectName = brokerObjectName;
    }

    public ManagementContext getManagementContext() {
        if (managementContext == null) {
            managementContext = new ManagementContext();
        }
        return managementContext;
    }
View Full Code Here

        params.put("type", "Broker");
        params.put("destinationType", "Queue");
        params.put("destinationName", queueName);
        ObjectName queueObjectName = ObjectName.getInstance(amqDomain, params);

        ManagementContext mgmtCtx = broker.getManagementContext();
        QueueViewMBean queueView = (QueueViewMBean)mgmtCtx.newProxyInstance(queueObjectName, QueueViewMBean.class, true);

        Object[] messages = queueView.browse();

        LOG.info("+Browsed with JMX: " + messages.length);
View Full Code Here

        broker.setBrokerName("localhost");
        broker.setUseJmx(true);
        broker.setDeleteAllMessagesOnStartup(deleteAllMessagesOnStartup);
        broker.addConnector("tcp://localhost:0");

        ManagementContext ctx = new ManagementContext();
        //if createConnector == true everything is fine
        ctx.setCreateConnector(false);
        broker.setManagementContext(ctx);

        broker.start();
        broker.waitUntilStarted();
View Full Code Here

        System.out.println("Starting broker");
        System.out.flush();
        broker = new BrokerService();
        broker.setPersistent(false);
        ManagementContext ctx = new ManagementContext(ManagementFactory.getPlatformMBeanServer());
        ctx.setConnectorPort(jmxport);
        broker.setManagementContext(ctx);
        broker.setUseJmx(true);
//        broker.setAdvisorySupport(false);
//        broker.setDeleteAllMessagesOnStartup(true);
View Full Code Here

        super.stop();
    }

    private void registerMbean() {
        if (getBrokerService().isUseJmx()) {
            ManagementContext managementContext = getBrokerService().getManagementContext();
            try {
                objectName = new ObjectName(getBrokerService().getBrokerObjectName().toString() + objectNamePropsAppendage);
                managementContext.registerMBean(new RuntimeConfigurationView(this), objectName);
            } catch (Exception ignored) {
                LOG.debug("failed to register RuntimeConfigurationMBean", ignored);
            }
        }
    }
View Full Code Here

            // String brokerDir = "xbean:...;
            // System.setProperty("activemq.base", brokerDir);
            // BrokerService broker = BrokerFactory.createBroker(new URI(brokerDir + "/activemq.xml"));

            // for running on Java 5 without mx4j
            ManagementContext managementContext = broker.getManagementContext();
            managementContext.setFindTigerMbeanServer(true);
            managementContext.setUseMBeanServer(true);
            managementContext.setCreateConnector(false);

            broker.setUseJmx(true);
            // broker.setPlugins(new BrokerPlugin[] { new
            // ConnectionDotFilePlugin(), new UDPTraceBrokerPlugin() });
            broker.addConnector("tcp://localhost:61616");
View Full Code Here

        super.stop();
    }

    private void registerMbean() {
        if (getBrokerService().isUseJmx()) {
            ManagementContext managementContext = getBrokerService().getManagementContext();
            try {
                objectName = new ObjectName(getBrokerService().getBrokerObjectName().toString() + objectNamePropsAppendage);
                managementContext.registerMBean(new RuntimeConfigurationView(this), objectName);
            } catch (Exception ignored) {
                LOG.debug("failed to register RuntimeConfigurationMBean", ignored);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.broker.jmx.ManagementContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.