use of org.apache.activemq.ActiveMQConnectionFactory in project quickstarts by jboss-switchyard.
the class JMSClient method sendToActiveMQ.
private static void sendToActiveMQ(String value) throws Exception {
ConnectionFactory cf = new ActiveMQConnectionFactory(AMQ_USER, AMQ_PASSWD, AMQ_BROKER_URL);
Connection conn = cf.createConnection();
try {
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
final MessageProducer producer = session.createProducer(session.createQueue(REQUEST_NAME));
final MessageConsumer consumer = session.createConsumer(session.createQueue(REPLY_NAME));
conn.start();
producer.send(session.createTextMessage(createPayload(value)));
System.out.println("Message sent. Waiting for reply ...");
Message message = consumer.receive(3000);
String reply = ((TextMessage) message).getText();
System.out.println("REPLY: \n" + reply);
} finally {
conn.close();
}
}
use of org.apache.activemq.ActiveMQConnectionFactory in project pinpoint by naver.
the class TestBroker method start.
boolean start() throws Exception {
this.brokerService.start();
// but this method was only introduced in 5.3.0
for (Map.Entry<String, ActiveMQConnectionFactory> e : this.connectionFactories.entrySet()) {
String connectUri = e.getKey();
ActiveMQConnectionFactory connectionFactory = e.getValue();
ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
connection.setClientID("client_" + connectUri);
connection.start();
this.connections.put(connectUri, connection);
}
return true;
}
use of org.apache.activemq.ActiveMQConnectionFactory in project spring-boot by spring-projects.
the class ActiveMQAutoConfigurationTests method brokerIsEmbeddedByDefault.
@Test
public void brokerIsEmbeddedByDefault() {
load(EmptyConfiguration.class);
ConnectionFactory connectionFactory = this.context.getBean(ConnectionFactory.class);
assertThat(connectionFactory).isInstanceOf(ActiveMQConnectionFactory.class);
String brokerUrl = ((ActiveMQConnectionFactory) connectionFactory).getBrokerURL();
assertThat(brokerUrl).isEqualTo("vm://localhost?broker.persistent=false");
}
use of org.apache.activemq.ActiveMQConnectionFactory in project spring-boot by spring-projects.
the class ActiveMQPropertiesTests method setTrustedPackages.
@Test
public void setTrustedPackages() {
this.properties.getPackages().setTrustAll(false);
this.properties.getPackages().getTrusted().add("trusted.package");
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactoryFactory(this.properties).createConnectionFactory(ActiveMQConnectionFactory.class);
assertThat(factory.isTrustAllPackages()).isEqualTo(false);
assertThat(factory.getTrustedPackages().size()).isEqualTo(1);
assertThat(factory.getTrustedPackages().get(0)).isEqualTo("trusted.package");
}
use of org.apache.activemq.ActiveMQConnectionFactory in project spring-boot by spring-projects.
the class JmsAutoConfigurationTests method testActiveMQOverriddenPool.
@Test
public void testActiveMQOverriddenPool() {
load(TestConfiguration.class, "spring.activemq.pool.enabled:true");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
PooledConnectionFactory pool = this.context.getBean(PooledConnectionFactory.class);
assertThat(jmsTemplate).isNotNull();
assertThat(pool).isNotNull();
assertThat(pool).isEqualTo(jmsTemplate.getConnectionFactory());
ActiveMQConnectionFactory factory = (ActiveMQConnectionFactory) pool.getConnectionFactory();
assertThat(factory.getBrokerURL()).isEqualTo(ACTIVEMQ_EMBEDDED_URL);
}
Aggregations