use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rabbitmq-jms-client by rabbitmq.
the class RabbitAPIConnectionFactory method getConnectionFactory.
@Override
public ConnectionFactory getConnectionFactory() {
RMQConnectionFactory rmqCF = new RMQConnectionFactory() {
private static final long serialVersionUID = 1L;
@Override
public Connection createConnection(String userName, String password) throws JMSException {
if (!testssl) {
this.setPort(RABBIT_PORT);
} else {
this.setPort(RABBIT_TLS_PORT);
}
return super.createConnection(userName, password);
}
};
if (testssl) {
try {
rmqCF.useSslProtocol();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
rmqCF.setQueueBrowserReadMax(qbrMax);
return rmqCF;
}
use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rabbitmq-jms-client by rabbitmq.
the class RabbitMqBasicQosIT method connection.
private QueueConnection connection(int qos) throws Exception {
RMQConnectionFactory connectionFactory = (RMQConnectionFactory) AbstractTestConnectionFactory.getTestConnectionFactory().getConnectionFactory();
connectionFactory.setChannelsQos(qos);
QueueConnection queueConnection = connectionFactory.createQueueConnection();
queueConnection.start();
return queueConnection;
}
use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rabbitmq-jms-client by rabbitmq.
the class RpcIT method setupRpcServer.
void setupRpcServer() throws Exception {
RMQConnectionFactory connectionFactory = (RMQConnectionFactory) AbstractTestConnectionFactory.getTestConnectionFactory().getConnectionFactory();
connectionFactory.setDeclareReplyToDestination(false);
serverConnection = connectionFactory.createConnection();
serverConnection.start();
Session session = serverConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(QUEUE_NAME);
drainQueue(session, queue);
session.close();
rpcServer = new RpcServer(serverConnection);
}
use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rabbitmq-jms-client by rabbitmq.
the class SslContextIT method defaultSslContextOverridesSetSslContext.
@Test
public void defaultSslContextOverridesSetSslContext() throws Exception {
RMQConnectionFactory connectionFactory = (RMQConnectionFactory) AbstractTestConnectionFactory.getTestConnectionFactory(true, 0).getConnectionFactory();
SSLContext defaultSslContext = createSslContext();
AlwaysTrustTrustManager defaultTrustManager = new AlwaysTrustTrustManager();
defaultSslContext.init(null, new TrustManager[] { defaultTrustManager }, null);
SSLContext.setDefault(defaultSslContext);
connectionFactory.useDefaultSslContext(true);
SSLContext sslContext = createSslContext();
AlwaysTrustTrustManager trustManager = new AlwaysTrustTrustManager();
sslContext.init(null, new TrustManager[] { trustManager }, null);
connectionFactory.useSslProtocol(sslContext);
connection = connectionFactory.createConnection();
assertTrue(defaultTrustManager.checkServerTrustedCallCount.get() >= 1, "TrustManager#checkServerTrusted must be called");
assertEquals(0, trustManager.checkServerTrustedCallCount.get());
}
use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rabbitmq-jms-client by rabbitmq.
the class SslContextIT method sslContextShouldBeUsedWhenExplicitlySet.
// https://github.com/rabbitmq/rabbitmq-jms-client/issues/12
// the set SSLContext isn't overridden
@Test
public void sslContextShouldBeUsedWhenExplicitlySet() throws Exception {
RMQConnectionFactory connectionFactory = (RMQConnectionFactory) AbstractTestConnectionFactory.getTestConnectionFactory(true, 0).getConnectionFactory();
connectionFactory.setUri("amqps://guest:guest@localhost:5671/%2f");
SSLContext sslContext = createSslContext();
AlwaysTrustTrustManager trustManager = new AlwaysTrustTrustManager();
sslContext.init(null, new TrustManager[] { trustManager }, null);
connectionFactory.useSslProtocol(sslContext);
connection = connectionFactory.createConnection();
assertTrue(trustManager.checkServerTrustedCallCount.get() >= 1, "TrustManager#checkServerTrusted must be called");
}
Aggregations