Examples of QpidServiceImpl


Examples of org.wso2.carbon.qpid.service.QpidServiceImpl

        // Make it possible to create VM brokers automatically
        System.setProperty(VM_BROKER_AUTO_CREATE, "true");
        // Set Derby log filename
        System.setProperty(DERBY_LOG_FILE, System.getProperty(ServerConstants.CARBON_HOME) + QPID_DERBY_LOG_FILE);
       
        QpidServiceImpl qpidServiceImpl =
                new QpidServiceImpl(QpidServiceDataHolder.getInstance().getAccessKey());

        // Start Qpid broker
        try {
            System.setProperty(Main.QPID_HOME, qpidServiceImpl.getQpidHome());
            String[] args = {"-p" + qpidServiceImpl.getPort(), "-s" + qpidServiceImpl.getSSLPort()};
            Main.setStandaloneMode(false);
            Main.main(args);

            // Remove Qpid shutdown hook so that I have control over shutting the broker down
            Runtime.getRuntime().removeShutdownHook(ApplicationRegistry.getShutdownHook());

            // Wait until the broker has started
            while (!isBrokerRunning()) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {}
            }

            //check whether the tcp port has started. some times the server started thread may return
            //before Qpid server actually bind to the tcp port. in that case there are some connection
            //time out issues.
            boolean isServerStarted = false;
            int port = Integer.parseInt(qpidServiceImpl.getPort());
            while (!isServerStarted) {
                Socket socket = null;
                try {
                    InetAddress address = InetAddress.getByName("localhost");
                    socket = new Socket(address, port);
                    isServerStarted = socket.isConnected();
                    if (isServerStarted) {
                        log.info("Successfully connected to the server on port " + qpidServiceImpl.getPort());
                    }
                } catch (IOException e) {
                    log.info("Wait until Qpid server starts on port " + qpidServiceImpl.getPort());
                    Thread.sleep(500);
                } finally {
                    try {
                        if ((socket != null) && (socket.isConnected())) {
                            socket.close();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.