use of jakarta.jms.QueueConnection in project spring-framework by spring-projects.
the class SingleConnectionFactory method createQueueConnection.
@Override
public QueueConnection createQueueConnection() throws JMSException {
Connection con;
synchronized (this.connectionMonitor) {
this.pubSubMode = Boolean.FALSE;
con = createConnection();
}
if (!(con instanceof QueueConnection)) {
throw new jakarta.jms.IllegalStateException("This SingleConnectionFactory does not hold a QueueConnection but rather: " + con);
}
return ((QueueConnection) con);
}
use of jakarta.jms.QueueConnection in project spring-framework by spring-projects.
the class TransactionAwareConnectionFactoryProxy method createQueueConnection.
@Override
public QueueConnection createQueueConnection() throws JMSException {
ConnectionFactory target = getTargetConnectionFactory();
if (!(target instanceof QueueConnectionFactory)) {
throw new jakarta.jms.IllegalStateException("'targetConnectionFactory' is no QueueConnectionFactory");
}
QueueConnection targetConnection = ((QueueConnectionFactory) target).createQueueConnection();
return (QueueConnection) getTransactionAwareConnectionProxy(targetConnection);
}
use of jakarta.jms.QueueConnection in project spring-framework by spring-projects.
the class SingleConnectionFactoryTests method testWithQueueConnection.
@Test
public void testWithQueueConnection() throws JMSException {
Connection con = mock(QueueConnection.class);
SingleConnectionFactory scf = new SingleConnectionFactory(con);
QueueConnection con1 = scf.createQueueConnection();
con1.start();
con1.stop();
con1.close();
QueueConnection con2 = scf.createQueueConnection();
con2.start();
con2.stop();
con2.close();
// should trigger actual close
scf.destroy();
verify(con, times(2)).start();
verify(con, times(2)).stop();
verify(con).close();
verifyNoMoreInteractions(con);
}
use of jakarta.jms.QueueConnection in project spring-framework by spring-projects.
the class SingleConnectionFactoryTests method testCachingConnectionFactoryWithQueueConnectionFactoryAndJms102Usage.
@Test
public void testCachingConnectionFactoryWithQueueConnectionFactoryAndJms102Usage() throws JMSException {
QueueConnectionFactory cf = mock(QueueConnectionFactory.class);
QueueConnection con = mock(QueueConnection.class);
QueueSession txSession = mock(QueueSession.class);
QueueSession nonTxSession = mock(QueueSession.class);
given(cf.createQueueConnection()).willReturn(con);
given(con.createQueueSession(true, Session.AUTO_ACKNOWLEDGE)).willReturn(txSession);
given(txSession.getTransacted()).willReturn(true);
given(con.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE)).willReturn(nonTxSession);
CachingConnectionFactory scf = new CachingConnectionFactory(cf);
scf.setReconnectOnException(false);
Connection con1 = scf.createQueueConnection();
Session session1 = con1.createSession(true, Session.AUTO_ACKNOWLEDGE);
session1.rollback();
session1.close();
session1 = con1.createSession(false, Session.CLIENT_ACKNOWLEDGE);
session1.close();
con1.start();
QueueConnection con2 = scf.createQueueConnection();
Session session2 = con2.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
session2.close();
session2 = con2.createSession(true, Session.AUTO_ACKNOWLEDGE);
session2.getTransacted();
// should lead to rollback
session2.close();
con2.start();
con1.close();
con2.close();
// should trigger actual close
scf.destroy();
verify(txSession).rollback();
verify(txSession).close();
verify(nonTxSession).close();
verify(con).start();
verify(con).stop();
verify(con).close();
}
use of jakarta.jms.QueueConnection in project spring-framework by spring-projects.
the class SingleConnectionFactoryTests method testWithQueueConnectionFactoryAndJms11Usage.
@Test
public void testWithQueueConnectionFactoryAndJms11Usage() throws JMSException {
QueueConnectionFactory cf = mock(QueueConnectionFactory.class);
QueueConnection con = mock(QueueConnection.class);
given(cf.createConnection()).willReturn(con);
SingleConnectionFactory scf = new SingleConnectionFactory(cf);
Connection con1 = scf.createConnection();
Connection con2 = scf.createConnection();
con1.start();
con2.start();
con1.close();
con2.close();
// should trigger actual close
scf.destroy();
verify(con).start();
verify(con).stop();
verify(con).close();
verifyNoMoreInteractions(con);
}
Aggregations