Examples of SingleConnectionFactory


Examples of org.springframework.jms.connection.SingleConnectionFactory

        JmsEndpoint endpoint = resolveMandatoryEndpoint("activemq:test.foo?useSingleConnection=true");
        JmsProducer producer = 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

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

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 {
                    scf = new SingleConnectionFactory102(connectionFactory, pubSubDomain);
                }
                if (getDurableSubscriptionClientId() != null) {
                    scf.setClientId(getDurableSubscriptionClientId());
                }
                scf.setReconnectOnException(isReconnectOnException());
                wrappedConnectionFactory = scf;
            } else {
                wrappedConnectionFactory = connectionFactory;
            }
        }
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

        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 {
                    scf = new SingleConnectionFactory102(connectionFactory, pubSubDomain);
                }
                if (getDurableSubscriptionClientId() != null) {
                    scf.setClientId(getDurableSubscriptionClientId());
                }
                scf.setReconnectOnException(isReconnectOnException());
                wrappedConnectionFactory = scf;
            } else {
                wrappedConnectionFactory = connectionFactory;
            }
        }
View Full Code Here

Examples of org.springframework.jms.connection.SingleConnectionFactory

            if (connectionFactory == null) {
                connectionFactory = JMSFactory.getConnectionFactoryFromJndi(this);
            }
            if (wrapInSingleConnectionFactory && !(connectionFactory instanceof SingleConnectionFactory)) {
                if (useJms11) {
                    wrappedConnectionFactory = new SingleConnectionFactory(connectionFactory);
                } else {
                    wrappedConnectionFactory = new SingleConnectionFactory102(connectionFactory,
                                                                              pubSubDomain);
                }
                if (reconnectOnException) {
View Full Code Here

Examples of org.springframework.jms.connection.SingleConnectionFactory

    @Override
    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

    verify(connection).close();
  }

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

    TransactionSynchronizationManager.initSynchronization();
    try {
      template.execute(new SessionCallback<Void>() {
        @Override
        public Void doInJms(Session session) throws JMSException {
          session.getTransacted();
          return null;
        }
      });
      template.execute(new SessionCallback<Void>() {
        @Override
        public Void doInJms(Session session) throws JMSException {
          session.getTransacted();
          return null;
        }
      });

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

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

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

    verify(connection).start();
    if (useTransactedTemplate()) {
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

        return template;
    }

    private synchronized ConnectionFactory retrieveJmsConnectionFactory(String host) {
        if (!connections.containsKey(host)) {
            connections.put(host, new SingleConnectionFactory(new ActiveMQConnectionFactory(host)));
        }
        return connections.get(host);
    }
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.