use of org.apache.activemq.ActiveMQConnectionFactory in project camel by apache.
the class Sjms2EndpointNameOverrideTest method createCamelContext.
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
Sjms2Component component = new Sjms2Component();
component.setConnectionCount(1);
component.setConnectionFactory(connectionFactory);
camelContext.addComponent(BEAN_NAME, component);
return camelContext;
}
use of org.apache.activemq.ActiveMQConnectionFactory in project meteo by pierre.
the class AMQSubscriber method connect.
private void connect() throws JMSException {
String url = String.format("%s://%s:%d", amqConfig.getProtocol(), amqConfig.getHost(), amqConfig.getPort());
log.info("Connecting to: " + url);
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(amqConfig.getUsername(), amqConfig.getPassword(), url);
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(session.createTopic(amqConfig.getTopic()));
consumer.setMessageListener(listener);
log.info("Connected!");
}
use of org.apache.activemq.ActiveMQConnectionFactory in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testActiveMQOverriddenRemoteHost.
@Test
public void testActiveMQOverriddenRemoteHost() {
load(TestConfiguration.class, "spring.activemq.brokerUrl:tcp://remote-host:10000");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
ActiveMQConnectionFactory connectionFactory = this.context.getBean(ActiveMQConnectionFactory.class);
assertThat(jmsTemplate).isNotNull();
assertThat(connectionFactory).isNotNull();
assertThat(connectionFactory).isEqualTo(jmsTemplate.getConnectionFactory());
assertThat(((ActiveMQConnectionFactory) jmsTemplate.getConnectionFactory()).getBrokerURL()).isEqualTo("tcp://remote-host:10000");
}
use of org.apache.activemq.ActiveMQConnectionFactory in project play-cookbook by spinscale.
the class ActiveMqPlugin method onApplicationStart.
@Override
public void onApplicationStart() {
Logger.info("ActiveMQ Plugin started");
try {
List<Class> jobClasses = new ArrayList<Class>();
for (ApplicationClass applicationClass : Play.classes.getAssignableClasses(ActiveMqJob.class)) {
if (Job.class.isAssignableFrom(applicationClass.javaClass)) {
jobClasses.add(applicationClass.javaClass);
}
}
MessageListener listener = new ActiveMqConsumer(jobClasses);
connectionFactory = new ActiveMQConnectionFactory();
// receive
receiveConnection = connectionFactory.createTopicConnection();
receiveConnection.start();
receiveSession = receiveConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
receiveTopic = receiveSession.createTopic("playMessages");
receiveSubscriber = receiveSession.createSubscriber(receiveTopic);
receiveSubscriber.setMessageListener(listener);
// send
sendingConnection = connectionFactory.createTopicConnection();
sendingConnection.start();
sendingSession = sendingConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
sendingTopic = sendingSession.createTopic("playMessages");
sendingPublisher = sendingSession.createPublisher(sendingTopic);
} catch (Exception e) {
Logger.error(e, "Could not start activemq broker");
}
}
use of org.apache.activemq.ActiveMQConnectionFactory in project play-cookbook by spinscale.
the class ActiveMqTest method initialize.
@Before
public void initialize() throws Exception {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_USER, ActiveMQConnection.DEFAULT_PASSWORD, ActiveMQConnection.DEFAULT_BROKER_URL);
receiveConnection = connectionFactory.createTopicConnection();
receiveConnection.start();
receiveSession = receiveConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
receiveTopic = receiveSession.createTopic("playMessages");
receiveSubscriber = receiveSession.createSubscriber(receiveTopic);
sendingConnection = connectionFactory.createTopicConnection();
sendingConnection.start();
sendingSession = sendingConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
sendingTopic = sendingSession.createTopic("playMessages");
sendingPublisher = sendingSession.createPublisher(sendingTopic);
ChatRoom.clean();
}
Aggregations