use of org.apache.qpid.jms.JmsConnectionFactory in project camel by apache.
the class AMQPComponent method amqp10Component.
// Factory methods
/**
* Use {@code amqpComponent(String uri)} instead.
*/
@Deprecated
public static AMQPComponent amqp10Component(String uri) throws MalformedURLException {
JmsConnectionFactory connectionFactory = new JmsConnectionFactory(uri);
connectionFactory.setTopicPrefix("topic://");
return new AMQPComponent(connectionFactory);
}
use of org.apache.qpid.jms.JmsConnectionFactory in project ddf by codice.
the class AmqpProducerConsumerExample method createCamelContext.
private void createCamelContext() throws Exception {
CamelContext camelContext = getContext();
JmsConnectionFactory connectionFactory = new JmsConnectionFactory("admin", "admin", "amqps://localhost:5671");
JmsComponent jms = JmsComponent.jmsComponent(connectionFactory);
AMQPComponent amqp = new AMQPComponent(connectionFactory);
camelContext.addComponent("jms", jms);
camelContext.addComponent("amqp", amqp);
}
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 activemq-artemis by apache.
the class ConsumerTest method createFactory.
private ConnectionFactory createFactory(int protocol) {
switch(protocol) {
case // core protocol
1:
// core protocol
ActiveMQConnectionFactory coreCF = new ActiveMQConnectionFactory();
coreCF.setCompressLargeMessage(true);
coreCF.setMinLargeMessageSize(10 * 1024);
return coreCF;
// amqp
case 2:
return new JmsConnectionFactory("amqp://localhost:61616");
// openwire
case 3:
return new org.apache.activemq.ActiveMQConnectionFactory("tcp://localhost:61616");
default:
return null;
}
}
use of org.apache.qpid.jms.JmsConnectionFactory in project activemq-artemis by apache.
the class TopicDurableTests method testMessageDurableSubscription.
@Test
public void testMessageDurableSubscription() throws Exception {
JmsConnectionFactory connectionFactory = new JmsConnectionFactory(getBrokerQpidJMSConnectionURI() + "?jms.clientID=jmsTopicClient");
Connection connection = connectionFactory.createConnection();
connection.start();
System.out.println("testMessageDurableSubscription");
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Topic testTopic = session.createTopic("jmsTopic");
String sub1ID = "sub1DurSub";
String sub2ID = "sub2DurSub";
MessageConsumer subscriber1 = session.createDurableSubscriber(testTopic, sub1ID);
MessageConsumer subscriber2 = session.createDurableSubscriber(testTopic, sub2ID);
MessageProducer messageProducer = session.createProducer(testTopic);
int count = 100;
String batchPrefix = "First";
List<Message> listMsgs = generateMessages(session, batchPrefix, count);
sendMessages(messageProducer, listMsgs);
System.out.println("First batch messages sent");
List<Message> recvd1 = receiveMessages(subscriber1, count);
List<Message> recvd2 = receiveMessages(subscriber2, count);
assertThat(recvd1.size(), is(count));
assertMessageContent(recvd1, batchPrefix);
System.out.println(sub1ID + " :First batch messages received");
assertThat(recvd2.size(), is(count));
assertMessageContent(recvd2, batchPrefix);
System.out.println(sub2ID + " :First batch messages received");
subscriber1.close();
System.out.println(sub1ID + " : closed");
batchPrefix = "Second";
listMsgs = generateMessages(session, batchPrefix, count);
sendMessages(messageProducer, listMsgs);
System.out.println("Second batch messages sent");
recvd2 = receiveMessages(subscriber2, count);
assertThat(recvd2.size(), is(count));
assertMessageContent(recvd2, batchPrefix);
System.out.println(sub2ID + " :Second batch messages received");
subscriber1 = session.createDurableSubscriber(testTopic, sub1ID);
System.out.println(sub1ID + " :connected");
recvd1 = receiveMessages(subscriber1, count);
assertThat(recvd1.size(), is(count));
assertMessageContent(recvd1, batchPrefix);
System.out.println(sub1ID + " :Second batch messages received");
subscriber1.close();
subscriber2.close();
session.unsubscribe(sub1ID);
session.unsubscribe(sub2ID);
}
Aggregations