Search in sources :

Example 61 with ActiveMQConnectionFactory

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;
}
Also used : CamelContext(org.apache.camel.CamelContext) ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory)

Example 62 with ActiveMQConnectionFactory

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!");
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory)

Example 63 with ActiveMQConnectionFactory

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");
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.Test)

Example 64 with ActiveMQConnectionFactory

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");
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ArrayList(java.util.ArrayList) MessageListener(javax.jms.MessageListener) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass) JMSException(javax.jms.JMSException)

Example 65 with ActiveMQConnectionFactory

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();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) Before(org.junit.Before)

Aggregations

ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)69 CamelContext (org.apache.camel.CamelContext)25 SjmsComponent (org.apache.camel.component.sjms.SjmsComponent)16 ConnectionFactory (javax.jms.ConnectionFactory)11 Test (org.junit.Test)10 PooledConnectionFactory (org.apache.activemq.pool.PooledConnectionFactory)9 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)8 JmsTemplate (org.springframework.jms.core.JmsTemplate)7 Connection (javax.jms.Connection)6 Session (javax.jms.Session)6 Before (org.junit.Before)5 MessageProducer (javax.jms.MessageProducer)4 RouteBuilder (org.apache.camel.builder.RouteBuilder)4 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)4 File (java.io.File)3 Destination (javax.jms.Destination)3 JMSException (javax.jms.JMSException)3 MessageConsumer (javax.jms.MessageConsumer)3 BrokerService (org.apache.activemq.broker.BrokerService)3 ArrayList (java.util.ArrayList)2