List of usage examples for org.springframework.jms.connection JmsResourceHolder getConnection
@Nullable
public Connection getConnection()
From source file:com.ccc.ccm.client.JMSTemplateAutowired.java
/** * Fetch an appropriate Connection from the given JmsResourceHolder. * <p>This implementation accepts any JMS 1.1 Connection. * @param holder the JmsResourceHolder//from www. j ava2 s. c om * @return an appropriate Connection fetched from the holder, * or <code>null</code> if none found */ protected Connection getConnection(JmsResourceHolder holder) { return holder.getConnection(); }
From source file:org.springframework.jms.connection.ConnectionFactoryUtils.java
/** * Obtain a JMS Session that is synchronized with the current transaction, if any. * @param cf the ConnectionFactory to obtain a Session for * @param existingCon the existing JMS Connection to obtain a Session for * (may be {@code null})/*from w ww. j a va2 s . c om*/ * @param synchedLocalTransactionAllowed whether to allow for a local JMS transaction * that is synchronized with a Spring-managed transaction (where the main transaction * might be a JDBC-based one for a specific DataSource, for example), with the JMS * transaction committing right after the main transaction. If not allowed, the given * ConnectionFactory needs to handle transaction enlistment underneath the covers. * @return the transactional Session, or {@code null} if none found * @throws JMSException in case of JMS failure */ @Nullable public static Session getTransactionalSession(final ConnectionFactory cf, @Nullable final Connection existingCon, final boolean synchedLocalTransactionAllowed) throws JMSException { return doGetTransactionalSession(cf, new ResourceFactory() { @Override @Nullable public Session getSession(JmsResourceHolder holder) { return holder.getSession(Session.class, existingCon); } @Override @Nullable public Connection getConnection(JmsResourceHolder holder) { return (existingCon != null ? existingCon : holder.getConnection()); } @Override public Connection createConnection() throws JMSException { return cf.createConnection(); } @Override public Session createSession(Connection con) throws JMSException { return con.createSession(synchedLocalTransactionAllowed, Session.AUTO_ACKNOWLEDGE); } @Override public boolean isSynchedLocalTransactionAllowed() { return synchedLocalTransactionAllowed; } }, true); }