use of org.apache.qpid.jms.JmsConnectionFactory in project syndesis by syndesisio.
the class AMQPConnector method lookupComponent.
private AMQPComponent lookupComponent() {
final CamelContext context = getCamelContext();
final List<String> names = context.getComponentNames();
if (ObjectHelper.isEmpty(names)) {
return null;
}
// lookup existing component with same configuration
for (String name : names) {
Component cmp = context.getComponent(name, false, false);
if (cmp instanceof AMQPComponent) {
final ConnectionFactory factory;
try {
factory = ((AMQPComponent) cmp).getConfiguration().getConnectionFactory();
} catch (IllegalArgumentException e) {
// ignore components without a connection factory
continue;
}
if (factory instanceof JmsConnectionFactory) {
JmsConnectionFactory jmsConnectionFactory = (JmsConnectionFactory) factory;
if (!Objects.equals(connectionUri, jmsConnectionFactory.getRemoteURI())) {
continue;
}
if (!Objects.equals(username, jmsConnectionFactory.getUsername())) {
continue;
}
if (!Objects.equals(password, jmsConnectionFactory.getPassword())) {
continue;
}
if (!Objects.equals(clientId, jmsConnectionFactory.getClientID())) {
continue;
}
return (AMQPComponent) cmp;
}
}
}
return null;
}
use of org.apache.qpid.jms.JmsConnectionFactory in project camel by apache.
the class AMQPComponent method amqpComponent.
public static AMQPComponent amqpComponent(String uri) {
JmsConnectionFactory connectionFactory = new JmsConnectionFactory(uri);
connectionFactory.setTopicPrefix("topic://");
return new AMQPComponent(connectionFactory);
}
use of org.apache.qpid.jms.JmsConnectionFactory in project camel by apache.
the class AMQPComponent method doStart.
// Life-cycle
@Override
protected void doStart() throws Exception {
Set<AMQPConnectionDetails> connectionDetails = getCamelContext().getRegistry().findByType(AMQPConnectionDetails.class);
if (connectionDetails.size() == 1) {
AMQPConnectionDetails details = connectionDetails.iterator().next();
JmsConnectionFactory connectionFactory = new JmsConnectionFactory(details.username(), details.password(), details.uri());
connectionFactory.setTopicPrefix("topic://");
setConnectionFactory(connectionFactory);
}
super.doStart();
}
use of org.apache.qpid.jms.JmsConnectionFactory in project activemq-artemis by apache.
the class DivertTopicToQueueTest method divertTopicToQueueWithSelectorTest.
@Test
public void divertTopicToQueueWithSelectorTest() throws Exception {
final String address1 = "bss.order.workorderchanges.v1.topic";
final String address2 = "bss.order.Consumer.cbma.workorderchanges.v1.queue";
final String address3 = "bss.order.Consumer.pinpoint.workorderchanges.v1.queue";
DivertConfiguration dc1 = new DivertConfiguration().setName("WorkOrderChangesCBMA-Divert").setRoutingName("WorkOrderChangesCBMA-Divert").setAddress(address1).setForwardingAddress(address2).setExclusive(false).setRoutingType(DivertConfigurationRoutingType.ANYCAST);
DivertConfiguration dc2 = new DivertConfiguration().setName("WorkOrderChangesPinpoint-Divert").setRoutingName("WorkOrderChangesPinpoint-Divert").setAddress(address1).setForwardingAddress(address3).setExclusive(false).setRoutingType(DivertConfigurationRoutingType.ANYCAST);
server.deployDivert(dc1);
server.deployDivert(dc2);
JmsConnectionFactory factory = new JmsConnectionFactory(getBrokerQpidJMSConnectionURI());
Connection connection = factory.createConnection(null, null);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
javax.jms.Topic topicSource = session.createTopic(address1);
javax.jms.Queue queueTarget = session.createQueue(address2);
javax.jms.Queue queueTarget2 = session.createQueue(address3);
final MessageProducer producer = session.createProducer(topicSource);
final TextMessage message = session.createTextMessage("Hello");
message.setStringProperty("filename", "BILHANDLE");
connection.start();
String selector = "filename='BILHANDLE'";
final MessageConsumer consumer = session.createConsumer(queueTarget, selector);
final MessageConsumer consumer2 = session.createConsumer(queueTarget2, selector);
producer.send(message);
TextMessage receivedMessage = (TextMessage) consumer.receive(1000);
TextMessage receivedMessage2 = (TextMessage) consumer2.receive(1000);
Assert.assertNotNull(receivedMessage);
Assert.assertNotNull(receivedMessage2);
connection.close();
}
use of org.apache.qpid.jms.JmsConnectionFactory in project activemq-artemis by apache.
the class JMSClientTestSupport method createConnection.
private Connection createConnection(URI remoteURI, String username, String password, String clientId, boolean start) throws JMSException {
JmsConnectionFactory factory = new JmsConnectionFactory(remoteURI);
Connection connection = trackJMSConnection(factory.createConnection(username, password));
connection.setExceptionListener(new ExceptionListener() {
@Override
public void onException(JMSException exception) {
exception.printStackTrace();
}
});
if (clientId != null && !clientId.isEmpty()) {
connection.setClientID(clientId);
}
if (start) {
connection.start();
}
return connection;
}
Aggregations