use of org.apache.camel.CamelContext in project camel by apache.
the class SjmsBatchConsumerTest method createCamelContext.
@Override
public CamelContext createCamelContext() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
registry.put("testStrategy", new ListAggregationStrategy());
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(broker.getTcpConnectorUri());
SjmsComponent sjmsComponent = new SjmsComponent();
sjmsComponent.setConnectionFactory(connectionFactory);
SjmsBatchComponent sjmsBatchComponent = new SjmsBatchComponent();
sjmsBatchComponent.setConnectionFactory(connectionFactory);
CamelContext context = new DefaultCamelContext(registry);
context.addComponent("sjms", sjmsComponent);
context.addComponent("sjms-batch", sjmsBatchComponent);
return context;
}
use of org.apache.camel.CamelContext in project camel by apache.
the class SjmsDestinationCreationStrategyTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = new DefaultCamelContext();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(brokerUri);
SjmsComponent component = new SjmsComponent();
component.setConnectionFactory(connectionFactory);
component.setDestinationCreationStrategy(new TestDestinationCreationStrategyTest());
camelContext.addComponent("sjms", component);
return camelContext;
}
use of org.apache.camel.CamelContext in project camel by apache.
the class AsyncConsumerFalseTest method createCamelContext.
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
camelContext.addComponent("async", new MyAsyncComponent());
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
SjmsComponent component = new SjmsComponent();
component.setConnectionFactory(connectionFactory);
camelContext.addComponent("sjms", component);
return camelContext;
}
use of org.apache.camel.CamelContext in project camel by apache.
the class CafeRouteSpringIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
applicationContext = new ClassPathXmlApplicationContext("META-INF/spring/camel-context.xml");
CamelContext camelContext = getCamelContext();
template = camelContext.createProducerTemplate();
}
use of org.apache.camel.CamelContext in project camel by apache.
the class CamelJmsToFileExample method main.
public static void main(String[] args) throws Exception {
// START SNIPPET: e1
CamelContext context = new DefaultCamelContext();
// END SNIPPET: e1
// Set up the ActiveMQ JMS Components
// START SNIPPET: e2
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
// Note we can explicit name the component
context.addComponent("test-jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
// END SNIPPET: e2
// Add some configuration by hand ...
// START SNIPPET: e3
context.addRoutes(new RouteBuilder() {
public void configure() {
from("test-jms:queue:test.queue").to("file://test");
}
});
// END SNIPPET: e3
// Camel template - a handy class for kicking off exchanges
// START SNIPPET: e4
ProducerTemplate template = context.createProducerTemplate();
// END SNIPPET: e4
// Now everything is set up - lets start the context
context.start();
// START SNIPPET: e5
for (int i = 0; i < 10; i++) {
template.sendBody("test-jms:queue:test.queue", "Test Message: " + i);
}
// END SNIPPET: e5
// wait a bit and then stop
Thread.sleep(1000);
context.stop();
}
Aggregations