use of org.apache.qpid.jms.JmsConnectionFactory in project activemq-artemis by apache.
the class OpenWireToAMQPTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
server = createServer(true, true);
Configuration serverConfig = server.getConfiguration();
serverConfig.getAddressesSettings().put("#", new AddressSettings().setAutoCreateQueues(true).setAutoCreateAddresses(true).setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ")));
serverConfig.setSecurityEnabled(false);
server.start();
coreQueue = new SimpleString(queueName);
server.createQueue(coreQueue, RoutingType.ANYCAST, coreQueue, null, false, false);
qpidfactory = new JmsConnectionFactory("amqp://localhost:61616");
}
use of org.apache.qpid.jms.JmsConnectionFactory in project syndesis-qe by syndesisio.
the class JmsClientManager method initClient.
private JmsClient initClient() {
if (jmsClient == null) {
switch(protocol) {
case "tcp":
case "openwire":
ActiveMQConnectionFactory jmsFactory = new ActiveMQConnectionFactory();
jmsFactory.setBrokerURL(jmsUrl);
jmsFactory.setUserName(jmsUser);
jmsFactory.setPassword(jmsPass);
jmsClient = new JmsClient(jmsFactory);
break;
case "amqp":
JmsConnectionFactory jmsConnectionFactory = new JmsConnectionFactory(jmsUser, jmsPass, jmsUrl);
jmsClient = new JmsClient(jmsConnectionFactory);
break;
}
}
return jmsClient;
}
use of org.apache.qpid.jms.JmsConnectionFactory in project syndesis by syndesisio.
the class AMQPConnector method createDelegateComponent.
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
@Override
protected Optional<Component> createDelegateComponent(ComponentDefinition definition, Map<String, Object> options) throws Exception {
AMQPComponent delegate = lookupComponent();
if (delegate == null) {
// create and set ConnectionFactory on delegate
final AMQPUtil.ConnectionParameters connectionParameters = new AMQPUtil.ConnectionParameters(connectionUri, username, password, brokerCertificate, clientCertificate, skipCertificateCheck);
final JmsConnectionFactory connectionFactory = AMQPUtil.createConnectionFactory(connectionParameters);
connectionFactory.setClientID(clientId);
delegate = new AMQPComponent(connectionFactory);
}
return Optional.of(delegate);
}
use of org.apache.qpid.jms.JmsConnectionFactory in project syndesis by syndesisio.
the class AMQPUtil method createConnectionFactory.
public static JmsConnectionFactory createConnectionFactory(ConnectionParameters connectionParameters) {
final JmsConnectionFactory result;
final String connectionUri = connectionParameters.getConnectionUri();
if (!connectionUri.contains("amqps:")) {
result = new JmsConnectionFactory(connectionParameters.getUsername(), connectionParameters.getPassword(), connectionUri);
} else {
StringBuilder newConnectionUri = new StringBuilder(connectionUri);
if (connectionParameters.isSkipCertificateCheck()) {
if (!connectionUri.contains("transport.trustAll")) {
LOG.warn("Skipping Certificate check for AMQP Connection {}", connectionUri);
newConnectionUri.append(connectionUri.contains("?") ? "&" : "?").append("transport.trustAll=true&transport.verifyHost=false");
}
} else {
// add amqps connection certificates
final String clientCertificate = connectionParameters.getClientCertificate();
if (!ObjectHelper.isEmpty(clientCertificate)) {
// copy client certificate to a keystore using a random key
addKeyStoreParam(newConnectionUri, clientCertificate, "amqp-client", "key");
newConnectionUri.append("&transport.keyAlias=amqp-client");
}
final String brokerCertificate = connectionParameters.getBrokerCertificate();
if (!ObjectHelper.isEmpty(brokerCertificate)) {
// copy broker certificate to a keystore using a random key
addKeyStoreParam(newConnectionUri, brokerCertificate, "amqp-broker", "trust");
// possibly expose this property from connector in the future?
newConnectionUri.append("&transport.verifyHost=false");
}
}
result = new JmsConnectionFactory(connectionParameters.getUsername(), connectionParameters.getPassword(), newConnectionUri.toString());
}
return result;
}
use of org.apache.qpid.jms.JmsConnectionFactory in project syndesis by syndesisio.
the class AMQPVerifierExtension method verifyCredentials.
private void verifyCredentials(ResultBuilder builder, Map<String, Object> parameters) {
final String connectionUri = (String) parameters.get("connectionUri");
final String username = (String) parameters.get("username");
final String password = (String) parameters.get("password");
final boolean skipCertificateCheck = "true".equals(parameters.get("skipCertificateCheck"));
final String brokerCertificate = (String) parameters.get("brokerCertificate");
final String clientCertificate = (String) parameters.get("clientCertificate");
LOG.debug("Validating AMQP connection to {}", connectionUri);
final AMQPUtil.ConnectionParameters connectionParameters = new AMQPUtil.ConnectionParameters(connectionUri, username, password, brokerCertificate, clientCertificate, skipCertificateCheck);
JmsConnectionFactory connectionFactory = AMQPUtil.createConnectionFactory(connectionParameters);
Connection connection = null;
try {
// try to create and start the JMS connection
connection = connectionFactory.createConnection();
connection.start();
} catch (JMSException e) {
final Map<String, Object> redacted = new HashMap<>(parameters);
redacted.replace("password", "********");
LOG.warn("Unable to connect to AMQP Broker with parameters {}, Message: {}, error code: {}", redacted, e.getMessage(), e.getErrorCode(), e);
builder.error(ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.ILLEGAL_PARAMETER_VALUE, e.getMessage()).parameterKey("connectionUri").parameterKey("username").parameterKey("password").build());
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException ignored) {
// ignore
}
}
}
}
Aggregations