Package org.apache.activemq.broker

Examples of org.apache.activemq.broker.BrokerService


    public BrokerService createBroker(URI config) throws Exception {

        String uri = config.getSchemeSpecificPart();
        ApplicationContext context = createApplicationContext(uri);

        BrokerService broker = null;
        try {
            broker = (BrokerService)context.getBean("broker");
        } catch (BeansException e) {
        }
View Full Code Here


                    return super.doCompositeConnect(finalLocation);
                };
            };
            rc.setBrokerFactoryHandler(new BrokerFactoryHandler() {
                public BrokerService createBroker(URI brokerURI) throws Exception {
                    BrokerService service = new BrokerService();
                    IntrospectionSupport.setProperties(service, brokerOptions);
                    service.setBrokerName(finalBroker);
                    TransportConnector c = service.addConnector("tcp://localhost:0");
                    c.setDiscoveryUri(new URI("multicast://" + finalGroup));
                    service.addNetworkConnector("multicast://" + finalGroup);
                    return service;
                }
            });
            return rc;
View Full Code Here

     * @throws Exception
     */
    @Ignore
    @Test
    public void testRequestReply() throws Exception {
        BrokerService broker = new BrokerService();
        broker.addConnector("tcp://localhost:61616");
        broker.setPersistent(false);
        broker.setTimeBeforePurgeTempDestinations(1000);
        broker.start();

        DefaultCamelContext context = new DefaultCamelContext();
        JmsComponent jmsComponent = new JmsComponent();

        /**
         *
         */
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
        connectionFactory.setBrokerURL("failover://(tcp://localhost:61616)?maxReconnectAttempts=1");

        /**
         * When using Tibco EMS the problem can be recreated. As the broker is
         * external it has to be stopped and started by hand.
         */
        // TibjmsConnectionFactory connectionFactory = new
        // TibjmsConnectionFactory();
        // connectionFactory.setReconnAttemptCount(1);

        jmsComponent.setConnectionFactory(connectionFactory);
        jmsComponent.setRequestTimeout(1000);
        jmsComponent.setReceiveTimeout(1000);
        context.addComponent("jms", jmsComponent);
        context.addRoutes(new RouteBuilder() {

            @Override
            public void configure() throws Exception {
                from("jms:testqueue").bean(new EchoServiceImpl());
                from("direct:test").to("jms:testqueue");
            }
        });
        CamelBeanPostProcessor processor = new CamelBeanPostProcessor();
        processor.setCamelContext(context);
        processor.postProcessBeforeInitialization(this, "this");
        context.start();

        String ret = proxy.echo("test");
        Assert.assertEquals("test", ret);

        broker.stop();
        /**
         * Wait long enough for the jms client to do a full reconnect. In the
         * Tibco EMS case this means that a Temporary Destination created before
         * is invalid now
         */
        Thread.sleep(5000);

        System.in.read();
        broker.start(true);

        /**
         * Before the fix to this issue this call will throw a spring UncategorizedJmsException
         * which contains an InvalidJmsDestination
         */
 
View Full Code Here

        }
    }

    protected BrokerService createBroker() throws Exception {

      BrokerService service = new BrokerService();
        service.setPersistent(false);
        service.setUseJmx(false);
        connector = service.addConnector("tcp://localhost:0");

        return service;
    }
View Full Code Here

    private void doList(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
        List<ConnectorWrapper> connectorWrappers = new ArrayList<ConnectorWrapper>();
        Map<String, BrokerServiceWrapper> brokerServices = getBrokerServices();
        Collection<BrokerServiceWrapper> wrappers = brokerServices.values();
        for (BrokerServiceWrapper wrapper: wrappers) {
            BrokerService brokerService = wrapper.getBrokerService();
            List<TransportConnector> connectors = brokerService.getTransportConnectors();
            for (TransportConnector connector: connectors) {
                String connectorURI = connector.getUri().toString();
                String brokerName = wrapper.getBrokerName();
                String protocol = connector.getUri().getScheme();
                int port = connector.getUri().getPort();
View Full Code Here

            throws PortletException, IOException {
        //String sBrokerURI = actionRequest.getParameter("brokerURI");
        String sBrokerName = actionRequest.getParameter("brokerName");
        try {
            Map<String, BrokerServiceWrapper> brokerServices = getBrokerServices();
            BrokerService brokerService = brokerServices.get(sBrokerName).getBrokerService();
            if (brokerService.isStarted()) {
                return;
            }
            brokerService.start(true);
            brokerService.waitUntilStarted();
            if (!brokerService.isStarted()) {
                throw new PortletException(getLocalizedString(actionRequest,
                        "jmsmanager.broker.failStartBrokerNoReason", sBrokerName));
            }
            addInfoMessage(actionRequest, getLocalizedString(actionRequest, "jmsmanager.broker.successStartBroker",
                    sBrokerName));
View Full Code Here

            throws PortletException, IOException {
        //String sBrokerURI = actionRequest.getParameter("brokerURI");
        String sBrokerName = actionRequest.getParameter("brokerName");
        try {
            Map<String, BrokerServiceWrapper> brokerServices = getBrokerServices();
            BrokerService brokerService = brokerServices.get(sBrokerName).getBrokerService();
            if (!brokerService.isStarted()) {
                return;
            }
            brokerService.stop();
            brokerService.waitUntilStopped();
            if (brokerService.isStarted()) {
                throw new PortletException(getLocalizedString(actionRequest,
                        "jmsmanager.broker.failStopBrokerNoReason", sBrokerName));
            }
            addInfoMessage(actionRequest, getLocalizedString(actionRequest, "jmsmanager.broker.successStopBroker",
                    sBrokerName));
View Full Code Here

                @SuppressWarnings("unchecked")
                Set<String> ids = (Set<String>) container.getComponentIds();
                for (Object id: ids) {
                    Object object = container.getComponentInstance((String)id);
                    if (object instanceof BrokerService) {
                        BrokerService brokerService = (BrokerService) object;
                        String brokerName = brokerService.getBrokerName();
                        String brokerURI = brokerService.getMasterConnectorURI();
                        State state = brokerService.isStarted() ? State.RUNNING : State.STOPPED;
                        BrokerServiceWrapper wrapper = new BrokerServiceWrapper(brokerName, brokerURI, brokerService, state);
                        brokerServices.put(brokerName, wrapper);
                    }
                }
            }
View Full Code Here

    BrokerService broker = null;

    protected BrokerService createBroker(KahaDBPersistenceAdapter kaha) throws Exception {

        broker = new BrokerService();
        broker.setUseJmx(false);
        broker.setPersistenceAdapter(kaha);
        broker.start();
        return broker;
View Full Code Here

        KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
        File dir = new File("src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersionX");
        IOHelper.deleteFile(dir);
        kaha.setDirectory(dir);
        kaha.setJournalMaxFileLength(1024*1024);
        BrokerService broker = createBroker(kaha);
        ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");       
        Connection connection = cf.createConnection();
        connection.setClientID("test");
        connection.start();
        producerSomeMessages(connection, 1000);
        connection.close();
        broker.stop();
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.broker.BrokerService

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.