Dataset Preview
Full Screen
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed
Error code:   DatasetGenerationError
Exception:    ArrowInvalid
Message:      JSON parse error: Column() changed from object to array in row 0
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/packaged_modules/json/json.py", line 153, in _generate_tables
                  df = pd.read_json(f, dtype_backend="pyarrow")
                File "/src/services/worker/.venv/lib/python3.9/site-packages/pandas/io/json/_json.py", line 815, in read_json
                  return json_reader.read()
                File "/src/services/worker/.venv/lib/python3.9/site-packages/pandas/io/json/_json.py", line 1025, in read
                  obj = self._get_object_parser(self.data)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/pandas/io/json/_json.py", line 1051, in _get_object_parser
                  obj = FrameParser(json, **kwargs).parse()
                File "/src/services/worker/.venv/lib/python3.9/site-packages/pandas/io/json/_json.py", line 1187, in parse
                  self._parse()
                File "/src/services/worker/.venv/lib/python3.9/site-packages/pandas/io/json/_json.py", line 1403, in _parse
                  ujson_loads(json, precise_float=self.precise_float), dtype=None
              ValueError: Unexpected character found when decoding array value (2)
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1997, in _prepare_split_single
                  for _, table in generator:
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/packaged_modules/json/json.py", line 156, in _generate_tables
                  raise e
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/packaged_modules/json/json.py", line 130, in _generate_tables
                  pa_table = paj.read_json(
                File "pyarrow/_json.pyx", line 308, in pyarrow._json.read_json
                File "pyarrow/error.pxi", line 154, in pyarrow.lib.pyarrow_internal_check_status
                File "pyarrow/error.pxi", line 91, in pyarrow.lib.check_status
              pyarrow.lib.ArrowInvalid: JSON parse error: Column() changed from object to array in row 0
              
              The above exception was the direct cause of the following exception:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1396, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1045, in convert_to_parquet
                  builder.download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1029, in download_and_prepare
                  self._download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1124, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1884, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2040, in _prepare_split_single
                  raise DatasetGenerationError("An error occurred while generating the dataset") from e
              datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

Instruction
string
Input
string
Output
string
apache-camel
I am trying to connect to salesforce using Apache Camel salesforce component. Here is a very simple route I am trying to start: <code>@Override public void configure() throws Exception { from("salesforce:event/Case__e") .to("mock:end"); } </code> When trying to start it I am getting an obvious error saying I did not specify a client id: <code>Caused by: java.lang.IllegalArgumentException: clientId must be specified at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:149) ~[camel-util-3.16.0.jar:3.16.0] at org.apache.camel.component.salesforce.SalesforceLoginConfig.validate(SalesforceLoginConfig.java:238) ~[camel-salesforce-3.16.0.jar:3.16.0] </code> That makes perfectly sense as according to Camel docs clentId parameter must be specified. To address this I am specifying a <code>clientId</code> as below: <code>@Override public void configure() throws Exception { from("salesforce:event/Case__e?clientId=xyz") .to("mock:end"); } </code> When trying to start the route this time I am getting a rather strange error complaining about <code>clientId</code> being an unknown parameter: <code>Failed to resolve endpoint: salesforce://event/Case__e?clientId=xyz due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{clientId=xyz}] </code> Not sure what I am doing wrong and how should I address this. Thank you in advance for your inputs.
Your problem is related to the fact that <code>clientId</code> is a component option so it must be configured at the component level while you try to configure it like it was a query parameter / an endpoint option which cannot work. Depending on the runtime that you use, the way to configure a component may change but the idea remains the same. For example, assuming that you use an <code>application.properties</code> to configure your application, the configuration of your salesforce component would look like this: In application.properties <code># Salesforce credentials camel.component.salesforce.login-config.client-id=<Your Client ID> camel.component.salesforce.login-config.client-secret=<Your Client Secret> camel.component.salesforce.login-config.refresh-token=<Your Refresh Token> ... </code> Here is a salesforce example https://github.com/apache/camel-examples/blob/main/examples/salesforce-consumer/
apache-camel
I have a route to poll the email from the server. In the <code>FunctionRoute</code> I am trying to pass the subject of the email I want to fetch by the IMAP protocol using pollEnrich method in the <code>EmailPollingRoute</code>. Currently I am facing problem to make a dynamic URI endpoint. I noticed the headers are being cleared before calling the pollEnrich method. Therefore I tried to use the <code>${exchangeProperty.subject}</code> but there is no email is fetched. When I set the subject directly in the endpoint as String then the email is being fetched. How can I set the subject dynamically in the pollEnrich method? The subject is being passed from the <code>FunctionRoute</code> to <code>EmailPollingRoute</code> route. I appreciate any help <code>@Component public class FunctionRoute extends EmailPollingRoute { static final Logger LOGGER = LoggerFactory.getLogger(FunctionRoute.class); @Override public void configure() throws Exception { from("direct:process_polling_email_function") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { subject = "ABCD - Test1"; exchange.setProperty("ABCD - Test1"); LOGGER.info("1. subject - " + subject); }}) //.setProperty("subject", constant("ABCD - Test1")) //.setHeader("subject", simple("ABCD - Test1")) .to("direct:process_polling_email"); } } </code> <code>@Component public class EmailPollingRoute extends BaseRouteBuilder { static final Logger LOGGER = LoggerFactory.getLogger(EmailPollingRoute.class); public String subject; @Override public void configure() throws Exception { //super.configure(); //2362 //@formatter:off from("direct:process_polling_email") .routeId("routeId_EmailPollingRoute") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { subject = exchange.getProperty("subject", String.class); LOGGER.info("0001 - subjectB: (" + subject + ")"); }}) .pollEnrich("imaps://XXXXXXX.info" + "?username=XXXXX&" + "password=XXXXXXX&" +"folderName=Inbox/Test&" +"searchTerm.fromSentDate=now-72h&" +"searchTerm.subject=${exchangeProperty.subject}&" +"fetchSize=1"); .to("log:newmail"); //@formatter:on } } </code>
You can set pollEnrich URI dynamically using simple method, you can also specify timeout in similar way. <code>.pollEnrich() .simple("imaps://XXXXXXX.info" + "?username=XXXXX&" + "password=XXXXXXX&" +"folderName=Inbox/Test&" +"searchTerm.fromSentDate=now-72h&" +"searchTerm.subject=${exchangeProperty.subject}&" +"fetchSize=1") .timeout(1000); </code>
apache-camel
There's a DTO created on a builder method (assume it has only a "name" attribute with some random value) and I want to check if the returned object has the same value, but the response is null. Unit test code: <code>class GetProductByIdRouteBuilderTest extends CamelTestSupport { @Test void testRoute() throws Exception { var expected = DTOBuilder.getProductDetailsDTO(); getMockEndpoint("mock:result").expectedMessageCount(1); getMockEndpoint("mock:result").expectedHeaderReceived("id", 1); var response = template.requestBodyAndHeader( "direct:getProductById", null, "id", 1L, GetProductDetailsDTO.class ); assertMockEndpointsSatisfied(); assertEquals(expected.getName(), response.getName()); } @Override protected RoutesBuilder createRouteBuilder() { return new RouteBuilder() { @Override public void configure() { from("direct:getProductById") .routeId("getProductById") .log("id = ${header.id}") .to("mock:result") .end(); } }; } } </code> Solution Used the whenAnyExchangeReceived method: <code>getMockEndpoint("mock:result").whenAnyExchangeReceived(exchange -> { exchange.getMessage().setBody(expected); exchange.getMessage().setHeader(Exchange.HTTP_RESPONSE_CODE, HttpStatus.OK.value()); }); </code>
It sounds like a totally expected behavior since the body of the original message is <code>null</code> and your route doesn't transform it such that the result of your route is <code>null</code>. Let's describe your code step by step to better understand: The test method The next code snippet, sends a message to the Consumer endpoint <code>direct:getProductById</code> with <code>null</code> as body and <code>1L</code> as value of the header <code>id</code> and tries to convert the resulting body into an object of type <code>GetProductDetailsDTO</code>. <code>var response = template.requestBodyAndHeader( "direct:getProductById", null, "id", 1L, GetProductDetailsDTO.class ); </code> The route Your route simply logs the value of the header <code>id</code> and sends the message received by the consumer endpoint <code>direct:getProductById</code> as is to the producer endpoint <code>mock:result</code>. So knowing that, we can see that your route will actually end with a message with <code>null</code> as body, and since Camel cannot convert <code>null</code> to an object of type <code>GetProductDetailsDTO</code>, you end up with <code>null</code> as result of your route. I guess that your route is incomplete as it should somehow query your database.
apache-camel
In my camel application, I am trying to send a message from the source AMQ Queue (INLET) doing some TRANSFORMATION(XMLTO JSON) to Target AMQ Queue (OUTLET) The message is successfully transferred from INLET to OUTLET. But the 1st Messages ID is different and the remaining all are the same in the entire route flow. Below is the Message-IDs : Message ID :ID:dbf0f290-c7e2-11ec-b776-6eb51c0a3021:-1:-1:-1:-1 (DIFFERENT) Message ID :queue_INLET_ID_dbf0f290-c7e2-11ec-b776-6eb51c0a3021_-1_-1_-1_-1 (SAME) Message ID :queue_INLET_ID_dbf0f290-c7e2-11ec-b776-6eb51c0a3021_-1_-1_-1_-1 (SAME) Message ID :queue_INLET_ID_dbf0f290-c7e2-11ec-b776-6eb51c0a3021_-1_-1_-1_-1 (SAME) Anyone help me on this.
Before I used exchange.getIn().getMessageId() After using this exchange.getExchangeId() //Solved my issue
apache-camel
I am implementing simple camel application using camel 3.14.0. I start using modelcamelcontext. But there is below exception during setting custom tracer. <code>2022-04-29 17:04:18.474 INFO 10264 --- [ main] target.atom.engine.EngineApplication : Started EngineApplication in 14.158 seconds (JVM running for 16.177) 2022-04-29 17:04:18.540 ERROR 10264 --- [ main] o.s.boot.SpringApplication : Application run failed java.lang.IllegalStateException: Cannot set tracer on a started CamelContext at org.apache.camel.impl.engine.AbstractCamelContext.setTracer(AbstractCamelContext.java:4601) ~[camel-base-engine-3.14.0.jar:3.14.0] at target.atom.common.config.TargetAtomConfig.reloadRoutes(TargetAtomConfig.java:54) ~[classes/:na] at target.atom.common.config.TargetAtomConfig$$FastClassBySpringCGLIB$$7b88810d.invoke(<generated>) ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.1.jar:5.3.1] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) ~[spring-aop-5.3.1.jar:5.3.1] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.1.jar:5.3.1] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) ~[spring-aop-5.3.1.jar:5.3.1] at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89) ~[spring-aop-5.3.1.jar:5.3.1] </code> How do I set tracer in modelCamelContext? source code <code>ModelCamelContext modelCamelContext = camelContext.adapt(ModelCamelContext.class); TraceFormatter formatter = new TraceFormatter(); modelCamelContext.setTracer(formatter.getTracer(modelCamelContext)); modelCamelContext.setTracing(true); … </code>
Assuming that you are using Camel Spring Boot, the <code>CamelContext</code> can be customized thanks to a bean of type <code>CamelContextConfiguration</code> that is meant to be used to add custom logic before and after Spring Boot and the <code>CamelContext</code> have been fully started. In your case, the idea is to add custom logic before the start up, so your code should look like this: <code>@Bean CamelContextConfiguration contextConfiguration() { return new CamelContextConfiguration() { @Override public void beforeApplicationStart(CamelContext context) { // Configure the tracer before starting up the camel context TraceFormatter formatter = new TraceFormatter(); context.setTracer(formatter.getTracer(modelCamelContext)); context.setTracing(true); } @Override public void afterApplicationStart(CamelContext camelContext) { // Nothing to do } }; } </code>
apache-camel
I have a route builder that depending on the content of a message sets specific properties. It doesn't send it to other endpoints so I cannot mock them and check what they got. I can produce a message or exchange but is there a way to check it after it was transformed by this route builder?
Assuming that your route is synchronous (i.e. not <code>from:seda</code>), you can simply check that the property was updated on the exchange that you send via the <code>ProducerTemplate</code>. Let's assume that you need to check the value of the property <code>TestProp</code>: <code>package com.example.demo; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Produce; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.ExchangeBuilder; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest class PropertyUpdateTest { @Produce("direct:testProps") ProducerTemplate template; @Autowired CamelContext camelContext; @Test void verifyRouteUpdatesProperty() { Exchange exchange = ExchangeBuilder.anExchange(camelContext) .withProperty("TestProp", "InitialVal") .build(); template.send(exchange); assertThat(exchange.getProperty("TestProp")).isEqualTo("UpdatedVal"); } } </code>
apache-camel
I have something like the following: <code>.from("direct:start") .to("direct:a") .to("direct:b") .to("direct:c"); </code> The issue I have is <code>direct:a</code> modifies the body and then passes that modified body to b and c. I want a, b, and c to all get the same body. I was able to achieve this by doing <code>.multicast()</code>: <code>.from("direct:start") .multicast() .to("direct:a", "direct:b", "direct:c"); </code> However, it appears the <code>.to(...)</code> blocks are not executing in sequential order anymore (even though I am not specifying <code>.parallelProcessing()</code>) and also the multicast is messing up my tx policy. I cannot find anything that exactly fits this need. A wireTap would achieve this I think, but that is async and I need synchronous and sequential. I have even tried brute force saving the body to a property against the exchange and then restoring it and that does not seem to work.
You can use enrich for this: <code>from("direct:start") .enrich("direct:a", AggregationStrategies.useOriginal(true)) .enrich("direct:b", AggregationStrategies.useOriginal(true)) .enrich("direct:c", AggregationStrategies.useOriginal(true)); </code> The <code>true</code> argument there means that exceptions thrown by your child routes will be propagated to the main route. If you do not want that, just pass <code>false</code> or omit the argument altogether.
apache-camel
I have the following route definitions file (linehaul-routes.xml): <code><routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://camel.apache.org/schema/spring" xsi:schemaLocation=" http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <route id="route1" errorHandlerRef="myErrorHandler"> <from uri="amqp:queue:DSMLH_consignment_event"/> <!-- AMQP queue to which I send messages to trigger the route !--> <to uri="https://pesho.free.beeceptor.com/"/> <!-- Returns http 500 !--> </route> </routes> </code> I also have a file with error handler in the same directory (linehaul-error-handlers.xml): <code><errorHandlers> <errorHandler id="myErrorHandler" type="DefaultErrorHandler"> <redeliveryPolicy maximumRedeliveries="5" redeliveryDelay="2000"/> </errorHandler> </errorHandlers> </code> And application.properties <code>camel.context.name=testContext camel.main.routes-include-pattern=classpath:routes/linehaul-routes.xml,classpath:routes/linehaul-error-handlers.xml </code> When I run the code I get the following stacktrace <code>2022-04-27 19:44:53,657 ERROR [org.apa.cam.qua.mai.CamelMainRuntime] (Quarkus Main Thread) [{}] Failed to start application: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[https://pesho.free.beeceptor.com/] <<< in route: Route(route1)[From[amqp:queue:DSMLH_consignment_event] -> [T... because of No bean could be found in the registry for: myErrorHandler of type: org.apache.camel.ErrorHandlerFactory at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:240) at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74) at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:868) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:758) at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2862) at org.apache.camel.quarkus.core.FastCamelContext.doInit(FastCamelContext.java:166) at org.apache.camel.support.service.BaseService.init(BaseService.java:83) at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2568) at org.apache.camel.support.service.BaseService.start(BaseService.java:111) at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2587) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247) at org.apache.camel.quarkus.main.CamelMain.doStart(CamelMain.java:94) at org.apache.camel.support.service.BaseService.start(BaseService.java:119) at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:140) at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49) at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45) at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy_0(Unknown Source) at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot173480958.deploy(Unknown Source) at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source) at io.quarkus.runtime.Application.start(Application.java:101) at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:103) at io.quarkus.runtime.Quarkus.run(Quarkus.java:67) at io.quarkus.runtime.Quarkus.run(Quarkus.java:41) at io.quarkus.runtime.Quarkus.run(Quarkus.java:120) at io.quarkus.runner.GeneratedMain.main(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: myErrorHandler of type: org.apache.camel.ErrorHandlerFactory at org.apache.camel.support.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:241) at org.apache.camel.model.errorhandler.ErrorHandlerHelper.lookupErrorHandlerFactory(ErrorHandlerHelper.java:82) at org.apache.camel.reifier.errorhandler.ErrorHandlerRefReifier.lookupErrorHandler(ErrorHandlerRefReifier.java:41) at org.apache.camel.reifier.errorhandler.ErrorHandlerRefReifier.createErrorHandler(ErrorHandlerRefReifier.java:35) at org.apache.camel.impl.DefaultModelReifierFactory.createErrorHandler(DefaultModelReifierFactory.java:65) at org.apache.camel.reifier.ProcessorReifier.wrapInErrorHandler(ProcessorReifier.java:745) at org.apache.camel.reifier.ProcessorReifier.wrapChannelInErrorHandler(ProcessorReifier.java:726) at org.apache.camel.reifier.ProcessorReifier.wrapChannel(ProcessorReifier.java:705) at org.apache.camel.reifier.ProcessorReifier.wrapChannel(ProcessorReifier.java:611) at org.apache.camel.reifier.ProcessorReifier.wrapProcessor(ProcessorReifier.java:607) at org.apache.camel.reifier.ProcessorReifier.makeProcessor(ProcessorReifier.java:854) at org.apache.camel.reifier.ProcessorReifier.addRoutes(ProcessorReifier.java:579) at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:236) ... 31 more </code> What is wrong with the route to error handler mapping ? (My goal is to make my route to re-try several times on http 500)
Camel Quarkus only supports 'simple' XML routes. You cannot define beans directly like you can with Camel Spring XML. Instead, you can declare a CDI bean and reference it in the XML. For example. <code>@Named("myErrorHandler") public DefaultErrorHandlerBuilder createDefaultErrorHandler() { return new DefaultErrorHandlerBuilder() .maximumRedeliveries(5) .redeliveryDelay(2000); } </code> Then you can reference the bean via <code>errorHandlerRef</code> on the <code>route</code> tag. <code><route id="route1" errorHandlerRef="myErrorHandler"> </code>
apache-camel
Java Code <code> @Component @RequiredArgsConstructor public class WireInboundFileListener extends RouteBuilder { private final JwtWireTokenService jwtWireTokenService; private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @Value("${wire.ftp.protocol}") private String ftpProtocol; @Value("${wire.ftp.server}") private String ftpServer; @Value("${wire.ftp.server.port}") private String ftpServerPort; @Value("${wire.ftp.username}") private String ftpUsername; @Value("${wire.ftp.password}") private String ftpPassword; @Value("${wire.ftp.private.key.file}") private String ftpPrivateKeyFile; @Value("${wire.ftp.private.key.passphrase}") private String privateKeyPassphrase; @Value("${wire.file.inbound.dir}") private String ftpListenDir; @Value("${wire.file.inbound.url}") private String inboundUrl; @Override public void configure() { var fromFtpUri = String.format("%s:%s:%s/%s?username=%s&delete=true&antInclude=*.txt", ftpProtocol, ftpServer, ftpServerPort, ftpListenDir, ftpUsername); log.info("SFTP inbound listen dir : " + ftpListenDir); if (Environment.getExecutionEnvironment().equals(Environment.ExecutionEnvironment.AWS)) { fromFtpUri += "&privateKeyFile=" + ftpPrivateKeyFile + "&privateKeyPassphrase=" + privateKeyPassphrase; } else { fromFtpUri += "&password=" + ftpPassword; } from(fromFtpUri) //.delay(10000) event I put delay but still got file content null .convertBodyTo(String.class) .process(exchange -> { final var requestBody = new HashMap<String, Object>(); final var content = exchange.getIn().getBody(); final var fileName = exchange.getIn().getHeader("CamelFileName"); requestBody.put("content", content); requestBody.put("name", fileName); exchange.getIn().setBody(OBJECT_MAPPER.writeValueAsString(requestBody)); }) .to("log:com.test.wire.inbound.listener.SftpRoute") .setHeader(Exchange.HTTP_METHOD, constant("POST")) .setHeader("Content-Type", constant("application/json")) .setHeader("Authorization", method(this, "clientToken")) .to(inboundUrl + "?throwExceptionOnFailure=false") .log("Response body from wire inbound : ${body}") .end(); } public String clientToken() { return "Bearer " + jwtWireTokenService.getToken(); } } </code> Success Request <code>2022-04-20 03:46:47.910 INFO 1 --- [read #6 - Delay] c.test.wire.inbound.listener.SftpRoute : Exchange[ExchangePattern: InOnly, BodyType: String, Body: { "name": "sample-inbound-transfer-20220414024722.txt", "content": "file content" }] </code> Fail Request <code>2022-04-21 09:36:54.148 INFO 1 --- [read #4 - Delay] c.test.wire.inbound.listener.SftpRoute : Exchange[ExchangePattern: InOnly, BodyType: String, Body: { "name": "sample-inbound-transfer-20220414024722.txt", "content": "" }] </code> Main issue <code> final var content = exchange.getIn().getBody();// sometimes get null, sometimes can get file contents </code> When I test to drop a file to SFTP server in local it worked as I expected in <code>Sucess Request</code> because the process to upload seemed fast because it is in local (FileZilla). But when I test to drop a file again to SFTP server that hosts in real server sometimes it works and sometimes it didn't work <code>Fail Request</code>. Seem like the SFTP consuming file issue. Could you please help me on that? Thanks
The file is probably (sometimes) consumed by your Camel route before the file upload is finished. What you can try is to configure your endpoint to poll the files only if it has exclusive read-lock on the file (i.e. the file is not in-progress or being written); see the readLock parameter. I think the default is no read lock; you should set <code>readLock=changed</code>...but I do not remember is such mode is also possible on endpoints of SFTP type.
apache-camel
I am using Apache Camel with IntelliJ Community Edition. I've seen on the official site some kind of debugger for XML DSL, but is not very clear how to use it... Does it works for the Community edition also? It asks to create a Camel SpringBoot Application run configuration, how I do it? In fact, when I check for this application, I can't find nothing. I have installed the recommended plugin.
Apache Camel plugin is not compatible with IntelliJ IDEA 2022.1. Try using 2021.3 instead.
apache-camel
<code>[ { "Name": "ABC", "ID": 1, "StartDate": 1444845395112, "EndDate": null, "ValueAction": null, "ValueSource": "lmn" }, { "Name": "PQR", "ID": 2, "StartDate": 1444845395119, "EndDate": 1446845395119, "ValueAction": null, "ValueSource": null }, { "Name": "XYZ", "ID": 3, "StartDate": null, "EndDate": null, "ValueAction": "qwe", "ValueSource": "lmn" } ] </code> How to create object array from this json using split with 'groovy script/java' [Name, ID, ValueAction, ValueSource] here ValueAction/ValueSource should be null if StartDate is null. So array should be like this. <code> [[ABC,1, , lmn],[PQR,2, , ],[XYZ,3, , ]] </code>
<code>import groovy.json.* def json = new JsonSlurper().parseText '''[ { "Name": "ABC", "ID": 1, "StartDate": 1444845395112, "EndDate": null, "ValueAction": null, "ValueSource": "lmn" }, { "Name": "PQR", "ID": 2, "StartDate": 1444845395119, "EndDate": 1446845395119, "ValueAction": null, "ValueSource": null }, { "Name": "XYZ", "ID": 3, "StartDate": null, "EndDate": null, "ValueAction": "qwe", "ValueSource": "lmn" } ] ''' def res = json.findResults{ it.StartDate ? [ it.Name, it.ID, it.ValueAction ?: '', it.ValueSource ] : null } assert res.toString() == '[[ABC, 1, , lmn], [PQR, 2, , null]]' </code> Next time please post the valid JSON.
apache-camel
I am playing around with camel-k to build some integrations. The dev mode experience is really great. My command is <code>kamel run --config file:demo-template.json demo-driver.groovy --dev</code> But when i am finished i would like not just remove the <code>--dev</code> switch. I would like to have some yaml files to check in into git and the deploy them with ArgoCD or Flux. Is there something like <code>kamel build ... --dry-run=client -o yaml</code> or similar?
You can use <code>kamel run ... -o yaml</code>, for example: <code>kamel run --config file:demo-template.json demo-driver.groovy -o yaml > integration.yaml </code> Despite the <code>run</code> name, when specifying the output, it will not actually run the integration
apache-camel
I've got a problem, i need to send get request to the url. But i got exception: <code>Failed to create route route1: Route(route1)[From[jetty://https://jsonplaceholder.typicode.... because of No endpoint could be found for: jetty://https://jsonplaceholder.typicode.com/todos/, please check your classpath contains the needed Camel component jar. </code> Camel route: <code>from("jetty://" + serverUrl) .log("${body}") .to("direct:process"); from("direct:process").id("processing") .log("Body processed") .log(body().toString()); </code> P.S I'm using camel 3.16.0
As the error message states, your problem is due to the fact that <code>camel-jetty</code> is not in your classpath. Assuming that you use Maven, simply add the following dependency to the pom of your project: <code><dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jetty</artifactId> <version>3.16.0</version> </dependency> </code> If not you can still download it from here.
apache-camel
I have an Apache Camel application with an Idempotent Consumer. I need a metric with the total number of duplicated messages. How could I implement such a metric? Code <code>@SpringBootApplication public class TestApplication { public static void main(String[] args) { SpringApplication.run(TestApplication.class, args); } @Bean public MicrometerRoutePolicyFactory micrometerRoutePolicyFactory() { return new MicrometerRoutePolicyFactory(); } @Bean public EndpointRouteBuilder route() { return new EndpointRouteBuilder() { @Override public void configure() throws Exception { from(file("d:/tmp/camel/")) .idempotentConsumer(jsonpath("$.id"), MemoryIdempotentRepository.memoryIdempotentRepository()) .to(file("d:/tmp/copy/")); } }; } } </code> Research I looked into <code>MicrometerConstants</code>, but I couldn't find a metric for duplicate messages. Question How can I count the number of duplicate messages for Idempotent Consumer with a metric?
I found a workaround, see Idempotent Consumer: How to handle duplicate messages in the route Available as of Camel 2.8 You can now set the <code>skipDuplicate</code> option to <code>false</code> which instructs the idempotent consumer to route duplicate messages as well. However the duplicate message has been marked as duplicate by having a property on the Exchange set to true. We can leverage this fact by using a Content Based Router or Message Filter to detect this and handle duplicate messages. For example in the following example we use the Message Filter to send the message to a duplicate endpoint, and then stop continue routing that message. Filter duplicate messages <code>from("direct:start") // instruct idempotent consumer to not skip duplicates as we will filter then our self .idempotentConsumer(header("messageId")).messageIdRepository(repo).skipDuplicate(false) .filter(property(Exchange.DUPLICATE_MESSAGE).isEqualTo(true)) // filter out duplicate messages by sending them to someplace else and then stop .to("mock:duplicate") .stop() .end() // and here we process only new messages (no duplicates) .to("mock:result"); </code> and <code>MicrometerBuilders#micrometer</code>: <code>default MicrometerEndpointBuilderFactory.MicrometerEndpointBuilder micrometer(String path)</code> Micrometer (camel-micrometer) Collect various metrics directly from Camel routes using the Micrometer library. Category: monitoring Since: 2.22 Maven coordinates: org.apache.camel:camel-micrometer Syntax: <code>micrometer:metricsType:metricsName</code> Path parameter: metricsType (required) Type of metrics There are 6 enums and the value can be one of: COUNTER, GAUGE, LONG_TASK_TIMER, TIMER, DISTRIBUTION_SUMMARY, OTHER Path parameter: metricsName (required) Name of metrics Path parameter: tags Tags of metrics Parameters: <code>path - metricsType:metricsName</code> Returns: the dsl builder My modified code: <code>@Bean public EndpointRouteBuilder route() { return new EndpointRouteBuilder() { @Override public void configure() throws Exception { from(file("d:/tmp/camel/")) .idempotentConsumer(jsonpath("$.id"), MemoryIdempotentRepository.memoryIdempotentRepository()) .skipDuplicate(false) .filter(header(Exchange.DUPLICATE_MESSAGE).isEqualTo(true)) .to(micrometer("duplicate_messages").increment("1")) .stop() .end() .to(file("d:/tmp/copy/")); } }; } </code>
apache-camel
How do you install Apache-Camel? I've just started reading 'Camel in Action' 2nd ed. In section 1.2.1, is suggests downloading the binary distribution. I found this link to from the releases page: Release 2.24.1 But I can only see a source-code download. I've tried to compile from the source, but that always encounters an error. How do you just install the binary on either Ubuntu/Redhat/Fedora? Or have I misunderstood Apache-Camel as being a library that you can just install? Must it always be compiled with maven?
Camel, Java-projects and build-tools Apache Camel works like any other Java library or framework, meaning that in order to use the framework you'll have to include its java binaries (i.e .jar files) to your project as dependencies. Now to make things simpler most developers use either Maven or Gradle to create, manage and build their java projects. From these two I would recommend Maven as it seems to be the preferred option for Camel developers with most examples (including ones in official camel site) using it. To install maven follow the official how to install maven guide. Maven archetypes To create example camel project you can use maven archetypes which are basically project templates that can be used to create various types of new projects. If you're reading Camel in Action you might be better off using Camel version 2.x.x in your projects with Java Development Kit version 8. Camel 3.x.x is pretty similar so it should be fairly easy to learn that after learning the basics with 2.x.x. After installing maven you can use your Java IDE (i.e IntelliJ, VSCode, Eclipse or Netbeans) to create project from maven archetype with groupId: org.apache.camel.archetypes artifactId: camel-archetype-java and version: 2.25.4 Or use maven command line command: <code># Create new camel java project for Camel version 2.25.4 mvn archetype:generate -DarchetypeGroupId="org.apache.camel.archetypes" -DarchetypeArtifactId=camel-archetype-java -DarchetypeVersion="2.25.4" </code> Camel project The new project should contain project file pom.xml where you can specify all the dependencies for your project. The the camel-archetype-java should have the following dependencies listed in the dependencies section of pom.xml. <code><dependencies> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> </dependency> <!-- logging --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> <scope>runtime</scope> </dependency> <!-- testing --> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-test</artifactId> <scope>test</scope> </dependency> </dependencies> </code> The example route in camel-archetype-java archetypes Myroutebuilder.java is pretty complex for beginners. Hello world on a timer is generally a more simpler test on to see if things work. <code>package com.example; import org.apache.camel.LoggingLevel; import org.apache.camel.builder.RouteBuilder; public class MyRouteBuilder extends RouteBuilder { public void configure() { // from("file:src/data?noop=true") // .choice() // .when(xpath("/person/city = 'London'")) // .log("UK message") // .to("file:target/messages/uk") // .otherwise() // .log("Other message") // .to("file:target/messages/others"); from("timer:timerName?period=3000") .routeId("helloWorldTimer") .log(LoggingLevel.INFO, "Hello world"); } } </code> The project generated from archetype comes with exec-maven-plugin which allows you to run the project with <code>mvn exec:java</code> Java development kit - JDK If you're using JDK 11 instead of JDK 8 you'll have to modify maven-compiler-plugin configuration a bit. <code><plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <!-- <source>1.8</source> <target>1.8</target> --> <source>11</source> <target>11</target> </configuration> </plugin> </code> If you've multiple versions of JDK installed you'll have to configure your IDE to use the correct one for the project. With IntelliJ you can configure JDK used by the project from project structure settings. With VSCode you'll need both JDK 11 and JDK 8 as VSCode Java extensions require JDK 11 to run. Example settings.json entries for OpenJDK: <code>"java.configuration.runtimes": [ { "name": "JavaSE-11", "path": "C:\\Program Files\\AdoptOpenJDK\\jdk-11.x.x.xxx-hotspot", "default": true }, { "name": "JavaSE-1.8", "path": "C:\\Program Files\\RedHat\\java-1.8.0-openjdk-1.8.0.xxx-x", } ], "java.home": "C:\\Program Files\\AdoptOpenJDK\\jdk-11.x.x.xxx-hotspot" </code> You might also want to setup your path variable so that java -version returns correct version from the command-line.
apache-camel
Facing an issue while migrating from 2.x version to 3.16.0. What is the alternative for <code><handled><constant>true</constant></handled></code> in camel-spring 3.x versions. What is the alternative for handled and continue in higher versions?
The <code>handled</code> tag is not deprecated as you can see in the class <code>OnExceptionDefinition</code> corresponding to the model class that is used to generate the XSD schema of the Spring XML DSL and in the latest XSD schema. The equivalent of your code in Spring XML DSL is: <code><onException> <!-- the exception is full qualified names as plain strings --> <!-- there can be more just add a 2nd, 3rd exception element (unbounded) --> <exception>java. Lang. Throwable</exception> <!-- mark this as handled --> <handled> <constant>true</constant> </handled> ... </onException> </code> For more details about error handling using Spring DSL please refer to the documentation.
apache-camel
I am trying to POC accessing DynamoDB via an Apache Camel application. Obviously Dynamo DB will run in AWS but for development purposes we have it running locally as a docker container. It was very easy to create a Dynamo BD table locally and put some items in there manually. I used for this my intelij Dynamo DB console and all I had to provide was a custom end point <code>http://localhost:8000</code> and the Default credential provider chain. Now at some certain times of the day I would like to trigger a job that will scan the Dynamo DB items and perform some actions on the returned data. <code>from("cron:myCron?schedule=0 */5 * * * *") .log("Running myCron scheduler") .setHeader(Ddb2Constants.OPERATION, () -> Ddb2Operations.Scan) .to("aws2-ddb:myTable") .log("Performing some work on items"); </code> When I am trying to run my application it fails to start complaining that the security token is expired which makes me think it is trying to go to AWS rather than accessing the local. I was unable to find anything about how would I set this. The camel dynamo db component (https://camel.apache.org/components/3.15.x/aws2-ddb-component.html) is talking about being able to configure the component with a <code>DynamoDbClient</code> but this is an interface and its implementation called <code>DefaultDynamoDbClient</code> is not public and so is the <code>DefaultDynamoDbClientBuilder</code>.
Assuming that you use Spring Boot as Camel runtime, the simplest way in your case is to configure the <code>DynamoDbClient</code> used by Camel thanks to options set in the <code>application.properties</code> as next: <code># The value of the access key used by the component aws2-ddb camel.component.aws2-ddb.accessKey=test # The value of the secret key used by the component aws2-ddb camel.component.aws2-ddb.secretKey=test # The value of the region used by the component aws2-ddb camel.component.aws2-ddb.region=us-east-1 # Indicates that the component aws2-ddb should use the new URI endpoint camel.component.aws2-ddb.override-endpoint=true # The value of the URI endpoint used by the component aws2-ddb camel.component.aws2-ddb.uri-endpoint-override=http://localhost:8000 </code> For more details please refer to the documentation of those options: camel.component.aws2-ddb.accessKey camel.component.aws2-ddb.secretKey camel.component.aws2-ddb.region camel.component.aws2-ddb.override-endpoint camel.component.aws2-ddb.uri-endpoint-override For other runtimes, it can be configured programatically as next: <code>Ddb2Component ddb2Component = new Ddb2Component(context); String accessKey = "test"; String secretKey = "test"; String region = "us-east-1"; String endpoint = "http://localhost:8000"; ddb2Component.getConfiguration().setAmazonDDBClient( DynamoDbClient.builder() .endpointOverride(URI.create(endpoint)) .credentialsProvider( StaticCredentialsProvider.create( AwsBasicCredentials.create(accessKey, secretKey) ) ) .region(Region.of(region)) .build() ); </code>
apache-camel
I saw in another post how manually adding the camel context and starting it should work, but it hasn't for me. I double checked the from, and to paths and they seem to be correct. Not sure why it's not calling the method and would appreciate some advice <code>public class CsvRouteBuilder extends DdsRouteBuilder { private CsvConverterProcessor csvConverterProcessor; private CamelContext camelContext; @Autowired public CsvRouteBuilder(CsvConverterProcessor csvConverterProcessor) throws Exception { this.csvConverterProcessor = csvConverterProcessor; camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("{{input.files.csv}}") .routeId("CSVConverter") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { System.out.println("hitting"); } }) .to("{{output.files.csv}}"); } }); camelContext.start(); } </code>
The processor is not called simply because your route is not properly declared such that Spring Boot is not aware of it. The proper way is to make your class extend RouteBuilder to define your route(s) and annotate your class with <code>@Component</code> to mark it as candidate for auto-detection when using annotation-based configuration and classpath scanning. Your code should rather be something like this: <code>@Component public class CsvRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from("{{input.files.csv}}") .routeId("CSVConverter") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { System.out.println("hitting"); } }) .to("{{output.files.csv}}"); } } </code>
apache-camel
I'm currently trying to add properties component with location set to my properties file to use properties placeholders in my project: <code>PropertiesComponent pc = new PropertiesComponent(); pc.setLocation("classpath:properties.properties"); context.addComponent("properties", pc); </code> But addComponent() function expects Component type argument, not PropertiesComponent even though PropertiesComponent extends the DefaultComponent class. I've added this dependency to pom.xml to use it: <code><dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-properties</artifactId> <version>3.0.0-M4</version> </dependency> </code> and also added the resources tag: <code><build> <resources> <resource> <directory>${project.basedir}/src/main/resources</directory> </resource> </resources> ... </build> </code> The error I get looks like this: java: incompatible types: org.apache.camel.component.properties.PropertiesComponent cannot be converted to org.apache.camel.Component I have no idea what causes it, please help. Thanks.
The <code>PropertiesComponent</code> is a very special component thus there are dedicated methods like <code>setPropertiesComponent</code> and <code>getPropertiesComponent()</code> in the Camel context to manage it that you should use instead. Your code should rather be something like the following code: <code>// create the properties component PropertiesComponent pc = new PropertiesComponent(); pc.setLocation("classpath:properties.properties"); // add properties component to camel context context.setPropertiesComponent(pc); </code> Or simply <code>context.getPropertiesComponent().setLocation("classpath:properties.properties")</code>
apache-camel
I have a spring web-app which uses camel-servletlistener(2.25.4), camel-urlrewrite(2.25.4) and springframework.web(5.3.15) internally. these dependencies uses javax.servlet internally because of which my web-app is not running in tomcat-10. can i know what should be done so that my web-app supports tomcat-10 too. I have replaced all the javax dependencies to jakarta. i getting following error. <code>06-Apr-2022 11:05:56.002 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [org.springframework.web.context.ContextLoaderListener] java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener </code>
Apache Camel doesn't support Jakarta EE yet thus it cannot work for now on Tomcat 10. There is an ongoing task about that https://issues.apache.org/jira/browse/CAMEL-17136, you can follow it to know when it will be supported. Your second option is to use Tomcat 9 instead.
apache-camel
I have the following supercalss <code>BaseRouteBuilder</code> where I am handling the common exception. All my routes extends this class <code>1234Route extends BaseRouteBuilder</code>. In all my route I am calling at the end a http request to create the order and I am using a format to convert it to JSON. Is it possible in apache Camel to move the format and this conding to the supercass <code>BaseRouteBuilder</code>? <code>.marshal(format) .setHeader( Exchange.HTTP_METHOD, constant(org.apache.camel.component.http.HttpMethods.POST) ) .setHeader(Exchange.CONTENT_TYPE, constant("application/json")) .to("http://localhost:8080/orders/create-order") </code> **Superclass - BaseRouteBuilder ** <code>@Component public class BaseRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { //@formatter:off onException(Exception.class).process(new Processor() { public void process(Exchange exchange) throws Exception { //Coding to enrich the exception error } }) .handled(true) .to("activemq:queue:dead-messages"); //@formatter:on } } </code> **Subclass - 1234Route <code>@Component public class 1234Route extends BaseRouteBuilder { @Override public void configure() throws Exception { super.configure(); JacksonDataFormat format = new JacksonDataFormat(); format.useList(); format.setUnmarshalType(DataBase.class); //@formatter:off from("activemq:queue:1234") // my route coding (I have deleted it) //.setHeader() //.process //.bean() //This is the common coding I want to move it to the super class. .marshal(format) .setHeader( Exchange.HTTP_METHOD, constant( org.apache.camel.component.http.HttpMethods.POST ) ) .setHeader(Exchange.CONTENT_TYPE, constant("application/json")) .to("http://localhost:8080/orders/create-order"); //@formatter:on } } </code>
RouteBuilder supports inheritance just like any other class, since onException is RouteBuilder scoped it's fine to define it in a base class. I would however advice against or at least be very careful when defining routes in something like BaseRouteBuilder. You should also mark BaseRouteBuilder abstract and I would also try to give it more descriptive name like RouteBuilderWithGenericErrorHandler. RouteBuilders are used to create and add RouteDefinitions to CamelContext and you're not limited to using just one RouteBuilder. Now if you add multiple RouteBuilders to CamelContext that all inherit from BaseRouteBuilder this will cause BaseRouteBuilder.configure to be called multiple times. This can cause problems like: RouteId conflicts. Consumer endpoint URI conflicts. Same configuration changes getting applied multiple times. i.e if you use <code>RouteBuilder.getContext</code> to modify the CamelContext in some way. In all my route I am calling at the end a http request to create the order and I am using a format to convert it to JSON. If many of your routes share same routing logic you should split that part to separate route and use it like function. It also makes it easier to add route-scope error handling like what to do when orders api isn't responding or the body provided to <code>direct:createOrder</code> consumer endpoint is invalid. <code>@Override public void configure() throws Exception { from("direct:createOrderA") .routeId("createOrderA") // .. do stuff for A .to("direct:createOrder"); from("direct:createOrderB") .routeId("createOrderB") // .. do stuff for B .to("direct:createOrder"); DataFormat format = ...; from("direct:createOrder") .routeId("createOrder") .marshal(format) .setHeader( Exchange.HTTP_METHOD, constant(org.apache.camel.component.http.HttpMethods.POST) ) .setHeader(Exchange.CONTENT_TYPE, constant("application/json")) .to("http://localhost:8080/orders/create-order"); } </code>
apache-camel
I'm using camel k on a project and I've tried use yaks framework for testing integrations routes. When I execute the command to begin the test which is written in a .feature file the .groovy file is not found. Does anyone have a clue about it? helloworld.feature <code>Feature: Hello Scenario: Print hello message Given load Camel K integration myIntegration.groovy Given Camel K integration myIntegration is running Then Camel K integration myIntegration should print Hello world from Camel K! </code> integration myIntegration.groovy <code>from('timer:tick?period=10000') .setBody() .constant('Hello world from Camel K!') .to('log:info') </code> CLI command <code>yaks test helloworld.feature -n dev-camelk </code> Logs: <code>[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] 1 Scenarios (1 failed) [test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] 3 Steps (1 failed, 2 skipped) [test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] 0m1.987s **[test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] com.consol.citrus.exceptions.CitrusRuntimeException: Failed to load Camel K integration from resource mob2.groovy** [test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] at org.citrusframework.yaks.camelk.CamelKSteps.loadIntegrationFromFile(CamelKSteps.java:141) [test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] at ✽.load Camel K integration mob2.groovy(classpath:org/citrusframework/yaks/helloworld.feature:3) [test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] Caused by: **java.io.FileNotFoundException: class path resource [myIntegration.groovy] cannot be opened because it does not exist** [test-helloworld-c91h513v71u96jkmfqbg-g56mw test-1] at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:199) </code> Thank you!
There are a couple of problems in the way you call it. The integration name is generally kebab case for Camel K integration, so, your feature must be: <code>Feature: Hello Scenario: Print hello message Given load Camel K integration myIntegration.groovy Given Camel K integration my-integration is running Then Camel K integration my-integration should print Hello world from Camel K! </code> Then, you must provide the integration file resource via <code>--resource</code> option, such as: <code>yaks run helloworld.feature --resource myIntegration.groovy </code> Hope it helps!
apache-camel
We need to ugrade hazelcast4 to Hazelcast5 and we are using Camel connectors.Does Apache Camel connector supports the Hazelcast5.any answer or reply or link will be helpful
It has been updated from 3.16.0 ahead. 3.16.0 has been released last week: https://github.com/apache/camel/commit/ab07cb5583874ca5fffbcf93d1929522359f77a5
apache-camel
I want start camel route when 4 files with specific names are in directory. When file1.csv.sem, file2.csv.sem, file3.csv.sem, file4.csv.sem start camel route. <code> <from uri="file:{{directory.path}}?include=file1.*.sem"/> </code> I expect camel route will start when these 4 files are in directory.
You could create timer or scheduled route that uses custom processor that checks contents of a folder using <code>File.list()</code> or <code>File.listFiles()</code>. If all the required files exist processor sets body, header or property to signal that the route should continue. After that you can use PollEnrich to consume each of the files individually and store them to a header or property for later use. <code>String filePath = getContext() .resolvePropertyPlaceholders("{{input.path}}"); String[] requiredFiles = new String[]{ "file1.csv.sem", "file2.csv.sem", "file3.csv.sem" }; // Poll input folder every 5 seconds for required files from("timer:timerName?period=5000") .routeId("multifiles") .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { for (int i = 0; i < requiredFiles.length; i++) { File file = new File(filePath + File.separator + requiredFiles[i]); if(!file.exists()){ exchange.getMessage().setBody(false); return; } } exchange.getMessage().setBody(true); } }) .filter(body().isEqualTo(false)) .log("Missing files..") .stop() .end() .to("direct:processFileGroup"); from("direct:processFileGroup") .routeId("processFileGroup") .setBody(constant(Arrays.asList(requiredFiles))) // Read required files and aggregate to a list .split(body(), AggregationStrategies.groupedBody()) .log("${body}") .pollEnrich() .simple("file:{{input.path}}?fileName=${body}") .timeout(1000) .end() .end() // Do stuff with the List of Exchange(s) in body .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { List<GenericFile> files = exchange.getMessage().getBody(List.class); for (int i = 0; i < files.size(); i++) { System.out.println(files.get(i).getFileName()); } } }); </code> Alternatively you could probably use file component with some custom aggregation strategy or some trickery with File-watch but those sound more complex at least for me. This is fairly common problem so there's probably some sort of EIP to handle this more elegantly but have not stumbled upon such yet.
apache-camel
I'm trying to simply unmarshal an XML file as below: <code><?xml version="1.0" encoding = "UTF-8" ?> <feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <products> <product> <facet type="string" elementType="string" name="Weight (g)"><![CDATA[210]]></facet> </product> </products> </feed> </code> I've got this classes: <code>@Getter @Setter @Builder @NoArgsConstructor @AllArgsConstructor @XmlRootElement(name = "feed") @XmlAccessorType(XmlAccessType.FIELD) public class Feed { private Products products; } </code> Subclass <code>Products</code>: <code>@Getter @Setter @Builder @NoArgsConstructor @AllArgsConstructor public class Products { private List<Product> products; } </code> Subclass <code>Product</code>: <code>@Getter @Setter @Builder @NoArgsConstructor @AllArgsConstructor @XmlAccessorType(XmlAccessType.FIELD) public class Product { @XmlElement(name = "facet") private List<Facet> facet; } </code> And finally <code>Facet</code>: <code>@Getter @Setter @Builder @NoArgsConstructor @AllArgsConstructor @XmlAccessorType(XmlAccessType.FIELD) public class Facet { @XmlElement(name = "name") private String name; @XmlElement(name = "type") private String type; @XmlElement(name = "elementType") private String elementType; private String content; } </code> The camel route I've written to unmarshall is as below: <code>@Component public class XMLSplitterRoute extends RouteBuilder { @Override public void configure() throws Exception { from("file:src/main/resources/files/xml").routeId("xmlUmarshaller") .log("body: ${body}") .unmarshal().jacksonXml(Products.class) .log("The unmarshalled object is ${body}") .marshal().json() .to("activemq:json-marshal-queue"); } } </code> But I keep getting the error below: <code>com.fasterxml.jackson.databind.JsonMappingException: Unexpected non-whitespace text ('210' in Array context: should not occur (or should be handled) at [Source: (BufferedInputStream); line: 29, column: 96] (through reference chain: com.sammy.model.Products["products"]->java.util.ArrayList[0]->com.sammy.model.Product["facet"]) </code> and <code>Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected non-whitespace text ('210' in Array context: should not occur (or should be handled) at [Source: (BufferedInputStream); line: 29, column: 96] </code> This means, it seems not to know what to do with the value within the cdata of the XML file! I've looked everywhere but not seen any potential solution. Please, help!!!
From the nice suggestiongs of Nicolas Filotto, I fixed my mappings by first converting my XML to XSD then generated the POJO's using xjc. For Camel unmarshal process, I changed it from jacksonXML to use Jaxb converter. <code>@Component public class XMLSplitterRoute extends RouteBuilder { @Override public void configure() throws Exception { DataFormat jaxb = new JaxbDataFormat("com.sammy.model"); from("file:src/main/resources/files/xml").routeId("xmlSplitter") .log("body: ${body}") .unmarshal(jaxb) .log("The unmarshalled object is ${body}") } } </code> This now works like a charm!!!
apache-camel
I'm facing an error to connect from my spring boot app container to Rabbitmq. I have attached the two docker containers (Rabbitmq and spring boot app) with bridge network in my docker compose file: <code> version: '3.3' services: rabbitmq: image: rabbitmq:3.8-management-alpine container_name: rabbitmq ports: - 5673:5673 - 5672:5672 - 15672:15672 networks: - orchestrator-rabbitmq environment: - RABBITMQ_DEFAULT_USER=adminsi - RABBITMQ_DEFAULT_PASS=test orchestrator: restart: on-failure build: context: . dockerfile: Dockerfile-orchestrator args: VERSION: ${VERSION} environment: - spring_rabbitmq_host=rabbitmq - spring_rabbitmq_port=5672 - spring_rabbitmq_username=adminsi - spring_rabbitmq_password=test container_name: orchestrator depends_on: - rabbitmq networks: - orchestrator-rabbitmq ports: - 7127:7127 networks: orchestrator-rabbitmq: external: name: orchestrator-rabbitmq </code> the connection is refused by Rabbitmq when my Spring boot app attempts to connect to this latter. Below the log: 11:35:22.176 [main] WARN o.a.c.c.rabbitmq.RabbitMQProducer - Failed to create connection. It will attempt to connect again when publishing a message. orchestrator | java.net.ConnectException: Connection refused orchestrator | at java.base/sun.nio.ch.Net.pollConnect(Native Method) orchestrator | at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672) orchestrator | at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:542) orchestrator | at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) orchestrator | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) orchestrator | at java.base/java.net.Socket.connect(Socket.java:633) orchestrator | at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:60) orchestrator | at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62) orchestrator | at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:156) orchestrator | at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1213) orchestrator | at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1170) orchestrator | at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1128) orchestrator | at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1321) orchestrator | at org.apache.camel.component.rabbitmq.RabbitMQEndpoint.connect(RabbitMQEndpoint.java:247) orchestrator | at org.apache.camel.component.rabbitmq.RabbitMQProducer.openConnectionAndChannelPool(RabbitMQProducer.java:108) orchestrator | at org.apache.camel.component.rabbitmq.RabbitMQProducer.doStart(RabbitMQProducer.java:163) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.impl.engine.AbstractCamelContext.internalAddService(AbstractCamelContext.java:1554) orchestrator | at org.apache.camel.impl.engine.AbstractCamelContext.addService(AbstractCamelContext.java:1475) orchestrator | at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:247) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:130) orchestrator | at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1655) orchestrator | at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:60) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:130) orchestrator | at org.apache.camel.impl.engine.DefaultChannel.doStart(DefaultChannel.java:126) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:116) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:130) orchestrator | at org.apache.camel.processor.Pipeline.doStart(Pipeline.java:221) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.support.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:89) orchestrator | at org.apache.camel.processor.FilterProcessor.doStart(FilterProcessor.java:138) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:116) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:130) orchestrator | at org.apache.camel.processor.ChoiceProcessor.doStart(ChoiceProcessor.java:185) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:130) orchestrator | at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1655) orchestrator | at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:60) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:130) orchestrator | at org.apache.camel.impl.engine.DefaultChannel.doStart(DefaultChannel.java:126) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:116) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:130) orchestrator | at org.apache.camel.processor.Pipeline.doStart(Pipeline.java:221) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.support.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:89) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:113) orchestrator | at org.apache.camel.impl.engine.RouteService.startChildServices(RouteService.java:396) orchestrator | at org.apache.camel.impl.engine.RouteService.doWarmUp(RouteService.java:193) orchestrator | at org.apache.camel.impl.engine.RouteService.warmUp(RouteService.java:121) orchestrator | at org.apache.camel.impl.engine.InternalRouteStartupManager.doWarmUpRoutes(InternalRouteStartupManager.java:306) orchestrator | at org.apache.camel.impl.engine.InternalRouteStartupManager.safelyStartRouteServices(InternalRouteStartupManager.java:189) orchestrator | at org.apache.camel.impl.engine.InternalRouteStartupManager.doStartOrResumeRoutes(InternalRouteStartupManager.java:147) orchestrator | at org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:3300) orchestrator | at org.apache.camel.impl.engine.AbstractCamelContext.doStartContext(AbstractCamelContext.java:2952) orchestrator | at org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2903) orchestrator | at org.apache.camel.spring.boot.SpringBootCamelContext.doStart(SpringBootCamelContext.java:43) orchestrator | at org.apache.camel.support.service.BaseService.start(BaseService.java:119) orchestrator | at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2587) orchestrator | at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:247) orchestrator | at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:119) orchestrator | at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:151) orchestrator | at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) orchestrator | at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) orchestrator | at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) orchestrator | at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) orchestrator | at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) orchestrator | at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) orchestrator | at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) orchestrator | at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) orchestrator | at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) orchestrator | at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) orchestrator | at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) orchestrator | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) orchestrator | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) orchestrator | at fr.orange.oab.sie.service.orchestrator.OrchestratorApplication.main(OrchestratorApplication.java:31) orchestrator | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) orchestrator | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) orchestrator | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) orchestrator | at java.base/java.lang.reflect.Method.invoke(Method.java:568) orchestrator | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) orchestrator | at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) orchestrator | at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) orchestrator | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) When I execute the below command inside my spring boot app container (orchestrator in my case) I get the following response: <code>nc -vz rabbitmq 5672 </code> The response is: Connection to rabbitmq (172.19.0.2) 5672 port [tcp/*] succeeded! So the tcp connection is succeeded between the two containers, but when I curl to rabbitmq inside my orchestrator container with the credentials that are defined in the above docker compose file, I get the connection refused: <code>curl -u "adminsi:test" http://localhost:15672 </code> But when I change localhost with rabbitmq as a host like below: <code>curl -u "adminsi:test" http://rabbitmq:15672 </code> The response is succeeded ! Below my properties config in spring boot app (orchestrator): <code>spring.rabbitmq.host=rabbitmq spring.rabbitmq.port=5672 spring.rabbitmq.username=adminsi spring.rabbitmq.password=test </code> I'm using apache camel to publish messages in rabbitmq (below an example of camel route that read from an API and publish the response in rabbitmq topic): <code>from("direct:OrchestratorDtstoreLoadDataRoute") .routeId("orchestrator-dtstore-route") .log(LoggingLevel.INFO, "Reading dtstore projects") .removeHeaders("*") .setHeader("Content-Type", () -> "application/json") .setHeader("CamelHttpMethod", () -> "GET") .setHeader("Authorization", () -> dtstoreToken) .setHeader("x-apikey", () -> dtstoreXapiKey) .recipientList(simple("cxfrs:{{cmdb.service.out.dtstore.url}}/projects")) .log(LoggingLevel.DEBUG, "dtstore projects : ${body}") .to(ExchangePattern.InOnly, "rabbitmq:q.cmdb.dtstore.projects?routingKey=dtstore&autoDelete=false&exchangeType=topic") .end(); </code> The Orchestrator Dockerfile: <code>FROM openjdk:17.0.2-jdk-slim ARG VERSION ENV ORCHESTRATOR_VERSION=$VERSION RUN apt-get update && apt-get install -y \ nano \ netcat \ iputils-ping \ curl \ && rm -rf /var/lib/apt/lists/* WORKDIR /opt/app COPY target/orchestrator-$ORCHESTRATOR_VERSION.jar . EXPOSE 7127 ENTRYPOINT java -jar orchestrator-$ORCHESTRATOR_VERSION.jar </code> I run mvn clean package before running the docker-compose file. Thanks a lot for your help.
At the end of the journey, I have found the solution, and yes after modifying the spring properties to these below new properties: <code>camel.component.rabbitmq.hostname=localhost camel.component.rabbitmq.port=5672 camel.component.rabbitmq.username=adminsi camel.component.rabbitmq.password=test </code> In this manner, we can tell camel which is bounded to rabbitmq about the host, port, username, and password, before just rabbitmq knows these properties, as a result, camel cannot resolve the rabbitmq's host. Then I changed the docker-compose environment for the orchestrator container: <code>version: '3.3' services: rabbitmq: image: rabbitmq:3.8-management container_name: rabbitmq ports: - 5673:5673 - 5672:5672 - 15672:15672 networks: - orchestrator-rabbitmq environment: - RABBITMQ_DEFAULT_USER=adminsi - RABBITMQ_DEFAULT_PASS=test orchestrator: restart: on-failure build: context: . dockerfile: Dockerfile args: VERSION: ${VERSION} environment: - camel_component_rabbitmq_hostname=rabbitmq - camel_component_rabbitmq_port=5672 - camel_component_rabbitmq_username=adminsi - camel_component_rabbitmq_password=test container_name: orchestrator depends_on: - rabbitmq networks: - orchestrator-rabbitmq ports: - 7127:7127 networks: orchestrator-rabbitmq: external: name: orchestrator-rabbitmq </code> I have modified the rabbitmq's host property (camel_component_rabbitmq_hostname) to rabbitmq for container resolution. I hope that my solution works for you, enjoy !
apache-camel
I have the below route and bean to get the message from the property file. In some message I have to replace the arguments in the message. Therefore I have looked for a solution without writing 2 methods in the bean one with arguments (<code>getMessageWithArgs</code>) and the second without arguments (<code>getMessage</code>). Is it doable to get rid of <code>getMessageWithArgs</code> in the bean by using DSL in the route or to make the arguments in the <code>getMessage</code> optional so I have at the end one method in the bean? Route <code>@Override public void configure() throws Exception { from("activemq:queue:1234") .setHeader("functionId", simple(FUNCTION_ID)) .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { Message message = exchange.getIn(); message.setHeader("messageId", "notice_1234_error_messageBox_1"); // List<String> arguments = Arrays.asList("Test1", "Test2", "Test3"); // message.setHeader("arguments", arguments); } }) .setHeader("message").method("messageBean", "getMessage( ${header.functionId}, ${header.messageId})") //.setHeader("message").method("messageBean", "getMessageWithArgs( ${header.functionId}, ${header.messageId}, ${header.arguments})") .log("after calling getMessageWithoutValidation: ${body}"); } </code> Bean <code>@Component public class MessageBean { public String getMessage(@Header("functionId") String functionId, @Header("messageId") String messageId) { //Doing something to get the message return message; } public String getMessageWithArgs(@Header("functionId") String functionId, @Header("messageId") String messageId, @Header("arguments") List<String> arguments) { //Doing something to get the message return message; } } </code>
If your goal is to keep only one method, keep only the method where you have all arguments knowing that if the header <code>arguments</code> has not been set, its value will be <code>null</code>. <code>public String getMessage(@Header("functionId") String functionId, @Header("messageId") String messageId, @Header("arguments") List<String> arguments) { if (arguments == null || arguments.isEmpty()) { // No arguments have been provided } else { // Arguments have been provided } return message; } </code>
apache-camel
I'm currently struggling with exposing the REST api in my project using Apache Camel. When I run the project it seems to be fine in the console, but it just doesn't work: curl http://127.0.0.1:8080/materials curl: (7) Failed to connect to 127.0.0.1 port 8080: Connection refused Here's the pom.xml file: <code><?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>Packages</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> <version>3.12.0</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jackson</artifactId> <version>3.12.0</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jdbc</artifactId> <version>3.12.0</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jsonpath</artifactId> <version>3.12.0</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-dbcp2</artifactId> <version>2.8.0</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.28</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.17.2</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId > <version>2.17.2</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-client</artifactId> <version>5.16.2</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-camel</artifactId> <version>5.16.4</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jaxb</artifactId> <version>3.12.0</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jaxb-starter</artifactId> <version>2.25.4</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jms</artifactId> <version>3.15.0</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-broker</artifactId> <version>5.16.4</version> </dependency> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.4.0-b180830.0359</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-xml-provider</artifactId> <version>2.13.2</version> </dependency> <dependency> <groupId>commons-validator</groupId> <artifactId>commons-validator</artifactId> <version>1.7</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-rest</artifactId> <version>3.12.0</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-servlet</artifactId> <version>3.12.0</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-servlet-starter</artifactId> <version>3.0.0-RC3</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jackson-starter</artifactId> <version>3.0.0-RC3</version> </dependency> </dependencies> </project> </code> Here's the code I wrote: <code>package com.release11.output; import com.release11.xjc.materials.ObjectFactory; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.jms.JmsComponent; import org.apache.camel.converter.jaxb.JaxbDataFormat; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.model.rest.RestBindingMode; import javax.jms.Connection; import javax.xml.bind.JAXBContext; public class OutputAdapter1 { public static void main(String[] args) throws Exception{ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61616"); Connection connection = connectionFactory.createConnection(); connection.start(); CamelContext context = new DefaultCamelContext(); context.addComponent("activemq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); JaxbDataFormat xmlDataFormat = new JaxbDataFormat(jaxbContext); xmlDataFormat.setIgnoreJAXBElement(false); restConfiguration() .component("servlet") .host("localhost") .port("8080") .bindingMode(RestBindingMode.auto); from("activemq:topic:MATERIALS_ENRICHED") .unmarshal(xmlDataFormat) .filter(simple("${body.type} in 'A1,A2,A3'")) .to("direct:materials"); rest("/materials") .get().route() .to("direct:materials"); } }); context.start(); } } </code> I'm not sure to put the build output here because it's quite long so I'll put only a fragment where those routes start: 12:47:22.591 [main] DEBUG org.apache.camel.component.jms.JmsConsumer - Started listener container org.apache.camel.component.jms.DefaultJmsMessageListenerContainer@52045dbe on destination MATERIALS_ENRICHED 12:47:22.591 [main] DEBUG org.apache.camel.impl.engine.InternalRouteStartupManager - Route: route1 started and consuming from: activemq://topic:MATERIALS_ENRICHED 12:47:22.593 [main] DEBUG org.apache.camel.impl.engine.InternalRouteStartupManager - Route: route2 >>> Route[rest://get:/materials?consumerComponentName=servlet&routeId=route2 -> null] 12:47:22.593 [main] DEBUG org.apache.camel.impl.engine.InternalRouteStartupManager - Starting consumer (order: 1001) on route: route2 12:47:22.593 [main] DEBUG org.apache.camel.support.DefaultConsumer - Build consumer: Consumer[servlet:/materials?httpMethodRestrict=GET] 12:47:22.593 [main] DEBUG org.apache.camel.support.DefaultConsumer - Init consumer: Consumer[servlet:/materials?httpMethodRestrict=GET] 12:47:22.593 [main] DEBUG org.apache.camel.support.DefaultConsumer - Starting consumer: Consumer[servlet:/materials?httpMethodRestrict=GET] 12:47:22.595 [main] DEBUG org.apache.camel.http.common.DefaultHttpRegistry - Registering consumer for path /materials providers present: 0 12:47:22.595 [main] DEBUG org.apache.camel.impl.engine.InternalRouteStartupManager - Route: route2 started and consuming from: servlet:/materials 12:47:22.597 [main] INFO org.apache.camel.impl.engine.AbstractCamelContext - Routes startup summary (total:2 started:2) 12:47:22.597 [main] INFO org.apache.camel.impl.engine.AbstractCamelContext - Started route1 (activemq://topic:MATERIALS_ENRICHED) 12:47:22.597 [main] INFO org.apache.camel.impl.engine.AbstractCamelContext - Started route2 (rest://get:/materials) 12:47:22.597 [main] INFO org.apache.camel.impl.engine.AbstractCamelContext - Apache Camel 3.12.0 (camel-1) started in 525ms (build:81ms init:296ms start:148ms) 12:47:22.610 [main] DEBUG org.apache.camel.impl.DefaultCamelContext - start() took 457 millis Please inform me in the comments shall I put the full build output so I'll edit the ticket. Please help me. Thanks.
The component <code>camel-servlet</code> is not meant to be used in standalone mode as you are trying to do. It is meant to be used when you deploy your Camel application on a Servlet container or an Application Server. In standalone mode, if you want to expose a rest endpoint, you should rather use a component like <code>camel-undertow</code>, <code>camel-jetty</code>, <code>camel-netty-http</code> or <code>camel-platform-http</code> (you can find the full list here). Assuming that you want to use <code>undertow</code>, you will have to follow the next steps In your pom file you need to replace <code>camel-rest</code> with <code>camel-undertow</code>, as next: <code><dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-undertow</artifactId> <version>3.12.0</version> </dependency> </code> Then, you just need to change your rest configuration to use <code>undertow</code> and it should be good: <code>restConfiguration() .component("undertow") .port(8080) .bindingMode(RestBindingMode.auto); </code>
apache-camel
Following the official documentation (https://camel.apache.org/manual/component-dsl.html#_using_component_dsl) I created this code: <code>package mygroupid.standalone; import org.apache.camel.CamelContext; import org.apache.camel.impl.DefaultCamelContext; public class MyMain { public static void main(String[] args) throws Exception { CamelContext context = new DefaultCamelContext(); context.start(); ComponentsBuilderFactory.kafka() .brokers("{{kafka.host}}:{{kafka.port}}") .register(camelContext, "kafka"); context.close(); } } </code> But the <code>Red Hat Language Server</code> in <code>VSCode</code> tells me: <code>ComponentsBuilderFactory cannot be resolved</code> And the <code>quick fix</code> feature in <code>VSCode</code> doesn't propose an import of a corresponding library. Can someone point me to the right direction? Do I have to understand the concept of <code>dependency injection</code> to do this?
As stated into the documentation that you are referring to, you need to add the next dependency to your project: <code><dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-componentdsl</artifactId> <version>x.x.x</version> </dependency> </code> Where <code>x.x.x</code> is the same version as the version of Camel that you use If you don't use any build tool like maven, gradle..., you can download the jar file directly from the repository and add it to your classpath. Don't forget to properly manage your property placeholders <code>{{kafka.host}}</code> and <code>{{kafka.port}}</code> as described here or replace <code>"{{kafka.host}}:{{kafka.port}}"</code> with your target broker hostname and port.
apache-camel
The documentation in the "Getting Started" section says the following: "1. Create a CamelContext object." https://camel.apache.org/manual/book-getting-started.html#BookGettingStarted-CamelContext I tried it like this: <code>import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.main.Main; import org.apache.camel.model.dataformat.JsonLibrary; public class CamelDemoMainClass { public static void main(String[] args) throws Exception { CamelContext camelContext = new CamelContext(); } } </code> But the language server in VS Code says the following: "Cannot instantiate the type CamelContext" And I also tried using <code>DefaultCamelContext</code> instead of <code>CamelContext</code> because I have seen it in some other project, but with the same result.
There are several ways to create a <code>CamelContext</code> depending on how you want to launch Camel (Standalone, Spring Boot, Quarkus, CDI...). Assuming that you want to launch Camel in standalone mode, you can create it using <code>DefaultCamelContext</code>. Like in the next basic example: <code>public final class CamelBasic { public static void main(String[] args) throws Exception { // create a CamelContext try (CamelContext camel = new DefaultCamelContext()) { // add routes which can be inlined as anonymous inner class // (to keep all code in a single java file for this basic example) camel.addRoutes(createBasicRoute()); // start is not blocking camel.start(); // so run for 10 seconds Thread.sleep(10_000); } } static RouteBuilder createBasicRoute() { return new RouteBuilder() { @Override public void configure() { from("timer:foo") .log("Hello Camel"); } }; } } </code> Source: https://github.com/apache/camel-examples/tree/main/examples/basic
apache-camel
I am trying to get a http response out of the JSLT Transformer within Apache Camel. Like in the given code sample <code>rest("/transform") .post("/start") .route() .to("jslt:transform.jslt").transform().body </code> I want to return the body after the transformation. But I always get an exception like <code>2022/03/23 14:51:09,842 [ERROR] [CamelHttpTransportServlet] - Error processing request java.lang.IllegalStateException: getWriter() has already been called for this response </code> After adding a logger I can confirm that the jslt transformation into the body is working fine. Plain responses like <code>rest("/say") .get("/hello").route().transform().constant("Hello World"); </code> work. I think it has to do with the implementation of the JSLT Transform.
It depends on your actual use case but assuming that you post a json payload to your endpoint then what you want to achieve can be done as next assuming that you use <code>camel-undertow</code>: <code>// configure rest-dsl restConfiguration() // to use undertow component and run on port 8080 .component("undertow").port(8080); // The endpoint /transform/start calls the route `direct:jslt` rest("/transform") .post("/start").consumes("application/json").to("direct:jslt"); from("direct:jslt") // Convert the payload to a String as only String or InputStream // are supported by the component jslt .convertBodyTo(String.class) // Transform the body using the template transform.jslt available from // the classpath .to("jslt:transform.jslt"); </code> The result is directly set in the body of your message so it is what the rest endpoint will return back to the client in its body.
apache-camel
I have parent router that calls other routers. The parent router has all the exception handling logic. In all child routers, on exception, I want to just add properties in the exchange object and leave the actual exception handling in the <code>parent(main)</code> router. Example: <code>public class ParentRouter extends RouteBuilder { @Override public void configure() throws Exception { onException(CustomException.class) .process(new ExceptionProcessor()) .handled(true); from("direct:parent-route").to("direct:child-route"); from("direct:child-route") .onException(CustomException.class) .process(new Processor(){ @Override public process(Exchange exchange){ exchange.setProperty("childExceptionFlg", "true"); } }); } </code> As per my requirement, when <code>CustomExpection</code> is thrown in the child router, it should add a property to the exchange object and the final handling code needs to be executed in the <code>ExceptionProcessor</code> in the parent router.
What you try to achieve can be done using routes dedicated to error handling that call each other (child error handler route calls parent error handler route) or at least a route for the main error handler that is called by the exception policy of your child routes. Something like: <code>// The main logic of the main exception policy is moved to a dedicated // route called direct:main-error-handler onException(CustomException.class) .to("direct:main-error-handler") .handled(true); from("direct:parent-route").to("direct:child-route"); from("direct:child-route") .onException(CustomException.class) // Set the exchange property childExceptionFlg to true .setProperty("childExceptionFlg", constant("true")) // Call explicitly the main logic of the the main exception policy once // the property is set .to("direct:main-error-handler") // Flag the exception as handled .handled(true) .end() // Throw a custom exception to simulate your use case .throwException(new CustomException()); from("direct:main-error-handler") .log("Property childExceptionFlg set to ${exchangeProperty.childExceptionFlg}"); </code> Result: <code>INFO route3 - Property childExceptionFlg set to true </code>
apache-camel
I have many quartz to schedule tasks like (ping, Email, etc.). Is it possible to manage many quartzes in one route in Apache Camel or I have to create route for every quarz? Error: <code>Caused by: org.apache.camel.FailedToStartRouteException: Failed to start route route9 because of Multiple consumers for the same endpoint is not allowed: quartz://myTimer?cron=0+0/1+*+*+*+?+* </code> Code: <code>@Component public class TimingRoute extends RouteBuilder { static final Logger LOGGER = LoggerFactory.getLogger(TimingRoute.class); @Override public void configure() throws Exception { // Every 3 minutes: 0+0/3+*+*+*+?+* // Every 10 seconds: 0/10+*+*+*+*+?+* from("quartz://myTimer?cron=0+0/1+*+*+*+?+*") // .setBody().simple("Current time is " + LocalDateTime.now()) // .log("${body}").to("direct:processPollingEmail"); from("quartz://myTimer?cron=0+0/1+*+*+*+?+*") // .setBody().simple("Current time is " + LocalDateTime.now()) // .log("${body}").to("direct:processPing"); } } </code>
What you did there already is "create route for every quartz". I believe the only reason why you're getting this error is that you gave the same ID to both your quartz endpoints. Try naming them "myTimer" and "myTimer2" (or anything more meaningful like "emailTimer" and "pingTimer") and you should be fine.
apache-camel
My intention is to send a list of messages one by one (messages are generate using values from db). What I do is query and get the message list attach it to the exchange and use split to slipt the messages and it sends Below is my route <code>.process(this::analyseSettlement) .choice() .when() .simple("${header.error_reason} == 001") .log("Settlement Completed") .otherwise() .log("BatchUpload process") .split(body(), flexible().accumulateInCollection(ArrayList.class)) .setHeader(Exchange.HTTP_METHOD).constant(HttpMethod.POST) .removeHeader(Exchange.HTTP_PATH) .marshal().json(JsonLibrary.Jackson) .to("http://localhost:8087/channel/tcp?bridgeEndpoint=true") // analyze response if success then update the table // if not return error .unmarshal(new JacksonDataFormat(InternalTransactionBean.class)) .process(this::analyseBatchUploadResponse) .end() .log("${body}") .process(this::processPostSettlement) </code> What I require is if I find an error in one of the response need to stop sending all un send messages and end the split and go to postProcesssettlement function flow required-> <code> Message list-> send message 1 by one error occurred while processing one message stop processing the rest of the messages and exit the route </code> How to achieve this or If my process of sending batch of messages is not correct please advice me regarding that.
One way to implement what you try to achieve in a Camel route is to use the EIPs <code>doTry</code>, <code>doCatch</code> and <code>doFinally</code> pretty much like the famous try-catch-finally blocks in Java associated with <code>stopOnException</code> to interrupt the execution of the split in case of error. In the example below, I simulate a per line validation of my file content which fails, I then execute something when the exception is caught in my <code>doCatch</code> block and finally execute something else whatever happened in my <code>doFinally</code> block <code>from("file:src/data") .doTry() .split(body().tokenize("\n")).stopOnException() .log("In split ${body}") .throwException(new RuntimeException("Not good")) .end() .endDoTry() .doCatch(RuntimeException.class) .log("In catch: ${body}") .doFinally() .log("In finally: ${body}") .end(); </code> Assuming that the content of my file is: <code>line 1 line 2 line 3 </code> The result of my route is then: <code>In split line 1 In catch: line 1 line 2 line 3 In finally: line 1 line 2 line 3 </code> More details about the EIPs <code>doTry</code>, <code>doCatch</code> and <code>doFinally</code>. More details about the option <code>stopOnException</code>.
apache-camel
I have a problem with ElasticSearch. My application write on Elasticsearch index using Apache Camel routes. Sometimes it happens that my Elasticsearch is not reachable and therefore the data that should be written at that time is lost. Is there a way to make it safe to write to Elasticsearch in order to retrieve data that was not stored during the down period?
Look into using a redelivery policy. For longer term outages, or when redelivery attempts are exhausted, you'd want something like a dead letter queue so the data is not lost.
apache-camel
I'm trying to make unmarshalling a file in a camel route work. I'm using the SmooksDataFormat to do so. Currently I have these things configured: Route: <code>@Component public class MyRoute extends RouteBuilder { @Override public void configure() throws Exception { // @formatter:off SmooksDataFormat sdf = new SmooksDataFormat("smooks-config.xml"); from("file:src/test/resources/input?delete=true&moveFailed=.failed") .routeId("route") .unmarshal(sdf) .to("mock:done"); // @formatter:on } } </code> smooks-config.xml: <code><?xml version="1.0"?> <smooks-resource-list xmlns="https://www.smooks.org/xsd/smooks-2.0.xsd" xmlns:edifact="https://www.smooks.org/xsd/smooks/edifact-2.0.xsd"> <edifact:parser schemaURI="/d96a/EDIFACT-Messages.dfdl.xsd"> <edifact:messageTypes> <edifact:messageType>ORDERS</edifact:messageType> </edifact:messageTypes> </edifact:parser> </smooks-resource-list> </code> Dependencies: (I've tried using the 2.0.0-M3 versions too, but that results in the same exception) <code><dependency> <groupId>org.smooks.cartridges</groupId> <artifactId>smooks-camel-cartridge</artifactId> <version>2.0.0-RC1</version> </dependency> <dependency> <groupId>org.smooks.cartridges.edi</groupId> <artifactId>smooks-edifact-cartridge</artifactId> <version>2.0.0-RC1</version> </dependency> <dependency> <groupId>org.smooks.cartridges.edi</groupId> <artifactId>edifact-schemas</artifactId> <classifier>d96a</classifier> <version>2.0.0-RC1</version> </dependency> # Camel version <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-dependencies</artifactId> <version>3.14.0</version> <type>pom</type> <scope>import</scope> </dependency> </code> Trying to run this result in this exception though: <code>org.smooks.api.SmooksConfigException: Error invoking @PostConstruct method 'postConstruct' on class 'org.smooks.cartridges.dfdl.parser.DfdlParser'. at org.smooks.engine.lifecycle.AbstractLifecyclePhase.invoke(AbstractLifecyclePhase.java:79) at org.smooks.engine.lifecycle.PostConstructLifecyclePhase.doApply(PostConstructLifecyclePhase.java:88) at org.smooks.engine.lifecycle.AbstractLifecyclePhase.apply(AbstractLifecyclePhase.java:61) at org.smooks.engine.lifecycle.DefaultLifecycleManager.applyPhase(DefaultLifecycleManager.java:53) at org.smooks.engine.delivery.JavaContentHandlerFactory.create(JavaContentHandlerFactory.java:94) at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.addContentDeliveryUnit(DefaultContentDeliveryConfigBuilder.java:442) at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyContentDeliveryUnitStrategy(DefaultContentDeliveryConfigBuilder.java:386) at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyStrategy(DefaultContentDeliveryConfigBuilder.java:373) at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ResourceConfigTableIterator.iterate(DefaultContentDeliveryConfigBuilder.java:524) at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder$ResourceConfigTableIterator.access$200(DefaultContentDeliveryConfigBuilder.java:504) at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder.extractContentHandlers(DefaultContentDeliveryConfigBuilder.java:346) at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder.load(DefaultContentDeliveryConfigBuilder.java:238) at org.smooks.engine.delivery.DefaultContentDeliveryConfigBuilder.build(DefaultContentDeliveryConfigBuilder.java:140) at org.smooks.engine.delivery.DefaultContentDeliveryRuntimeFactory.create(DefaultContentDeliveryRuntimeFactory.java:86) at org.smooks.engine.DefaultExecutionContext.<init>(DefaultExecutionContext.java:117) at org.smooks.engine.DefaultExecutionContext.<init>(DefaultExecutionContext.java:94) at org.smooks.Smooks.createExecutionContext(Smooks.java:447) at org.smooks.Smooks.createExecutionContext(Smooks.java:405) at org.smooks.cartridges.camel.dataformat.SmooksDataFormat.unmarshal(SmooksDataFormat.java:127) at org.apache.camel.support.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:64) at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:469) at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:187) at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64) at org.apache.camel.processor.Pipeline.process(Pipeline.java:184) at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398) at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:492) at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:245) at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:206) at org.apache.camel.support.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:202) at org.apache.camel.support.ScheduledPollConsumer.run(ScheduledPollConsumer.java:116) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) at java.base/java.lang.Thread.run(Thread.java:832) Caused by: org.smooks.api.SmooksConfigException: org.smooks.api.SmooksConfigException: java.lang.NoSuchMethodError: 'java.lang.Object scala.Some.value()' at org.smooks.cartridges.edi.EdiDataProcessorFactory.createDataProcessor(EdiDataProcessorFactory.java:87) at org.smooks.cartridges.dfdl.parser.DfdlParser.postConstruct(DfdlParser.java:167) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.smooks.engine.lifecycle.AbstractLifecyclePhase.invoke(AbstractLifecyclePhase.java:75) ... 35 common frames omitted Caused by: org.smooks.api.SmooksConfigException: java.lang.NoSuchMethodError: 'java.lang.Object scala.Some.value()' at org.smooks.cartridges.edifact.EdifactDataProcessorFactory.doCreateDataProcessor(EdifactDataProcessorFactory.java:115) at org.smooks.cartridges.edi.EdiDataProcessorFactory.createDataProcessor(EdiDataProcessorFactory.java:85) ... 41 common frames omitted Caused by: java.lang.NoSuchMethodError: 'java.lang.Object scala.Some.value()' at org.apache.daffodil.util.Misc$.getRequiredResource(Misc.scala:202) at org.apache.daffodil.util.Misc.getRequiredResource(Misc.scala) at org.smooks.cartridges.edifact.EdifactDataProcessorFactory.readVersion(EdifactDataProcessorFactory.java:136) at org.smooks.cartridges.edifact.EdifactDataProcessorFactory.doCreateDataProcessor(EdifactDataProcessorFactory.java:95) ... 42 common frames omitted </code> My dependency tree: <code>[INFO] nl.smooks.test:smooks-test:jar:1.0 [INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.4.5:compile [INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.4.5:compile [INFO] | | +- org.springframework.boot:spring-boot:jar:2.4.5:compile [INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.4.5:compile [INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.4.5:compile [INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.3:compile [INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.3:compile [INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.13.3:compile [INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.30:compile [INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile [INFO] | | \- org.yaml:snakeyaml:jar:1.27:compile [INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.4.5:compile [INFO] | | +- com.fasterxml.jackson.core:jackson-databind:jar:2.12.4:compile [INFO] | | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.4:compile [INFO] | | | \- com.fasterxml.jackson.core:jackson-core:jar:2.12.4:compile [INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.11.4:compile [INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.11.4:compile [INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.11.4:compile [INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.4.5:compile [INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.45:compile [INFO] | | +- org.glassfish:jakarta.el:jar:3.0.3:compile [INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.45:compile [INFO] | +- org.springframework:spring-web:jar:5.3.13:compile [INFO] | | \- org.springframework:spring-beans:jar:5.3.13:compile [INFO] | \- org.springframework:spring-webmvc:jar:5.3.6:compile [INFO] | +- org.springframework:spring-aop:jar:5.3.13:compile [INFO] | +- org.springframework:spring-context:jar:5.3.13:compile [INFO] | \- org.springframework:spring-expression:jar:5.3.13:compile [INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.4.5:compile [INFO] | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.4.5:compile [INFO] | | \- org.springframework.boot:spring-boot-actuator:jar:2.4.5:compile [INFO] | \- io.micrometer:micrometer-core:jar:1.6.6:compile [INFO] | +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile [INFO] | \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime [INFO] +- org.apache.camel.springboot:camel-spring-boot-starter:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-spring-boot:jar:3.14.0:compile [INFO] | | +- org.apache.camel:camel-spring:jar:3.14.0:compile [INFO] | | | +- org.apache.camel:camel-management-api:jar:3.14.0:compile [INFO] | | | \- org.springframework:spring-tx:jar:5.3.13:compile [INFO] | | +- org.apache.camel:camel-spring-main:jar:3.14.0:compile [INFO] | | | \- org.apache.camel:camel-main:jar:3.14.0:compile [INFO] | | | \- org.apache.camel:camel-base:jar:3.14.0:compile [INFO] | | +- org.apache.camel:camel-xml-jaxb-dsl:jar:3.14.0:compile [INFO] | | | +- org.apache.camel:camel-core-model:jar:3.14.0:compile [INFO] | | | | \- org.apache.camel:camel-core-processor:jar:3.14.0:compile [INFO] | | | \- org.apache.camel:camel-dsl-support:jar:3.14.0:compile [INFO] | | | \- org.apache.camel:camel-endpointdsl:jar:3.14.0:compile [INFO] | | +- org.apache.camel:camel-cloud:jar:3.14.0:compile [INFO] | | +- org.apache.camel:camel-cluster:jar:3.14.0:compile [INFO] | | | \- org.apache.camel:camel-base-engine:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-health:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-core-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-core-engine:jar:3.14.0:compile [INFO] | | +- org.apache.camel:camel-api:jar:3.14.0:compile [INFO] | | +- org.apache.camel:camel-core-reifier:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-util:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-bean-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-bean:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-browse-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-browse:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-controlbus-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-controlbus:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-dataformat-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-dataformat:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-dataset-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-dataset:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-direct-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-direct:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-directvm-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-directvm:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-file-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-file:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-language-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-language:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-log-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-log:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-mock-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-mock:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-ref-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-ref:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-rest-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-rest:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-tooling-model:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-util-json:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-saga-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-saga:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-scheduler-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-scheduler:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-seda-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-seda:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-stub-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-stub:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-timer-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-timer:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-validator-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-validator:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-vm-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-vm:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-xpath-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-xpath:jar:3.14.0:compile [INFO] | +- org.apache.camel.springboot:camel-xslt-starter:jar:3.14.0:compile [INFO] | | \- org.apache.camel:camel-xslt:jar:3.14.0:compile [INFO] | \- org.apache.camel.springboot:camel-xml-jaxp-starter:jar:3.14.0:compile [INFO] | \- org.apache.camel:camel-xml-jaxp:jar:3.14.0:compile [INFO] | \- org.apache.camel:camel-xml-io-util:jar:3.14.0:compile [INFO] +- org.apache.camel.springboot:camel-jmx-starter:jar:3.14.0:compile [INFO] | \- org.apache.camel:camel-jmx:jar:3.14.0:compile [INFO] | +- org.apache.camel:camel-support:jar:3.14.0:compile [INFO] | \- org.apache.camel:camel-management:jar:3.14.0:compile [INFO] +- org.jolokia:jolokia-core:jar:1.6.2:compile [INFO] | \- com.googlecode.json-simple:json-simple:jar:1.1.1:compile [INFO] +- org.smooks.cartridges:smooks-camel-cartridge:jar:2.0.0-RC1:compile [INFO] | \- org.smooks.cartridges:smooks-javabean-cartridge:jar:2.0.0-RC1:compile [INFO] | \- org.smooks:smooks-core:jar:2.0.0-RC1:compile [INFO] | +- org.smooks:smooks-commons:jar:2.0.0-RC1:compile [INFO] | | +- org.smooks:smooks-api:jar:2.0.0-RC1:compile [INFO] | | +- org.freemarker:freemarker:jar:2.3.31:compile [INFO] | | \- javax.inject:javax.inject:jar:1:compile [INFO] | +- com.thoughtworks.xstream:xstream:jar:1.4.18:compile [INFO] | | \- io.github.x-stream:mxparser:jar:1.2.2:compile [INFO] | | \- xmlpull:xmlpull:jar:1.1.3.1:compile [INFO] | +- org.mvel:mvel2:jar:2.4.14.Final:compile [INFO] | +- jaxen:jaxen:jar:1.2.0:compile [INFO] | +- com.fasterxml:classmate:jar:1.5.1:compile [INFO] | +- com.fasterxml:aalto-xml:jar:1.3.1:compile [INFO] | +- com.fasterxml.woodstox:woodstox-core:jar:6.2.8:compile [INFO] | | \- org.codehaus.woodstox:stax2-api:jar:4.2.1:compile [INFO] | +- xml-apis:xml-apis:jar:1.4.01:compile [INFO] | \- com.google.code.findbugs:jsr305:jar:3.0.2:compile [INFO] +- org.smooks.cartridges.edi:smooks-edifact-cartridge:jar:2.0.0-RC1:compile [INFO] | +- com.github.spullara.mustache.java:compiler:jar:0.9.10:compile [INFO] | +- org.smooks.cartridges.edi:smooks-edi-cartridge:jar:2.0.0-RC1:compile [INFO] | | \- org.smooks.cartridges.edi:edi-schemas:jar:2.0.0-RC1:compile [INFO] | \- org.smooks.cartridges:smooks-dfdl-cartridge:jar:1.0.0-RC1:compile [INFO] | \- org.apache.daffodil:daffodil-japi_2.12:jar:3.2.1:compile [INFO] | +- org.scala-lang:scala-library:jar:2.11.11:compile [INFO] | +- org.apache.daffodil:daffodil-core_2.12:jar:3.2.1:compile [INFO] | | +- org.apache.daffodil:daffodil-runtime1-unparser_2.12:jar:3.2.1:compile [INFO] | | | +- org.apache.daffodil:daffodil-runtime1_2.12:jar:3.2.1:compile [INFO] | | | | \- org.apache.daffodil:daffodil-io_2.12:jar:3.2.1:compile [INFO] | | | | \- org.apache.daffodil:daffodil-lib_2.12:jar:3.2.1:compile [INFO] | | | \- org.apache.daffodil:daffodil-runtime1-layers_2.12:jar:3.2.1:compile [INFO] | | \- org.apache.daffodil:daffodil-udf_2.12:jar:3.2.1:compile [INFO] | +- com.lihaoyi:os-lib_2.12:jar:0.8.0:compile [INFO] | | \- com.lihaoyi:geny_2.12:jar:0.7.0:compile [INFO] | +- org.scala-lang.modules:scala-xml_2.12:jar:2.0.1:compile [INFO] | +- org.scala-lang.modules:scala-parser-combinators_2.12:jar:2.1.0:compile [INFO] | +- com.ibm.icu:icu4j:jar:70.1:compile [INFO] | +- xerces:xercesImpl:jar:2.12.0:compile [INFO] | +- xml-resolver:xml-resolver:jar:1.2:compile [INFO] | +- commons-io:commons-io:jar:2.11.0:compile [INFO] | +- com.typesafe:config:jar:1.4.1:compile [INFO] | +- org.apache.logging.log4j:log4j-api-scala_2.12:jar:12.0:compile [INFO] | | \- org.scala-lang:scala-reflect:jar:2.12.10:compile [INFO] | +- org.apache.logging.log4j:log4j-api:jar:2.15.0:compile [INFO] | \- org.jdom:jdom2:jar:2.0.6:compile [INFO] +- org.smooks.cartridges.edi:edifact-schemas:jar:d96a:2.0.0-RC1:compile [INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.4.5:test [INFO] | +- org.springframework.boot:spring-boot-test:jar:2.4.5:test [INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.4.5:test [INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test [INFO] | | +- net.minidev:json-smart:jar:2.3:test [INFO] | | | \- net.minidev:accessors-smart:jar:1.2:test [INFO] | | | \- org.ow2.asm:asm:jar:5.0.4:test [INFO] | | \- org.slf4j:slf4j-api:jar:1.7.30:compile [INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile [INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile [INFO] | +- org.assertj:assertj-core:jar:3.18.1:test [INFO] | +- org.hamcrest:hamcrest:jar:2.2:test [INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.8.1:test [INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.8.1:test [INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test [INFO] | | | +- org.junit.platform:junit-platform-commons:jar:1.8.1:test [INFO] | | | \- org.apiguardian:apiguardian-api:jar:1.1.2:test [INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.8.1:test [INFO] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.8.1:test [INFO] | | \- org.junit.platform:junit-platform-engine:jar:1.8.1:test [INFO] | +- org.mockito:mockito-core:jar:3.6.28:test [INFO] | | +- net.bytebuddy:byte-buddy:jar:1.10.22:test [INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.10.22:test [INFO] | | \- org.objenesis:objenesis:jar:3.1:test [INFO] | +- org.mockito:mockito-junit-jupiter:jar:3.6.28:test [INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test [INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test [INFO] | +- org.springframework:spring-core:jar:5.3.13:compile [INFO] | | \- org.springframework:spring-jcl:jar:5.3.6:compile [INFO] | +- org.springframework:spring-test:jar:5.3.13:test [INFO] | \- org.xmlunit:xmlunit-core:jar:2.7.0:test [INFO] \- org.apache.camel:camel-test-spring-junit5:jar:3.14.0:test [INFO] +- org.apache.camel:camel-test-junit5:jar:3.14.0:test [INFO] | \- org.apache.camel:camel-core-languages:jar:3.14.0:compile [INFO] \- org.apache.camel:camel-spring-xml:jar:3.14.0:compile [INFO] +- org.apache.camel:camel-xml-jaxb:jar:3.14.0:compile [INFO] | +- com.sun.xml.bind:jaxb-core:jar:2.3.0:compile [INFO] | \- com.sun.xml.bind:jaxb-impl:jar:2.3.3:compile [INFO] | \- com.sun.activation:jakarta.activation:jar:1.2.2:runtime [INFO] \- org.apache.camel:camel-core-xml:jar:3.14.0:compile </code> Can anyone tell me what I'm doing wrong here?
I've figured out that this wrong version of the <code>scala-library</code> came from my dependency management dependency: <code><dependencyManagement> <dependencies> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-dependencies</artifactId> <version>3.14.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> </code> After updating it to this, it does bring in the right version: <code><dependencyManagement> <dependencies> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-bom</artifactId> <version>3.14.2</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> </code>
apache-camel
While monitoring an Apache Camel application with hawt.io, I noticed that the nodes of a camel route have some properties that I cannot influence with the Java DSL, but which are displayed in hawt.io. It would be pretty awesome if you could define them anyway. I am particularly interested in the id and the description of a node in the route. My route currently looks something like this (screenshot below): My route rabbitmq://tso11 log4 process4 to3 process5 to4 The displayed names (log4, process4, process5, ...) are automatically generated "id" properties. There is also an always empty property "description". It would be awesome if I could change this somehow for a much better readable route: My route rabbitmq://tso11 log incoming message process for header extraction to xslt processor additional-mappint.xslt process for conversion to nms42 format to nms42 endpoint Maybe there is a way? Maybe only with XML based DSL? Here is a screenshot:
In Java DSL, you can set the id of a node thanks to the method <code>id(String id)</code>. In the next example, the id of the endpoint <code>mock:bar</code> has been set to <code>bar</code>: <code>from("direct:start") .to("mock:foo") .to("mock:bar").id("bar") .to("mock:result"); </code>
apache-camel
I'm currently working with Apache Camel and hawt.io for monitoring and debugging my Camel routes. This works wonderfully, even if some important information is somewhat hidden in the documentation. For example, it took me a bit to turn on debugging. However, if I set a breakpoint where the message processing stops at that point in the route, I can't see any "body" or "headers" of my Camel exchange at that point. I've tried all sorts of settings: tracing / backlog tracing enabled on CamelContext tracing / backlog tracing enabled on route Adjusted settings on MBean "BacklogDebugger" and "BacklogTracer". Tracing on the "Trace" tab works very well: If I activate tracing in the "Trace" tab, I can see the flow of my message through all nodes of the route. Only when stopping at the breakpoint is the body and header not displayed. Edited: After some changes concerning other aspects (like assigning an ID to most of the route nodes) debugging works including display of body and headers. I have no clue what changed to make it work. And at the same time my application property "camel.main.debugging=true" failed on startup <code>Error binding property (camel.main.debugging=true) with name: debugging on bean: org.apache.camel.main.MainConfigurationProperties </code> I had to enabled debugging at the context like this: <code>getContext().setDebugging(true); </code> Here is some information: I don't use any special framework: Plain old Java with a Main method in which I start Camel-Main. Apache Camel: 3.14.1 Jolokai Agent: 1.7.1 hawt.io: 2.14.5 Exchange body type: DOMSource One of my routes: <code>getCamelContext().setBacklogTracing(true); from(rabbitMqFactory.queueConnect("tso11", "tso11-to-nms", "username")) .routeGroup("Workflow") .routeId("Workflow-to-NMS|Map-TSO11-to-NMS42") .routeDescription("Mapping of TSO11 Message to NMS42") .convertBodyTo(DOMSource.class) .log("Message for '$simple{header:tenant}' received") .process(tso11ToNmsMappingProcessor) .to("xslt:xslt/tso11-to-nms42.xslt") .to("direct:send"); </code> And here are my current properties: <code>camel.main.name=TSO11 camel.main.jmxEnabled=true camel.main.debugging=true camel.main.backlogTracing=true camel.main.lightweight=false camel.main.tracing=false camel.main.useBreadcrumb=true </code> Any ideas? Any hints for a good documentation? I have some more less important questions but I will open another issue for those. With kind recards Bert Finally here are screenhots of debugging tab (with empty body) and trace tab (with body content):
I found the reason for my problem: I used Camel 3.15.0 which is currently not supported by the camel plugin of hawt.io. When using latest 3.14.x it works like a charm :-) Hopefully there is still a maintainer of the camel plugin who will improve it in the near future. I am willing to contribute but the hawt.io developer information is not accessible and I am not able to understand how to run hawt.io from source locally .... especially how to include the camel plugin, which is in a separate github project.
apache-camel
When I try to marshal data I got from the database in Apache Camel using JAXB and providing XSD schema I get the error java.io.org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: java.util.LinkedHashMap to the required type: java.io.InputStream with value {id=5, number=5599, type=B3, ... } when I try to send the message to ActiveMQ. I'm new to integration and this is my intern Camel project. When I marshal the message to json everything is alright. I thought about converting the message to json and then to XML, but it seems to me that isn't the way I should do it. I've got a prepared XSD schema that looks like this: <code><?xml version="1.0" encoding="UTF-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:pc="com.release11.packages" targetNamespace="com.release11.materials"> <xs:import schemaLocation="packages.xsd" namespace="com.release11.packages"/> <xs:simpleType name="materialTypeType"> <xs:restriction base="xs:string"> <xs:enumeration value="A1"/> <xs:enumeration value="A2"/> <xs:enumeration value="A3"/> <xs:enumeration value="B1"/> <xs:enumeration value="B2"/> <xs:enumeration value="B3"/> <xs:enumeration value="C1"/> <xs:enumeration value="C2"/> <xs:enumeration value="C3"/> </xs:restriction> </xs:simpleType> <xs:complexType name="materialType"> <xs:sequence> <xs:element name="Id" type="xs:integer"/> <xs:element name="Number" type="xs:integer"/> <xs:element name="Type" type="materialTypeType"/> <xs:element name="Name" type="xs:string"/> <xs:element name="Description" type="xs:string"/> <xs:element name="Is_deleted" type="xs:boolean"/> <xs:element ref="pc:Packages" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="materialsType"> <xs:sequence> <xs:element name="Material" type="materialType" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:element name="Materials" type="materialsType"/> </xs:schema> </code> I tried to find the answer on the web, but I found nothing useful or I couldn't understand the answer so I need someone to explain this to me. Please help me. Here's my code: <code>public class InputAdapter { public static void main(String[] args) throws Exception { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl("jdbc:mysql://localhost:3306/Packages"); dataSource.setUsername("uname"); dataSource.setPassword("passwd"); SimpleRegistry registry = new SimpleRegistry(); registry.bind("dataSource", dataSource); ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(); activeMQConnectionFactory.setBrokerURL("tcp://127.0.0.1:61616"); Connection connection = activeMQConnectionFactory.createConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue("MESSAGES_RAW"); MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); CamelContext context = new DefaultCamelContext(registry); context.addComponent("activemq", JmsComponent.jmsComponentAutoAcknowledge(activeMQConnectionFactory)); context.addRoutes(new RouteBuilder() { @Override public void configure() { JaxbDataFormat dataFormat = new JaxbDataFormat(); dataFormat.setSchemaLocation("material.xsd"); from("timer://foo?repeatCount=1") .setBody(constant("SELECT * FROM material;")) .to("jdbc:dataSource") .split(body()) .marshal(dataFormat) .to("activemq:queue:MESSAGES_RAW"); } }); context.start(); Thread.sleep(1000); context.stop(); } } </code>
Generating classes from XSD with CLI tool You can use xjc command-line tool that comes pre-installed with at JDK 8 to generate jaxb classes. Example: <code>xjc material.xsd # With groupId xjc -p <groupId> material.xsd # With groupId and bindings configuration file xjc -p <groupId> -b bindings.xjb material.xsd </code> Generating classes from XSD using maven plugin Alternatively you can use maven plugin to do the same. By default the plugin will look for schema xsd files from <code>src/main/xsd</code> and bindings xjb files from <code>src/main/xjb</code> <code><build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>2.5.0</version> <executions> <execution> <id>xjc</id> <goals> <goal>xjc</goal> </goals> </execution> </executions> <configuration> <packageName>com.example.group</packageName> </configuration> </plugin> </plugins> </build> </code> If you're using JDK 11 or later you'll also have to include couple of related dependencies that are no longer included in the JDK. <code><dependencies> <dependency> <groupId>jakarta.xml.bind</groupId> <artifactId>jakarta.xml.bind-api</artifactId> <version>2.3.3</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-xjc</artifactId> <version>2.3.6</version> </dependency> </dependencies> </code> With these maven should generate the classes to <code>target/generated-sources/jaxb</code> folder after running <code>mvn clean install</code>. With maven plugin you're better off creating separate api-project for these and adding it as a dependency for your camel integration project. Usage in camel You can use jaxb with camel by creating JaxbDataFormat using JAXBContext instance. <code>JAXBContext jaxbContext = JAXBContext.newInstance(Materials.class); JaxbDataFormat jaxbDataformat = new JaxbDataFormat(jaxbContext); from("direct:marshalMaterials") .routeId("marshalMaterials") .marshal(jaxbDataformat) .log("${body}"); </code> Since you're querying a database that by default returns list of maps, you'll have to convert it to appropriate Jaxb object. You can use generated <code>ObjectFactory</code> class to generate different jaxb class instances. With JDK 11 you might also need following dependencies <code><dependency> <groupId>jakarta.xml.bind</groupId> <artifactId>jakarta.xml.bind-api</artifactId> <version>2.3.3</version> </dependency> <!-- versions obtained from dependency-management camel-bom --> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-core</artifactId> </dependency> </code> Namespace change from javax to jakarta More recent versions of jaxb are using jakarta namespace instead of javax. If you want to use the newer jakarta namespace instead you can use <code>jaxb2-maven-plugin</code> and <code>jakarta.xml.bind-api</code> version 3.x or higher. Support for Jakarta namespace is planned for Camel 4.x so if you're using Camel 3.x you might want to wait or upgrade to that first. Bindings XJB files With bindings xjb files you can tweak how classes get generated like change class or property names, prevent nested class mess etc. Example: Empty binding file template <code><?xml version="1.0" encoding="UTF-8"?> <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1" xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"> ... </jaxb:bindings> </code>
apache-camel
I am reading a file from a directory, and trying to call an API based on the data in the file. While trying to handle the exceptions, I am facing an issue. I am trying to configure the onException block to redeliver 3 times, with a delay of 5 seconds. The issue occurs, when I am setting <code>handled(true)</code>. This configuration does not redeliver, and stops as soon as the exception occurs. This is my <code>onException</code> block: <code> onException(HttpOperationFailedException.class) .log(LoggingLevel.ERROR, logger, "Error occurred while connecting to API for file ${header.CamelFileName} :: ${exception.message}") .log("redelivery counter :: ${header.CamelRedeliveryCounter}") .maximumRedeliveries(3) .redeliveryDelay(5000) .handled(true); </code> How do I do both, i.e. handle as well as redeliver?
Unless you use a buggy version of Camel, the redeliveries are made as expected whatever if it is handled or not. The only difference between handled or not, is the fact that the result sent back to the client once the retries are exhausted will be either the exception (not handled) or the result of your <code>onException</code> (handled). Your mistake here, is the fact that you assume that the log EIPs that you have defined in your <code>onException</code> are called for each retry while they are actually called only when the retries are exhausted. If you want to see the retries in your logs, you can use <code>retryAttemptedLogLevel</code> as next: <code> onException(HttpOperationFailedException.class) .maximumRedeliveries(3) .redeliveryDelay(5000) .retryAttemptedLogLevel(LoggingLevel.WARN); </code> You will then get warning messages of type: <code>Failed delivery for (MessageId: X on ExchangeId: Y). On delivery attempt: Z caught: ... </code>
apache-camel
I am new to using jolt Currently facing issues combining array of maps. I have an array of maps, 1 key in each map has an array of strings - as shown in input JSON. I am trying to combine all the key/values into single array of maps - as shown in expected output When combined the values are getting merged rather than being adding separately. Any help is appreciated. Input JSON <code> { "items": [ { "frontItem": [ "frontItem1" ], "base": "base1" }, { "frontItem": [ "frontItem2", "frontItem3" ], "base": "base2" } ] } </code> Jolt Spec created <code>[ { "operation": "shift", "spec": { "items": { "*": { "frontItem": { "*": { "@": "modified-items.[&].frontItem", "@(2,base)": "modified-items.[&].base" } } } } } } ] </code> Expected output <code>{ "modified-items": [ { "frontItem": "frontItem1", "base": "base1" }, { "frontItem": "frontItem2", "base": "base2" }, { "frontItem": "frontItem3", "base": "base2" } ] } </code> Current output with spec created <code>{ "modified-items": [ { "frontItem": [ "frontItem1", "frontItem2" ], "base": [ "base1", "base2" ] }, { "frontItem": "frontItem3", "base": "base2" } ] } </code>
You're so close to reach the solution. Just seperate the values by <code>@(3,base)</code> while walking through the indexes of the <code>frontItem</code> list such as <code>[ { "operation": "shift", "spec": { "items": { "*": { "frontItem": { "*": { "@": "@(3,base).[&].frontItem", "@(2,base)": "@(3,base).[&].base" } } } } } }, { "operation": "shift", "spec": { "*": { "*": "" } } } ] </code> the demo on the site http://jolt-demo.appspot.com/
apache-camel
Apache camel has added camel developer console in their latest release(3.15.0) I was trying it but after adding dependencies and 'camel.main.dev-console-enabled = true' , I am not able to find the developer console I had tried with endpoint http://localhost:8080/dev Also I am not able to enable dev console when I am using Camel Context wrote in XML DSL. How can i add statement to enable developer console when i have camel context written in XML DSL
It is actually a very new feature, for now, the developer console is only available from http://localhost:8080/dev when you use Camel JBang as mentioned in the documentation. For other modes, you can enable it programmatically by calling <code>context.setDevConsole(true)</code> or in case of Camel Main by setting <code>camel.main.dev-console-enabled</code> to <code>true</code> (as you mentioned) but it is not yet exposed, it can only be accessed programmatically from the <code>DevConsoleRegistry</code> (accessible with <code>context.getExtension(DevConsoleRegistry.class)</code>).
apache-camel
I'm currently working on an integration project. I have to get some data from the MySQL database and them combine them using Apache Camel. In the database I've got two tables, materials and packages. They are in the one-to-many relation, one material can contain multiple packages. I've already figured out how to get data from the database and save them to json file, but I have no idea how to combine those two messages into one. I've read about Aggregations but I don't really get them. This is my first usage of Apache Camel and I don't really know what sould I do now. The code for those routes looks like this: <code>public class InputAdapter{ public static void main(String[] args) throws Exception { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl("jdbc:mysql://localhost:3306/Packages"); dataSource.setUsername("uname"); dataSource.setPassword("passwd"); SimpleRegistry registry = new SimpleRegistry(); registry.bind("dataSource", dataSource); CamelContext context = new DefaultCamelContext(registry); context.addRoutes(new RouteBuilder() { @Override public void configure() { from("timer://foo?repeatCount=1") .setBody(constant("SELECT * FROM material;")) .to("jdbc:dataSource") .marshal().json(true) .to("file:/some/path/to/file?fileName=materials.json"); from("timer://foo?repeatCount=1") .setBody(constant("SELECT * FROM package;")) .to("jdbc:dataSource") .marshal().json(true) .to("file:/some/path/to/file?fileName=packages.json"); } }); context.start(); Thread.sleep(10000); context.stop(); } } </code> And the model for Material and a Package are just private properties with getters and setters: <code>public class Material { private int id; private int number; private enumType type; private String name; private String description; private boolean is_deleted; private List<Package> packageList = new ArrayList<>(); public enum enumType { A1, A2, A3, B1, B2, B3, Z1, Z2, Z3; } public int getId() { return this.id; } ... some getters } public List<Package> getPackageList() { return this.packageList; } public void setId(int id) { this.id = id; } ... some setters public void setPackageList(List<Package> packages) { this.packageList = packages; } } </code> Can someone give me a hint what sould I do now? Please help me.
Aggregators are normally used to combine messages coming in from a source. I probably wouldn't use the aggregators to combine these two sets of items. If you're looking to pull all the Materials and get the associated packages from the database, you might be better to retrieve the list of packages per Material. I would create a Processor that handles retrieving the packages for each of the returned Materials objects and then output the whole thing in a single route. You can define a processor class in Camel like so: <code>public class PackageProcessor implements Processor { @Override public void process(Exchange exchange) { // Transform the input to your message class // Retrieve the Packages // Transform the results to Packages // Add to the Material // Set the Out Body exchange.getMessage().setBody(material); } } </code> You can then use the processor in your Route to do this work. That would make the route look something like this then: <code>from("timer://foo?repeatCount=1") .routeId("my-material-route") .setBody(constant("SELECT * FROM materials;")) .to("jdbc:dataSource") .split(body()) .process(new PackageProcessor()) .setHeader(Exchange.FILE_NAME, simple("${exchangeId}.json")) .marshal().json(true) .to("file:/somepath") .end(); </code> This would output each record to a Json file with the needed information. If you want all of the items to be placed in a single file, this is where an aggregator would come into play. You'll notice a couple of items in the route outside of your original. The result of the JDBC component is an ArrayList<HashMap<String, Object>>. We add a Split in the route to send each item separately into the processor instead of the entire result set. The processor should receive a HashMap<String, Object> in the Exchange Body. After the processor, we set the CamelFileName Header on the exchange to the Exchange Id and this will then output an individual file per record from the Materials table. If you want to have it all in a single file, you can use an Aggregator that will collect the exchanges and build a list. That might be a little more complicated to have it release the exchanges out to a JSON file. You normally have to set a timeout or some sort of evaluation function to figure out when the "super" exchange should be released.
apache-camel
I created a xsd and used it with jaxb plugin like bellow: <code><?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.mycompany.fr/Canonical/Schema/invoices.xsd" targetNamespace="http://www.mycompany.fr/Canonical/Schema/invoices.xsd" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="invoices"> <xs:complexType> <xs:sequence> <xs:element name="invoice" maxOccurs="unbounded" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="invoice-type" type="xs:string"/> <xs:element minOccurs="0" name="insertion-date" type="xs:dateTime"/> <xs:element minOccurs="0" name="amount" type="xs:double"/> </xs:sequence> <xs:attribute name="invoice-number" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </code> The plugin: <code><plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>jaxb2-maven-plugin</artifactId> <version>2.5.0</version> <executions> <execution> <id>xsd-to-java</id> <goals> <goal>xjc</goal> </goals> </execution> </executions> <configuration> <packageName>com.mycompany.model</packageName> <sources> <source>src/main/resources/xsd/invoices.xsd</source> </sources> </configuration> </plugin> </code> It generated me this class: <code>@XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "invoice" }) @XmlRootElement(name = "invoices") public class Invoices { protected List<Invoice> invoice; /** * Gets the value of the invoice property. * * <p> * This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a <CODE>set</CODE> method for the invoice property. * * <p> * For example, to add a new item, do as follows: * <pre> * getInvoice().add(newItem); * </pre> * * * <p> * Objects of the following type(s) are allowed in the list * {@link Invoice } * * */ public List<Invoice> getInvoice() { if (invoice == null) { invoice = new ArrayList<Invoice>(); } return this.invoice; } /** * <p>Classe Java pour anonymous complex type. * * <p>Le fragment de schéma suivant indique le contenu attendu figurant dans cette classe. * * <pre> * &lt;complexType&gt; * &lt;complexContent&gt; * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt; * &lt;sequence&gt; * &lt;element name="invoice-type" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/&gt; * &lt;element name="insertion-date" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/&gt; * &lt;element name="amount" type="{http://www.w3.org/2001/XMLSchema}double" minOccurs="0"/&gt; * &lt;/sequence&gt; * &lt;attribute name="invoice-number" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /&gt; * &lt;/restriction&gt; * &lt;/complexContent&gt; * &lt;/complexType&gt; * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "invoiceType", "insertionDate", "amount" }) public static class Invoice { @XmlElement(name = "invoice-type") protected String invoiceType; @XmlElement(name = "insertion-date") @XmlSchemaType(name = "dateTime") protected XMLGregorianCalendar insertionDate; protected Double amount; @XmlAttribute(name = "invoice-number", required = true) protected String invoiceNumber; /** * Obtient la valeur de la propriété invoiceType. * * @return * possible object is * {@link String } * */ public String getInvoiceType() { return invoiceType; } /** * Définit la valeur de la propriété invoiceType. * * @param value * allowed object is * {@link String } * */ public void setInvoiceType(String value) { this.invoiceType = value; } /** * Obtient la valeur de la propriété insertionDate. * * @return * possible object is * {@link XMLGregorianCalendar } * */ public XMLGregorianCalendar getInsertionDate() { return insertionDate; } /** * Définit la valeur de la propriété insertionDate. * * @param value * allowed object is * {@link XMLGregorianCalendar } * */ public void setInsertionDate(XMLGregorianCalendar value) { this.insertionDate = value; } /** * Obtient la valeur de la propriété amount. * * @return * possible object is * {@link Double } * */ public Double getAmount() { return amount; } /** * Définit la valeur de la propriété amount. * * @param value * allowed object is * {@link Double } * */ public void setAmount(Double value) { this.amount = value; } /** * Obtient la valeur de la propriété invoiceNumber. * * @return * possible object is * {@link String } * */ public String getInvoiceNumber() { return invoiceNumber; } /** * Définit la valeur de la propriété invoiceNumber. * * @param value * allowed object is * {@link String } * */ public void setInvoiceNumber(String value) { this.invoiceNumber = value; } } } </code> And I used this Camel route to unmasharl the xml: <code> JaxbDataFormat jaxbDataFormat = new JaxbDataFormat(); jaxbDataFormat.setSchema("classpath:xsd/invoices.xsd"); from("file:{{xml.location}}?delay=1000") .log("Reading invoice XML data from ${header.CamelFileName}") .unmarshal(jaxbDataFormat) .split(body()) .to("direct:processedXml"); </code> but when I run my application, I got the following error ... [route2 ] [unmarshal1 ] [unmarshal[org.apache.camel.model.dataformat.JaxbDataFormat@7aff8796] ] [ 0] Stacktrace --------------------------------------------------------------------------------------------------------------------------------------- : java.io.IOException: javax.xml.bind.UnmarshalException with linked exception: [com.sun.istack.SAXParseException2; lineNumber: 2; columnNumber: 72; élément inattendu (URI : "http://www.mycompany.fr/Canonical/Schema/invoices.xsd", local : "invoices"). Les éléments attendus sont (none)] at org.apache.camel.converter.jaxb.JaxbDataFormat.unmarshal(JaxbDataFormat.java:312) at org.apache.camel.support.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:64) at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:471) at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:187) at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64) at org.apache.camel.processor.Pipeline.process(Pipeline.java:184) at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398) at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:492) at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:245) at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:206) at org.apache.camel.support.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:202) at org.apache.camel.support.ScheduledPollConsumer.run(ScheduledPollConsumer.java:116) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: javax.xml.bind.UnmarshalException Do you know the problem plz ? Thank a lot and best regards
When unmarshalling, you do not need to refer to a schema, but to a JAXB <code>contextPath</code>. You have to tell JAXB where (=in which packages) to find annotated pojos so that it will be able to turn xml into corresponding java objects. So try this: <code>JaxbDataFormat jaxbDataFormat = new JaxbDataFormat(); jaxbDataFormat.setContextPath("com.mycompany.model"); </code>
apache-camel
I defined a processor with camel which allow me to generate a jaxb java bean with a timer and write the pojo in xml file. But when I launch the application I got the following error: 08:09:00 WARN [or.ap.ca.co.ti.TimerConsumer] (Camel (camel-1) thread #2 - timer://generateInvoice) Error processing exchange. Exchange[20E715FDB7EFE19-0000000000000000]. Caused by: [java.io.IOException - org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: java.util.LinkedList to the required type: java.io.InputStream with value [com.mycompany.model.Invoice@21e27bf, com.mycompany.model.Invoice@1fd7b4bf, com.mycompany.model.Invoice@9cb7bae, com.mycompany.model.Invoice@2751bc51 ... My code is bellow: <code>from("timer:generateInvoice?period={{xml.timer.period}}&delay={{xml.timer.delay}}") .log("Generating randomized invoice XML data") .process("invoiceGenerator") .marshal(jaxbDataFormat) .to("file:{{xml.location}}"); </code> Bellow my generator: <code>@Override public void process(Exchange exchange) throws Exception { Random random = new Random(); List<Invoice> invoices = new LinkedList<>(); for (int i = 0; i < 100; i++) { String invoiceNumber = String.format("invoice-%d", random.nextInt()); Invoice invoice = new Invoice(); invoice.setInvoiceNumber(invoiceNumber); invoice.setAmount(random.nextDouble()); Instant now = Instant.now(); GregorianCalendar cal1 = new GregorianCalendar(); cal1.setTimeInMillis(now.toEpochMilli()); invoice.setInsertionDate(DatatypeFactory.newInstance().newXMLGregorianCalendar()); invoice.setInvoiceType(INVOICE_TYPE[random.nextInt(INVOICE_TYPE.length)]); invoices.add(invoice); } exchange.getMessage().setBody(invoices); } </code> I already tried to implement a converter of java.util.LinkedList to the required type: java.io.InputStream with: <code>@Converter public InputStream ListToInputStream(List<Invoice> invoices) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayInputStream bios = null; try { ObjectFactory objFactory = new ObjectFactory(); JAXBContext jaxbContext = JAXBContext.newInstance("com.webinage.model"); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); for(Invoice invoice : invoices) { marshaller.marshal(invoice, baos); } bios = new ByteArrayInputStream(new byte[baos.size()]); bios.read(baos.toByteArray()); } catch (Exception e) { e.printStackTrace(); } finally { baos.close(); } return bios; } </code> But same exception rise up ... do you have an idea plz ?
Most probably List is not what you want to put into the Exchange. I assume you want output XML to be something like: <code><Invoices> <Invoice>...</Invoice> <Invoice>...</Invoice> ... </Invoices> </code> in which case it's probably most straightforward to declare a container class: <code>@XmlRootElement public class Invoices { private List<Invoice> invoices; } </code> (getter and setter omitted). Then generate your schema and put this <code>Invoices</code> object into the Exchange.
apache-camel
I am unable to read in batch with the kafka camel consumer, despite following an example posted here. Are there changes I need to make to my producer, or is the problem most likely with my consumer configuration? The application in question utilizes the kafka camel component to ingest messages from a rest endpoint, validate them, and place them on a topic. I then have a separate service that consumes them from the topic and persists them in a time-series database. The messages were being produced and consumed one at a time, but the database expects the messages to be consumed and committed in batch for optimal performance. Without touching the producer, I tried adjusting the consumer to match the example in the answer to this question: How to transactionally poll Kafka from Camel? I wasn't sure how the messages would appear, so for now I'm just logging them: <code> from(kafkaReadingConsumerEndpoint).routeId("rawReadingsConsumer").process(exchange -> { // simple approach to generating errors String body = exchange.getIn().getBody(String.class); if (body.startsWith("error")) { throw new RuntimeException("can't handle the message"); } log.info("BODY:{}", body); }).process(kafkaOffsetManager); </code> But the messages still appear to be coming across one at a time with no batch read. My consumer config is this: <code> kafka: host: myhost port: myport consumer: seekTo: beginning maxPartitionFetchBytes: 55000 maxPollRecords: 50 consumerCount: 1 autoOffsetReset: earliest autoCommitEnable: false allowManualCommit: true breakOnFirstError: true </code> Does my config need work, or are there changes I need to make to the producer to have this work correctly?
At the lowest layer, the <code>KafkaConsumer#poll</code> method is going to return an <code>Iterator<ConsumerRecord></code>; there's no way around that. I don't have in-depth experience with Camel, but in order to get a "batch" of records, you'll need some intermediate collection to "queue" the data that you want to eventually send downstream to some "collection consumer" process. Then you will need some "switch" processor that says "wait, process this batch" or "continue filling this batch". As far as databases go, that process is exactly what Kafka Connect JDBC Sink does with <code>batch.size</code> config.
apache-camel
I have a custom class I'm trying to set to an incoming exchange message. But i keep getting this error when I try to set it. <code>java.lang.ClassCastException: java.lang.String cannot be cast to com.models.CsvModel </code> My route is below <code>private final DataFormat bindy = new BindyCsvDataFormat(com.models.CsvModel.class); @Override public void configure() throws Exception { from("{{input.files.csv}}") .routeId("CSVConverter") .split(body().tokenize("\n")) .unmarshal(bindy) .split(body().tokenize(",")) .process(new CsvConverterProcessor()) .to("{{output.files.csv}}"); } </code> And my custom class is this <code>@Component @CsvRecord(separator = " ") public class CsvModel { //some fields with setters, getters, and 2 constructors //fields are annotated with @Datafield and pos } </code> I try to set it in my processor process method as so <code> CsvModel model = (CsvModel) exchange.getIn().getBody();</code> I've seen an example where they do exactly this and it works for them.
It doesn't look like you ever actually converted the exchange body to a CsvModel. To do that, you'll need to call .convertBodyTo() prior to your processor receiving the exchange. <code>.split(body().tokenize(",")) .convertBodyTo(CsvModel.class) .process(new CsvConverterProcessor()) </code> Camel also doesn't know how to convert the exchange body to/from your class, so you'll need to add a custom type converter, either with annotations or by extending the TypeConverter class. Here's a sample skeleton of what you'll need. I would also include a converter to go the other way(CsvModel -> String). You can find full documentation for type converters here: https://camel.apache.org/manual/type-converter.html <code>@Converter(generateBulkLoader = true) public class CsvModelConverter { @Converter public static CsvModelConverter toCsvModel(String data, Exchange exchange) { CsvModel newModel = //Whatever you need to do to convert the string data to your class return csvModel; } } </code>
apache-camel
SOLVED! Scroll down to Solution. I have entity Person with some basic data on table A and more specific data on tables B, C, D, etc (address, for example). PersonResponseDTO (summarized): <code>{ "id": 1, "name": "Test" } </code> AddressResponseDTO (summarized): <code>{ "person_id": 1, "street": "Test St." } </code> These data come from an external API called using <code>from("direct:getPersonById").to(getPersonUrl)</code> and <code>from("direct:getAddressByPersonId").to(getAddressUrl)</code> (summarized). I created a third object called AggregatedPersonResponseDTO: <code>{ "person": { "id": 1, "name": "Test" }, "address": { "person_id": 1, "street": "Test St." } } </code> Is there a simple way to join both responses in a single request, returning an object of type AggregatedPersonResponseDTO, only using the Camel API? I want to use both response objects to build the third one. And I will have use cases in the future with more than two "joins". Solution explanation It's not needed to set streamCaching to either true or false. Not needed to set HTTP_PATH. Code in the Camel route: <code>from("direct:getFullPersonByIdService") .toD("http:{{endpoints.get-person-by-id}}?bridgeEndpoint=true") .pollEnrich( simple("http:{{endpoints.get-address-by-person-id}}?bridgeEndpoint=true"), 5000, new PersonAggregationStrategy(), false ) .unmarshal(new JacksonDataFormat(GetAggregatedPersonResponseDTO.class)) </code> The content between double curly-braces is read from the application.yml or application.properties. The whole PersonAggregationStrategy class: <code>@Log4j2 public class PersonAggregationStrategy implements AggregationStrategy { @SneakyThrows @Override public Exchange aggregate(final Exchange exchangePerson, final Exchange exchangeAddress) { log.info("Aggregating Person and Address..."); ObjectMapper objectMapper = new ObjectMapper(); final GetAggregatedPersonResponseDTO aggregatedPerson = new GetAggregatedPersonResponseDTO(); aggregatedPerson.setPerson(objectMapper.readValue(exchangePerson.getIn().getBody(String.class), GetPersonResponseDTO.class)); aggregatedPerson.setAddress(objectMapper.readValue(exchangeAddress.getIn().getBody(String.class), GetAddressResponseDTO.class)); exchangePerson.getIn().setBody(objectMapper.writeValueAsString(aggregatedPerson)); log.info("Aggregated object => {}", objectMapper.writeValueAsString(aggregatedPerson)); return exchangePerson; } } </code> I also had to implement the TypeConverters interface for the resulting object of the aggregation: <code>@Component public class AggregatedPersonConverter implements TypeConverters { private final ObjectMapper mapper; @Autowired public AggregatedPersonConverter(ObjectMapper mapper) { this.mapper = mapper; } @Converter public InputStream getAggregatedPersonResponseDTOToInputStream(GetAggregatedPersonResponseDTO source) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(source); oos.flush(); oos.close(); } catch (IOException e) { throw new RuntimeException(e); } return new ByteArrayInputStream(baos.toByteArray()); } } </code> I don't know if it works for more than two callbacks. Maybe it will need other implementations of AggregationStrategy. I'll test this use case some day.
You have to model a route which enriches the first web service result with the second one. The way you merge both responses has to be specified in your <code>AggregationStrategy</code> instance. See the enrich EIP: https://camel.apache.org/components/3.14.x/eips/enrich-eip.html
apache-camel
I hope you guys are doing well. We are evaluating some solutions (Apache Camel K and the likes) to allow teams to: Low Code protocol transformation (Kafka, FTP, S3, MQ, SOAP, SFTP, gRPC, GraphQL, etc.) One team in particular has to integrate their product with 100s of external partners (each one uses a different integration technology), and writing each integration "by hand" would be a waste of time/motivation. Enrich integrations' payloads (by calling both internal and external services) Pay per execution/transformation/step (SERVERLESS) Orchestrate processes that span multiples domain/services (On either our GCP account or Partners external Datacenters) Strong retry and monitoring capabilities Be part of our CI/CD pipeline (and not be limited to a Graphical interface) The items in bold seem to be part of what Cloud Workflows does natively, but are the other requirements something that can be added to (or achieved with) GCW to keep it "serverless"? Please. Any help would be appreciated. Thanks
Cloud Workflow can perform basic transformation (on string or date), but I can't recommend that. It's better to have a Cloud Functions or a Cloud Run that perform a transformation with code. You will be able to write unit test on it and to ensure the quality and the evolution of your system without regressions. For orchestration, it's the purpose of Cloud Workflows. Now, there is also some limits, or some corner case less easy to achieve with it. It depends on the complexity of your process and your expectations (observability, portability, replayability,...)
apache-camel
I am trying to test a route which is like this: <code>from("s3://bucketName") .process(exchange -> {exchange.getIn().setHeader(Exchange.FILE_NAME,MY_FILE_NAME);}) .log("File download Successful") .to("file:" + FILE_PATH).routeId("mys3Route"); </code> I have written my test like this: <code>@Test public void testFileMovement() throws Exception { AdviceWith.adviceWith(context, "mys3Route", a -> { a.replaceFromWith("mock:s3Location"); a.interceptSendToEndpoint("file:" + FILE_PATH).skipSendToOriginalEndpoint() .to("mock:anotherLocation"); }); MockEndpoint mockedToEndPoint = getMockEndpoint("mock:anotherLocation"); mockedToEndPoint.setExpectedMessageCount(1); template.sendBody("mock:s3Location", "Just Text"); mockedToEndPoint.assertIsSatisfied(); Thread.sleep(5000); } </code> Whenever I run this as unit test case, I get this error: org.apache.camel.CamelExecutionException: Exception occurred during >execution on the exchange: Exchange[] The error seems to be coming up here in: <code>org.apache.camel.impl.engine.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:591)</code> (which is present in camel dependencies). Any idea as to what I am doing wrong and how I can rectify it? Any help to resolve and understand this issue is greatly appreciated .
For starters you probably should not replace consumer/From endpoint with MockEndpoint just use direct endpoint. MockEndpoints only support producer endpoints (to) and should not be used as consumer endpoint (from). MockEndpoints are meant to be used as points on your route where you want to do assertions on things like message body, exchange properties, received messages etc. Secondly if you're using AdviceWith you should set the isUseAdviceWith to true and start the context manually just before you use <code>template.send</code> methods. How this is set varies a bit if you're using spring boot annotations or not. Example below uses just simple CamelTestSupport. Thirdly you rarely if ever need to use intercept on camel tests, use weaveById, weaveByToURI with replace instead. In this case you're better off just fixing how your file-path and file-name is set by using property-placeholders instead. This way you can just use useOverridePropertiesWithPropertiesComponent and TemporaryFolder feature of junit. Also Apache-commons IO FileUtils is pretty handy if you need to read file-contents of a test file or copy something to a test folder. Using Thread.Sleep with unit tests is hacky at best and should be avoided. For this case I see no reason why you would use it. RouteId is best placed at the top of the route. Example: <code>package com.example; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Properties; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.AdviceWithRouteBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; import org.apache.commons.io.FileUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; public class ExampleTest extends CamelTestSupport { @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); File outputFolder; static final String FILE_NAME = "testfile.txt"; @Test public void testFileMovement() throws Exception { context.getRouteDefinition("mys3Route") .adviceWith(context, new AdviceWithRouteBuilder(){ @Override public void configure() throws Exception { replaceFromWith("direct:start"); weaveAddLast() .to("mock:result"); } }); MockEndpoint resultMockEndpoint = getMockEndpoint("mock:result"); resultMockEndpoint.setExpectedMessageCount(1); startCamelContext(); template.sendBody("direct:start", "Just Text"); File file = new File(outputFolder, FILE_NAME); assertEquals(true, file.exists()); String fileContents = FileUtils.readFileToString(file, StandardCharsets.UTF_8); assertEquals("Just Text", fileContents); resultMockEndpoint.assertIsSatisfied(); } @Override protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder(){ @Override public void configure() throws Exception { from("s3://bucketName") .routeId("mys3Route") .log("File download Successful") .to("file:{{filepath}}?fileName={{filename}}"); } }; } @Override protected Properties useOverridePropertiesWithPropertiesComponent() { try { outputFolder = temporaryFolder.newFolder("output"); } catch (IOException e) { e.printStackTrace(); } Properties properties = new Properties(); properties.put("filename", FILE_NAME); properties.put("filepath", outputFolder.getPath()); return properties; } @Override public boolean isUseAdviceWith() { return true; } } </code> <code><dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>${commons-io.version}</version> </dependency> </code>
apache-camel
I'd like to know if it is possible to write to MongoDB with Apache Camel and choose to write asynchronously. I've seen no reference for the MongoDB Java Reactive Streams Driver, but I'd like to know if there's also an option of writing to MongoDB with Apache Camel with the Reactive driver (for Project Reactor users).
The MongoDB producer Apache Camel component uses the Sync - MongoDB Java Driver by default. A component in Apache Camel runs as is and cannot be modified unless through a predefined set of configuration options. To achieve multi-threading, you can decouple the continuation of message routing from consuming thread using the Threads EIP patten: <code>from("direct:operation") .threads(1) .to("mongodb:myDb?database=someDb&collection=someCollection&operation=save") </code> You can read more on the supported options in the documentation.
apache-camel
I would like to download a list of files with name and content in Apache Camel. Currently I am downloading the file content of all files as byte[] and storing them in a List. I then read the list using a ConsumerTemplate. This works well. This is my Route: <code> from(downloadUri) .aggregate(AggregationStrategies.flexible(byte[].class).accumulateInCollection( LinkedList.class)) .constant(true) .completionFromBatchConsumer() .to("direct:" + this.destinationObjectId); </code> I get the List of all downloaded file contents as byte[] as desired. I would like to extend it now so that it downloads the content and the file name of each file. It shall be stored in a pair object: <code>public class NameContentPair { private String fileName; private byte[] fileContent; public NameContentPair(String fileName, byte[] fileContent) { ... } } </code> These pair objects for each downloaded file shall in turn be stored in a List. How can I change or extend my Route to do this? I tried Camel Converters, but was not able to build them properly into my Route. I always got the Route setup wrong.
I solved this by implementing a custom AggregationStrategy. It reads the file name and the file content from each Exchange and puts them into a list as a NameContentPair objects. The file content and file name is present in the Exchange's body as a RemoteFile and is read from there. The general aggregation implementation is based on the example implementation from https://camel.apache.org/components/3.15.x/eips/aggregate-eip.html The aggregation strategy is then added to the route <code> from(downloadUri) .aggregate(new FileContentWithFileNameInListAggregationStrategy()) .constant(true) .completionFromBatchConsumer() .to("direct:" + this.destinationObjectId); </code>
apache-camel
I have a camel route in <code>MyRouteBuilder.java</code> file which is consuming messages from ActiveMQ: <code>from("activemq:queue:myQueue" ) .process(consumeDroppedMessage) .log(">>> I am here"); </code> I wrote a test case for the following like this : <code>@Override public RouteBuilder createRouteBuilder() throws Exception { return new MyRouteBuilder(); } @Test void testMyTest() throws Exception { String queueInputMessage = "My Msg"; template.sendBody("activemq:queue:myQueue", queueInputMessage); assertMockEndpointsSatisfied(); } </code> When I run the unit test case I get this strange error: <code>7:53:26.175 [main] DEBUG org.apache.camel.impl.engine.InternalRouteStartupManager - Route: route1 >>> Route[activemq://queue:null -> null] 17:53:26.175 [main] DEBUG org.apache.camel.impl.engine.InternalRouteStartupManager - Starting consumer (order: 1000) on route: route1 17:53:26.175 [main] DEBUG org.apache.camel.support.DefaultConsumer - Build consumer: Consumer[activemq://queue:null] 17:53:26.185 [main] DEBUG org.apache.camel.support.DefaultConsumer - Init consumer: Consumer[activemq://queue:null] 17:53:26.185 [main] DEBUG org.apache.camel.support.DefaultConsumer - Starting consumer: Consumer[activemq://queue:null] 17:53:26.213 [main] DEBUG org.apache.activemq.thread.TaskRunnerFactory - Initialized TaskRunnerFactory[ActiveMQ Task] using ExecutorService: java.util.concurrent.ThreadPoolExecutor@3fffff43[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0] 17:53:26.215 [main] DEBUG org.apache.activemq.transport.failover.FailoverTransport - Reconnect was triggered but transport is not started yet. Wait for start to connect the transport. 17:53:26.334 [main] DEBUG org.apache.activemq.transport.failover.FailoverTransport - Started unconnected 17:53:26.334 [main] DEBUG org.apache.activemq.transport.failover.FailoverTransport - Waking up reconnect task 17:53:26.335 [ActiveMQ Task-1] DEBUG org.apache.activemq.transport.failover.FailoverTransport - urlList connectionList:[tcp://localhost:61616], from: [tcp://localhost:61616] 17:53:26.339 [main] DEBUG org.apache.camel.component.jms.DefaultJmsMessageListenerContainer - Established shared JMS Connection 17:53:26.340 [main] DEBUG org.apache.camel.component.jms.DefaultJmsMessageListenerContainer - Resumed paused task: org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker@58c34bb3 17:53:26.372 [ActiveMQ Task-1] DEBUG org.apache.activemq.transport.failover.FailoverTransport - Attempting 0th connect to: tcp://localhost:61616 17:53:28.393 [ActiveMQ Task-1] DEBUG org.apache.activemq.transport.failover.FailoverTransport - Connect fail to: tcp://localhost:61616, reason: {} </code> I am especially stumped to see these messages: <code>Route: route1 >>> Route[activemq://queue:null -> null] </code> and <code>urlList connectionList:[tcp://localhost:61616], from: [tcp://localhost:61616] </code> Why is the queue coming up as <code>null</code> though I have a proper queue name? Also why is the broker url <code>tcp://localhost:61616</code>? I want to run this unit test case so that it runs properly in all environments like: local, DIT , SIT, PROD etc. So, for that I cannot afford the broker url to be: <code>tcp://localhost:61616</code>. Any ideas as to what I am doing wrong here and what I should be doing? EDIT 1: One of the issues that I am seeing is even before the test class is called, the <code>MyRouteBuilder()</code> inside <code>createRouteBuilder()</code> is invoked, leading to the issues that I see in the log.
Instead of setting up an explicit active mq broker , I started using a VM broker . <code>@Override protected RoutesBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() { ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); ActiveMQComponent activeMQComponent = new ActiveMQComponent(); activeMQComponent.setConnectionFactory(connectionFactory); context.addComponent("activemq", activeMQComponent); from("activemq:queue:myQueue").to("mock:collector"); } }; } </code> Also , I mistook camel junit as a traditional junit . We don't need to call explicitly the actual route builder class . Instead after setting up my activeMq component up above , I was able to write my test methods, mock my end points for queue and send messages and assert them . Camel is truly versatile . Requires a lot of study though .
apache-camel
I have a spring boot application that uses cxf camel routes, I didn't do any special configurations, entry point is http://0.0.0.0. My question is what is the maximum number of clients that my application is able to handle concurrently without any customizations? And what should I do and where if for example the defaults are insufficient?
It s about your web server. if you are use quarkus + camel quarkus use vert.x in background. you must configure vert.x and this parameters are vertx.eventloops.poolsize and vert.worker thread size. if you are use quarkus+spring boot. spring boot uses tomcat in default . u can use undertow or jetty.its tomcat parameters <code>server: tomcat: threads: max: 300 min-spare: 60 </code>
apache-camel
I am trying to read an Excel file using Apache Camel. For that I have found that we can use the CSV component: <code>https://camel.apache.org/components/3.14.x/dataformats/csv-dataformat.html </code> For that I have created a simple route which reads a XLSX file from a folder. Then I am trying to print the content of of that Excel file and write to another folder, but the contents of the file are not getting printed. The route is as below: <code>import org.apache.camel.builder.RouteBuilder; import org.apache.camel.dataformat.csv.CsvDataFormat; import org.apache.commons.csv.CSVFormat; import org.springframework.stereotype.Component; @Component public class MyRoute extends RouteBuilder { public void configure() { CsvDataFormat csv = new CsvDataFormat(); csv.setFormat(CSVFormat.EXCEL); from("file://C://work//ei01//source") .unmarshal(csv) .log("Reached ${body}") .marshal(csv) .to("file://C://work//ei01//destination?fileName=test.xlsx"); } } </code> The pom.xml is as below: <code><?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.6.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>sprng-boot-camel-demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>sprng-boot-camel-demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-starter</artifactId> <version>3.14.1</version> </dependency> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-csv-starter</artifactId> <version>3.14.1</version> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin> </plugins> </build> </project> </code> Can you please suggest me what I am doing wrong here?
I suppose you try to read a real Excel file (<code>.xlsx</code>). That does not work with the CSV data format. The <code>CSVFormat.EXCEL</code> format is to read CSV files (<code>.csv</code>) exported from Excel. Because the CSV format is done quite different from product to product, Camel supports multiple "well-known" CSV formats. One of them is <code>CSVFormat.EXCEL</code>. To read the native Excel format (I think it is a ZIP file that contains XML files), you need a library like Apache POI.
End of preview.
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
0