Examples of SingleConnectionFactory


Examples of org.springframework.jms.connection.SingleConnectionFactory

                   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

Examples of org.springframework.jms.connection.SingleConnectionFactory

        // 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

Examples of org.springframework.jms.connection.SingleConnectionFactory

        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

Examples of org.springframework.jms.connection.SingleConnectionFactory

    }

    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

Examples of org.springframework.jms.connection.SingleConnectionFactory

    }

    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

Examples of org.springframework.jms.connection.SingleConnectionFactory

        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

Examples of org.springframework.jms.connection.SingleConnectionFactory

    connectionControl.verify();
    sessionControl.verify();
  }

  public void testSessionCallbackWithinSynchronizedTransaction() throws Exception {
    SingleConnectionFactory scf = new SingleConnectionFactory(mockConnectionFactory);
    JmsTemplate template = createTemplate();
    template.setConnectionFactory(scf);

    mockConnection.start();
    connectionControl.setVoidCallable(3);
    // We're gonna call getTransacted 3 times, i.e. 2 more times.
    mockSession.getTransacted();
    sessionControl.setReturnValue(useTransactedSession(), 2);
    if (useTransactedTemplate()) {
      mockSession.commit();
      sessionControl.setVoidCallable(1);
    }
    mockSession.close();
    sessionControl.setVoidCallable(1);
    mockConnection.stop();
    connectionControl.setVoidCallable(1);
    mockConnection.close();
    connectionControl.setVoidCallable(1);

    sessionControl.replay();
    connectionControl.replay();

    TransactionSynchronizationManager.initSynchronization();
    try {
      template.execute(new SessionCallback() {
        public Object doInJms(Session session) throws JMSException {
          boolean b = session.getTransacted();
          return null;
        }
      });
      template.execute(new SessionCallback() {
        public Object doInJms(Session session) throws JMSException {
          boolean b = session.getTransacted();
          return null;
        }
      });

      assertSame(mockSession, ConnectionFactoryUtils.getTransactionalSession(scf, null, false));
      assertSame(mockSession, ConnectionFactoryUtils.getTransactionalSession(scf, scf.createConnection(), false));

      TransactionAwareConnectionFactoryProxy tacf = new TransactionAwareConnectionFactoryProxy(scf);
      Connection tac = tacf.createConnection();
      Session tas = tac.createSession(false, Session.AUTO_ACKNOWLEDGE);
      boolean b = tas.getTransacted();
      tas.close();
      tac.close();

      List synchs = TransactionSynchronizationManager.getSynchronizations();
      assertEquals(1, synchs.size());
      TransactionSynchronization synch = (TransactionSynchronization) synchs.get(0);
      synch.beforeCommit(false);
      synch.beforeCompletion();
      synch.afterCommit();
      synch.afterCompletion(TransactionSynchronization.STATUS_UNKNOWN);
    }
    finally {
      TransactionSynchronizationManager.clearSynchronization();
      scf.destroy();
    }
    assertTrue(TransactionSynchronizationManager.getResourceMap().isEmpty());

    connectionFactoryControl.verify();
    connectionControl.verify();
View Full Code Here

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

Examples of org.springframework.jms.connection.SingleConnectionFactory

        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

Examples of org.springframework.jms.connection.SingleConnectionFactory

        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
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.