Java Code Examples for org.apache.camel.CamelContext#addComponent()
The following examples show how to use
org.apache.camel.CamelContext#addComponent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWSS3RawOptionsTest.java From syndesis with Apache License 2.0 | 6 votes |
@Override protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); camelContext.setAutoStartup(false); camelContext.addComponent("aws-s3", new S3Component() { @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { final S3Configuration configuration = new S3Configuration(); setProperties(configuration, parameters); return new S3Endpoint(uri, this, configuration) { @Override public void doStart() throws Exception { // don't let the endpoint to start as it would try to // process the keys } }; } }); return camelContext; }
Example 2
Source File: RollbackTest.java From camel-cookbook-examples with Apache License 2.0 | 6 votes |
@Override protected CamelContext createCamelContext() throws Exception { SimpleRegistry registry = new SimpleRegistry(); DataSource auditDataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql"); DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(auditDataSource); registry.put("transactionManager", transactionManager); SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy(); propagationRequired.setTransactionManager(transactionManager); propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED"); registry.put("PROPAGATION_REQUIRED", propagationRequired); auditLogDao = new AuditLogDao(auditDataSource); CamelContext camelContext = new DefaultCamelContext(registry); SqlComponent sqlComponent = new SqlComponent(); sqlComponent.setDataSource(auditDataSource); camelContext.addComponent("sql", sqlComponent); return camelContext; }
Example 3
Source File: IdempotentConsumerInTransactionTest.java From camel-cookbook-examples with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { SimpleRegistry registry = new SimpleRegistry(); auditDataSource = EmbeddedDataSourceFactory.getDataSource("sql/schema.sql"); registry.put("auditDataSource", auditDataSource); DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(auditDataSource); registry.put("transactionManager", transactionManager); SpringTransactionPolicy propagationRequired = new SpringTransactionPolicy(); propagationRequired.setTransactionManager(transactionManager); propagationRequired.setPropagationBehaviorName("PROPAGATION_REQUIRED"); registry.put("PROPAGATION_REQUIRED", propagationRequired); auditLogDao = new AuditLogDao(auditDataSource); TransactionTemplate transactionTemplate = new TransactionTemplate(); transactionTemplate.setTransactionManager(transactionManager); transactionTemplate.setPropagationBehaviorName("PROPAGATION_REQUIRES_NEW"); idempotentRepository = new JdbcMessageIdRepository(auditDataSource, transactionTemplate, "ws"); CamelContext camelContext = new DefaultCamelContext(registry); SqlComponent sqlComponent = new SqlComponent(); sqlComponent.setDataSource(auditDataSource); camelContext.addComponent("sql", sqlComponent); return camelContext; }
Example 4
Source File: AbstractHiWorldTestSupport.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { final CamelContext context = super.createCamelContext(); // read HiWorld component configuration from TEST_OPTIONS_PROPERTIES final Properties properties = new Properties(); try { properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES)); } catch (Exception e) { throw new IOException(String.format("%s could not be loaded: %s", TEST_OPTIONS_PROPERTIES, e.getMessage()), e); } Map<String, Object> options = new HashMap<String, Object>(); for (Map.Entry<Object, Object> entry : properties.entrySet()) { options.put(entry.getKey().toString(), entry.getValue()); } final HiWorldConfiguration configuration = new HiWorldConfiguration(); IntrospectionSupport.setProperties(configuration, options); // add HiWorldComponent to Camel context final HiWorldComponent component = new HiWorldComponent(context); component.setConfiguration(configuration); context.addComponent("hiworld", component); return context; }
Example 5
Source File: ElasticsearchIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
private CamelContext createCamelContext() throws InterruptedException { CamelContext camelctx = new DefaultCamelContext(); ElasticsearchComponent elasticsearchComponent = new ElasticsearchComponent(); elasticsearchComponent.setHostAddresses(getElasticsearchHost()); camelctx.addComponent("elasticsearch-rest", elasticsearchComponent); return camelctx; }
Example 6
Source File: OrderRouterWithRecipientListTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example 7
Source File: ERPMain.java From camelinaction with Apache License 2.0 | 5 votes |
private void start() throws Exception { CamelContext camel = new DefaultCamelContext(); // add our custom component camel.addComponent("erp", new ERPComponent()); // add the route camel.addRoutes(new ERPRoute()); // and start Camel camel.start(); }
Example 8
Source File: AuditTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { CamelContext context = super.createCamelContext(); // simulate JMS with the SEDA component context.addComponent("jms", context.getComponent("seda")); return context; }
Example 9
Source File: LogEIPTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { CamelContext context = super.createCamelContext(); // simulate JMS with the SEDA component context.addComponent("jms", context.getComponent("seda")); return context; }
Example 10
Source File: FacebookIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testFacebookComponent() throws Exception { FacebookComponent component = new FacebookComponent(); FacebookConfiguration configuration = component.getConfiguration(); String baseURL = "http://localhost:8080/camel-facebook-tests/fake-facebook-api"; configuration.setClientURL(baseURL); configuration.setOAuthAccessTokenURL(baseURL + "/oauth-token"); configuration.setRestBaseURL(baseURL + "/rest"); CamelContext camelctx = new DefaultCamelContext(); camelctx.addComponent("facebook", component); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .toF("facebook://getTestUsers?oAuthAppId=%s&oAuthAppSecret=%s&appId=%s", FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, FACEBOOK_APP_ID); } }); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); PagableList testUserList = template.requestBody("direct:start", null, PagableList.class); Assert.assertNotNull("Facebook app test user list was null", testUserList); } finally { camelctx.close(); } }
Example 11
Source File: LogComponentTest.java From camelinaction with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { CamelContext context = super.createCamelContext(); // simulate JMS with the SEDA component context.addComponent("jms", context.getComponent("seda")); return context; }
Example 12
Source File: JdbcTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); camelContext.addComponent("jms", jmsComponentClientAcknowledge(connectionFactory)); return camelContext; }
Example 13
Source File: HazelcastMapConsumerIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
private CamelContext createCamelContext() throws Exception { MockitoAnnotations.initMocks(this); CamelContext context = new DefaultCamelContext(); context.addRoutes(createRouteBuilder()); HazelcastMapComponent map = new HazelcastMapComponent(context); map.setHazelcastInstance(hazelcastInstance); context.addComponent("hazelcast-map", map); trainHazelcastInstance(hazelcastInstance); return context; }
Example 14
Source File: ClientCamelJMSITest.java From hawkular-apm with Apache License 2.0 | 5 votes |
@Override protected void initContext(CamelContext context) throws Exception { ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); // Note we can explicit name the component context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); template = context.createProducerTemplate(); super.initContext(context); }
Example 15
Source File: FtpToJMSWithProcessorExample.java From camelinaction2 with Apache License 2.0 | 5 votes |
public static void main(String args[]) throws Exception { // create CamelContext CamelContext context = new DefaultCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { from("ftp://rider.com/orders?username=rider&password=secret"). process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("We just downloaded: " + exchange.getIn().getHeader("CamelFileName")); } }). to("jms:incomingOrders"); } }); // start the route and let it do its work context.start(); Thread.sleep(10000); // stop the CamelContext context.stop(); }
Example 16
Source File: MinaCustomCodecTest.java From camelinaction with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); camelContext.addComponent("jms", jmsComponentClientAcknowledge(connectionFactory)); return camelContext; }
Example 17
Source File: MinaTcpTest.java From camelinaction with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { CamelContext camelContext = super.createCamelContext(); ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); camelContext.addComponent("jms", jmsComponentClientAcknowledge(connectionFactory)); return camelContext; }
Example 18
Source File: OrderRouterWithParallelMulticastTest.java From camelinaction2 with Apache License 2.0 | 5 votes |
@Override protected CamelContext createCamelContext() throws Exception { // create CamelContext CamelContext camelContext = super.createCamelContext(); // connect to embedded ActiveMQ JMS broker ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); camelContext.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); return camelContext; }
Example 19
Source File: KnativeSourceRoutesLoaderTest.java From camel-k-runtime with Apache License 2.0 | 4 votes |
@ParameterizedTest @MethodSource("parameters") public void testWrapLoader(String uri) throws Exception { LOGGER.info("uri: {}", uri); final String data = UUID.randomUUID().toString(); final TestRuntime runtime = new TestRuntime(); KnativeComponent component = new KnativeComponent(); component.setEnvironment(KnativeEnvironment.on( KnativeEnvironment.endpoint(Knative.EndpointKind.sink, "sink", "localhost", runtime.port) )); CamelContext context = runtime.getCamelContext(); context.addComponent(KnativeConstants.SCHEME, component); Source source = Sources.fromURI(uri); SourceLoader loader = RoutesConfigurer.load(runtime, source); assertThat(loader.getSupportedLanguages()).contains(source.getLanguage()); assertThat(runtime.builders).hasSize(1); try { context.addRoutes(runtime.builders.get(0)); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { fromF("platform-http:/") .routeId("http") .to("mock:result"); } }); context.start(); List<RouteDefinition> definitions = context.adapt(ModelCamelContext.class).getRouteDefinitions(); assertThat(definitions).hasSize(2); assertThat(definitions).first().satisfies(d -> { assertThat(d.getOutputs()).last().hasFieldOrPropertyWithValue( "endpointUri", "knative://endpoint/sink" ); }); MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class); mock.expectedMessageCount(1); mock.expectedBodiesReceived(data); context.createFluentProducerTemplate() .to("direct:start") .withHeader("MyHeader", data) .send(); mock.assertIsSatisfied(); } finally { context.stop(); } }
Example 20
Source File: CamelConsumerTemplate.java From hazelcastmq with Apache License 2.0 | 4 votes |
@Override public void start() throws Exception { // Create a Hazelcast instance. Config config = new Config(); config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false); HazelcastInstance hazelcast = Hazelcast.newHazelcastInstance(config); try { // Create the HazelcaseMQ instance. HazelcastMQConfig mqConfig = new HazelcastMQConfig(); mqConfig.setHazelcastInstance(hazelcast); HazelcastMQInstance mqInstance = HazelcastMQ .newHazelcastMQInstance(mqConfig); // Create the camel component. HazelcastMQCamelConfig mqCamelConfig = new HazelcastMQCamelConfig(); mqCamelConfig.setHazelcastMQInstance(mqInstance); HazelcastMQCamelComponent mqCamelComponent = new HazelcastMQCamelComponent(); mqCamelComponent.setConfiguration(mqCamelConfig); // Create the Camel context. This could be done via a Spring XML file. CamelContext camelContext = new DefaultCamelContext(); camelContext.addComponent("hazelcastmq", mqCamelComponent); camelContext.start(); // Send a message to a queue. try (HazelcastMQContext mqContext = mqInstance.createContext()) { HazelcastMQProducer mqProducer = mqContext.createProducer(); mqProducer.send("/queue/primo.test", "Hello World!"); } // Create a Camel polling consumer. ConsumerTemplate consumerTemplate = camelContext.createConsumerTemplate(); String body = consumerTemplate. receiveBody("hazelcastmq:queue:primo.test", 2000, String.class); if (body == null) { log.warn("Did not get expected message!"); } else { log.info("Got message on queue: " + body); } consumerTemplate.stop(); camelContext.stop(); } finally { // Shutdown Hazelcast. hazelcast.getLifecycleService().shutdown(); } }