apache-camel

Apache Camel with Json Array split

你离开我真会死。 提交于 2019-12-01 12:28:26
问题 I have a camel application which receives a json array request from a jms queue upto size 13000,the structure of the json array request is as below. I would like to stream and split the json array with a group of 5. For example if I receive a json array of size 100 I would like to group as 5 and split it as 20 requests. Is there a inbuilt camel functionality to group and split json array or do I need to write a custom splitter? I'm using camel 2.17 version. Sample json array: [{ "name": "Ram"

How to manually control the offset commit with camel-kafka?

邮差的信 提交于 2019-12-01 12:17:37
I'm using the camel kafka component and I'm unclear what is happening under the hood with committing the offsets. As can be seen below, I'm aggregating records and I think for my use case that it only makes sense to commit the offsets after the records have been saved to SFTP. Is it possible to manually control when I can perform the commit? private static class MyRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from("kafka:{{mh.topic}}?" + getKafkaConfigString()) .unmarshal().string() .aggregate(constant(true), new MyAggregationStrategy())

How do dynamic “from” endpoints and exchanges work in camel?

风格不统一 提交于 2019-12-01 11:58:56
I'm sort of struggling with the dynamic routing concept and consumer rules. So let's say I have a route with exchange data, and then I want to use a header from the exchange in a different route in the "from" endpoint. I think it would look something like this: Route 1: from("file:/dir1") ... .to ("direct:start"); Route 2: from("direct: start")//get the old exchange data .from("file:/dir1/?fileName=${header.myHeader}")//start consuming from a different endpoint using old exchange data ... .to("direct: end); So those steps seems right to me, but I feel like Im sort of polluting the exchange. To

testing camel quartz route

a 夏天 提交于 2019-12-01 11:29:20
I try to make a junit test for apache camel route. Something like this : @RunWith(CamelSpringJUnit4ClassRunner.class) @ContextConfiguration( loader = CamelSpringDelegatingTestContextLoader.class ) public class MyExportRouteBuilderIT extends CamelTestSupport { @Test public void test() { // trigger and check the files made by route builder processor } @Override protected RouteBuilder createRouteBuilder() throws Exception { return new MyExportRouteBuilder(); } } The builder class is defined like this from("quartz2://exportJob?cron=" + cronTrigger) .setHeader(FILE_NAME, expression(FILE_NAME_FORMAT

Unable to send file to rest webservice via apache camel http

旧巷老猫 提交于 2019-12-01 10:58:51
I am new to Camel and I am facing an issue while sending files to webservice via camel http. I have a rest web service which consumes Multipart form data type content and accepts input as part of form data. When I send file and form parameter via camel it gives me the following error at camel console: Stacktrace --------------------------------------------------------------------------------------------------------------------------------------- org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http://localhost:8080/JAX_RS_Application/resource/restwb

How to manually control the offset commit with camel-kafka?

谁都会走 提交于 2019-12-01 10:20:40
问题 I'm using the camel kafka component and I'm unclear what is happening under the hood with committing the offsets. As can be seen below, I'm aggregating records and I think for my use case that it only makes sense to commit the offsets after the records have been saved to SFTP. Is it possible to manually control when I can perform the commit? private static class MyRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from("kafka:{{mh.topic}}?" +

How to generate a Flat file with header and footer using Camel Bindy

。_饼干妹妹 提交于 2019-12-01 08:09:29
问题 Currently I'm able to generate a flat file from a POJO using camel Bindy but unable to add header and Footer to the complete file. But when I tried to add header/footer to the file, it is adding to each single record but I need to add a single header/footer to the complete file not each record in the file. Below is the code snippet: from("jpa:com.PACKAGENAME.RebatePayout?consumer.namedQuery=REBATE_PAYOUT&consumer.delay=500000&consumeLockEntity=true&consumeDelete=false") .routeId("rebateroute"

Camel send multipart/form-data request

别说谁变了你拦得住时间么 提交于 2019-12-01 07:26:59
问题 I have an app, that sends a multipart/form-data & an app that recieves multipart/form-data request. Processing in reciever: InputStreamCache postBody = exchange.getIn().getBody(InputStreamCache.class); MultipartUploadContext mux = new MultipartUploadContext(postBody, exchange.getIn().getHeader("Content-Type",String.class)); Map<String,Object> params = mux.parseRequest(); Parsing a request, send from Postman/Swagger works fine. I have troubles integrating my camel-sender with my camel reciever

HTTP Post From ActiveMQ using Camel

别说谁变了你拦得住时间么 提交于 2019-12-01 06:50:42
We're using camel routes to post values from a queue to an http endpoint. I've successfully set up the route using camel's http component , but I'm unable to get the body of the jms message to post. For example, my route is set up like this: <route errorHandlerRef="dlc" autoStartup="true" id="route2" xmlns:ns2="http://camel.apache.org/schema/web" xmlns="http://camel.apache.org/schema/spring"> <from uri="activemq:test"/> <setHeader headerName="CamelHttpMethod"> <constant>POST</constant> </setHeader> <to uri="http://localhost/tim/camel/" id="to2"/> </route> Which results in a POST, but the

Camel cxfrs RESTful client / ProducerTemplate ConnectionTimeout

允我心安 提交于 2019-12-01 06:43:27
问题 I am trying to set the 'connectionTimeout' for a Camel CXF-RS component here which produces a RESTful requests on a 3rd party service. The default 30000 miliseconds is to long. Exchange exchange = template.send("cxfrs://" + url, new Processor() { public void process(Exchange exchange) throws Exception { exchange.setPattern(ExchangePattern.InOut); Message inMessage = exchange.getIn(); setupDestinationURL(inMessage); // using the http central client API inMessage.setHeader(CxfConstants.CAMEL