Package org.springframework.jms.connection

Examples of org.springframework.jms.connection.SingleConnectionFactory


                brokerService2.start();
            }
            final ExecutorService pool = Executors.newSingleThreadExecutor();
            final ActiveMQConnectionFactory connectionFactory1 = new ActiveMQConnectionFactory(
                    "vm://one");
            final SingleConnectionFactory singleConnectionFactory1 = new SingleConnectionFactory(
                    connectionFactory1);
            singleConnectionFactory1.setReconnectOnException(true);
            final DefaultMessageListenerContainer container1 = new DefaultMessageListenerContainer();
            container1.setConnectionFactory(singleConnectionFactory1);
            container1.setMaxConcurrentConsumers(1);
            container1.setDestination(new ActiveMQQueue("testingqueue"));
            container1.setMessageListener(new MessageListener() {

                public void onMessage(final Message message) {
                    broker1Count.incrementAndGet();
                }
            });
            container1.afterPropertiesSet();
            container1.start();
            pool.submit(new Callable<Object>() {

                public Object call() throws Exception {
                    try {
                        final ActiveMQConnectionFactory connectionFactory2 = new ActiveMQConnectionFactory(
                                "vm://two");
                        final SingleConnectionFactory singleConnectionFactory2 = new SingleConnectionFactory(
                                connectionFactory2);
                        singleConnectionFactory2.setReconnectOnException(true);
                        final DefaultMessageListenerContainer container2 = new DefaultMessageListenerContainer();
                        container2
                                .setConnectionFactory(singleConnectionFactory2);
                        container2.setMaxConcurrentConsumers(1);
                        container2.setDestination(new ActiveMQQueue(
View Full Code Here


        final String xmlConfig = getClass().getPackage().getName().replace('.','/') + "/loadbalancetest.xml";
        System.setProperty("lbt.networkBridgePrefetch", String.valueOf(networkBridgePrefetch));
        System.setProperty("lbt.brokerName", "one");
        final ActiveMQConnectionFactory connectionFactory1 = new ActiveMQConnectionFactory(
                "vm://one?brokerConfig=xbean:" + xmlConfig);
        final SingleConnectionFactory singleConnectionFactory1 = new SingleConnectionFactory(
                connectionFactory1);
        singleConnectionFactory1.setReconnectOnException(true);
        final DefaultMessageListenerContainer container1 = new DefaultMessageListenerContainer();
        container1.setConnectionFactory(singleConnectionFactory1);
        container1.setMaxConcurrentConsumers(1);
        container1.setDestination(new ActiveMQQueue(TESTING_QUEUE));
        container1.setMessageListener(new MessageListener() {

            public void onMessage(final Message message) {
                broker1Count.incrementAndGet();
            }
        });
        container1.afterPropertiesSet();
        container1.start();
        pool.submit(new Callable<Object>() {

            public Object call() throws Exception {
                System.setProperty("lbt.brokerName", "two");
                final ActiveMQConnectionFactory connectionFactory2 = new ActiveMQConnectionFactory(
                        "vm://two?brokerConfig=xbean:" + xmlConfig);
                final SingleConnectionFactory singleConnectionFactory2 = new SingleConnectionFactory(
                        connectionFactory2);
                singleConnectionFactory2.setReconnectOnException(true);
                final DefaultMessageListenerContainer container2 = new DefaultMessageListenerContainer();
                container2.setConnectionFactory(singleConnectionFactory2);
                container2.setMaxConcurrentConsumers(1);
                container2.setDestination(new ActiveMQQueue(TESTING_QUEUE));
                container2.setMessageListener(new MessageListener() {
View Full Code Here

        JmsEndpoint endpoint = resolveMandatoryEndpoint("activemq:test.foo?useSingleConnection=true");
        JmsProducer producer = (JmsProducer) endpoint.createProducer();

        JmsTemplate template = assertIsInstanceOf(JmsTemplate.class, producer.getInOutTemplate());
        assertEquals("pubSubDomain", false, template.isPubSubDomain());
        SingleConnectionFactory connectionFactory = assertIsInstanceOf(SingleConnectionFactory.class, template.getConnectionFactory());
        assertIsInstanceOf(ActiveMQConnectionFactory.class, connectionFactory.getTargetConnectionFactory());
    }
View Full Code Here

        if (answer.getBeanName() == null) {
            answer.setBeanName("Camel");
        }
        answer.setBrokerURL(getBrokerURL());
        if (isUseSingleConnection()) {
            SingleConnectionFactory scf = new SingleConnectionFactory(answer);
            if (activeMQComponent != null) {
                activeMQComponent.addSingleConnectionFactory(scf);
            }
            return scf;
        }
View Full Code Here

                   jmsConfig.getConnectionFactory() instanceof ActiveMQConnectionFactory);
        // get the wrapped connectionFactory
        ConnectionFactory wrappingCf = jmsConfig.getOrCreateWrappedConnectionFactory();
        assertTrue("Should get the instance of SingleConnectionFactory",
                   wrappingCf instanceof SingleConnectionFactory);
        SingleConnectionFactory scf = (SingleConnectionFactory)wrappingCf;
        assertSame("Should get the wrapped ActiveMQConnectionFactory",
                    amqCf, scf.getTargetConnectionFactory());
        // destroy the wrapping
        jmsConfig.destroyWrappedConnectionFactory();
        // get the wrapping cf
        assertNull("Should be null after destroy", jmsConfig.getWrappedConnectionFactory());
        // original connectionFactory should be unchanged
View Full Code Here

        // create an empty configuration
        JMSConfiguration jmsConfig = new JMSConfiguration();
        // create the connectionFactory to wrap
        ActiveMQConnectionFactory amqCf = new ActiveMQConnectionFactory();
        // wrap into SingleConnectionFactory
        SingleConnectionFactory scf = new SingleConnectionFactory(amqCf);
        // set the connectionFactory to reuse
        jmsConfig.setConnectionFactory(scf);
        // get the connectionFactory
        assertTrue("Should get the instance of SingleConnectionFactory",
                   jmsConfig.getConnectionFactory() instanceof SingleConnectionFactory);
View Full Code Here

        if (wrappedConnectionFactory == null) {
            if (connectionFactory == null) {
                connectionFactory = JMSFactory.getConnectionFactoryFromJndi(this);
            }
            if (wrapInSingleConnectionFactory && !(connectionFactory instanceof SingleConnectionFactory)) {
                SingleConnectionFactory scf;
                if (useJms11) {
                    if (connectionFactory instanceof XAConnectionFactory) {
                        scf = new XASingleConnectionFactory(connectionFactory);
                    } else {
                        scf = new SingleConnectionFactory(connectionFactory);
                    }
                    autoWrappedConnectionFactory = true;
                } else {
                    @SuppressWarnings("deprecation")
                    SingleConnectionFactory scf2
                        = new org.springframework.jms.connection.SingleConnectionFactory102(connectionFactory,
                                                                                            pubSubDomain);
                    scf = scf2;
                }
View Full Code Here

    }

    public Connection createConnection() throws JMSException {
      if (AbstractPollingMessageListenerContainer.this.sharedConnectionEnabled()) {
        Connection sharedCon = AbstractPollingMessageListenerContainer.this.getSharedConnection();
        return new SingleConnectionFactory(sharedCon).createConnection();
      }
      else {
        return AbstractPollingMessageListenerContainer.this.createConnection();
      }
    }
View Full Code Here

    }

    public Connection createConnection() throws JMSException {
      if (AbstractPollingMessageListenerContainer.this.sharedConnectionEnabled()) {
        Connection sharedCon = AbstractPollingMessageListenerContainer.this.getSharedConnection();
        return new SingleConnectionFactory(sharedCon).createConnection();
      }
      else {
        return AbstractPollingMessageListenerContainer.this.createConnection();
      }
    }
View Full Code Here

        if (wrappedConnectionFactory == null) {
            if (connectionFactory == null) {
                connectionFactory = JMSFactory.getConnectionFactoryFromJndi(this);
            }
            if (wrapInSingleConnectionFactory && !(connectionFactory instanceof SingleConnectionFactory)) {
                SingleConnectionFactory scf;
                if (useJms11) {
                    if (connectionFactory instanceof XAConnectionFactory) {
                        scf = new XASingleConnectionFactory(connectionFactory);
                    } else {
                        scf = new SingleConnectionFactory(connectionFactory);
                    }
                } else {
                    @SuppressWarnings("deprecation")
                    SingleConnectionFactory scf2
                        = new org.springframework.jms.connection.SingleConnectionFactory102(connectionFactory,
                                                                                            pubSubDomain);
                    scf = scf2;
                }
View Full Code Here

TOP

Related Classes of org.springframework.jms.connection.SingleConnectionFactory

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.