apache-camel

Apache Camel REST DSL - Validating Request Payload and return error response

匆匆过客 提交于 2019-12-04 15:16:41
I am exposing a rest service using "CamelHttpTransportServlet" that receive orders and place in jms queue. The code works fine on happy path and returns 200 response. I have written Processor to validate the input JSON, and set http_response_code based on the input. The issue is - for invalid requests though failure response code - 400 is set, the flow continues to the next route and pushes the data to the queue instead of sending the 400 response back to the calling app. rest("/ordermanagement") .post("/order").to("direct:checkInput"); from("direct:checkInput") .process(new Processor() {

Camel-SQL Why using StreamList seems to load all ResultSet?

大兔子大兔子 提交于 2019-12-04 14:12:48
Hi, What am I trying to do ? I am currently working on an ESB project (apache-camel + spring boot 2) where i read a MySQL table with more than 100 000 000 rows. I empty this table 1 row at a time, transform the row and send it to another database. How am I doing this ? Currently I use camel-sql to read the data //edited .from(sql:SELECT * FROM mytable?outputType=StreamList&outpuClass=MyClass) .split(body()).streaming() .bean(mybean, "transform") .end() Problem : As I can't make a select * and get all 100M rows in my RAM because it's not possibly big enough, I thougth about using streams.

Camel Apache: xpath to extract some value out of received XML

吃可爱长大的小学妹 提交于 2019-12-04 13:39:38
问题 during my Camel routes, I query a server (a HTTP GET) and as a result, I receive a 200 OK with a XML body looking similar like this: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <userProfiles xmlns="http://www.mycompany.com/AEContext/xmldata"> <userProfile name="guest"> <userProfileAttributes> <userProfileAttribute name="parameter1" value="data1" nameVisibility="ALL"/> <userProfileAttribute name="parameter2" value="data2" nameVisibility="ALL"/> <userProfileAttribute name=

Which Camel construct is suited for transforming?

孤人 提交于 2019-12-04 13:33:42
问题 Apache Camel offers several ways of performing data transforms: its concept of the Transform EIP, custom DataFormats, as well as its allowance for custom Type Converters. I have a situation where I need to do a very complex transform from inside a Camel route. Should I be implementing my own Type Converter, my own DataFormat, or should I implement org.apache.camel.Expression and put all the transform stuff in there: public class MyTransformer implements Expression { @Override public <T> T

Accessing Data from JSON body inside Apache Camel

依然范特西╮ 提交于 2019-12-04 13:12:50
I am working with an API which basically allows for the navigation of a file-system. I am trying to access data from within the returned JSON by the API in order to perform a function on it. Below is the code I am using the access the API. I have tried to use unmarshal to convert the JSON returned to a Map. from("timer://foo?fixedRate=true&period=120000") .log("Checking for files") .setHeader("Authorization", simple(myHttp.getAuth())) .setHeader("CamelHttpMethod", constant("GET")) .to(myHttp.getFullRequest()) .unmarshal(new JacksonDataFormat(Map.class)).log("${body}"); Which returns this data

how to create datasource using camel?

时间秒杀一切 提交于 2019-12-04 11:42:40
问题 I have just started learning Apache Camel. I understood the basics of Routes and Components. Now I want to give a try by connecting to Oracle database, reading records from one particular table and write those records to a file using File component. To read from database I assume I need to use JDBC component and give the dataSourceName . However, I couldn't find any info on how to create a dataSource using camel. All info that I found related to this topic uses Spring DSL examples. I don't

Unit testing FTP consumer with Apache Camel

99封情书 提交于 2019-12-04 11:33:30
I have the below route. In unit test, since I doesn't have the FTP server available, I'd like to use camel's test support and send an invalid message to "ftp://hostname/input" and verify that it failed and routed to "ftp://hostname/error" . I gone through the documentation which mainly talks about using the "mock:" endpoint but I am not sure how to use it in this scenario. public class MyRoute extends RouteBuilder { @Override public void configure() { onException(EdiOrderParsingException.class).handled(true).to("ftp://hostname/error"); from("ftp://hostname/input") .bean(new OrderEdiTocXml())

Camel - How to stop route execution on exception?

核能气质少年 提交于 2019-12-04 11:18:52
Is there any way I can stop the route execution (after displaying a log message) when exception is caught? <doTry> <process ref="messageProcessor"/> <doCatch> <exception>java.lang.IllegalArgumentException</exception> <log message="some message related to the exception" /> </doCatch> </doTry> Please provide a way to achieve this in Spring DSL. I've already tried < stop/> but that doesn't display log message. Added a process in doCatch which stop's a Camel context. <doTry> <process ref="messageProcessor"/> <doCatch> <exception>java.lang.IllegalArgumentException</exception> <handled> <constant

Camel retry control with multiple exceptions

◇◆丶佛笑我妖孽 提交于 2019-12-04 10:59:21
Preface: I'm fairly new to Camel, and after digesting Camel in action as best as possible, I'm adapting it to a project I'm on. In this project, we have some rather complex error handling, and I want to make sure I can replicate this as we Camel-ize our code. On our project (as most) there are a set of Exceptions we want to retry and a set that we don't - but more specifically, there are a set that we want to retry more than others (not all recoverable errors can be treated the same). In this case, I was attempting to define an onException block to change the redelivery policy. However, it

Camel - Passing specific parameters from routes to a generic bean method

不羁的心 提交于 2019-12-04 10:49:45
问题 Let's say I have a Camel route that looks like this : from("direct:myRoute") .setHeader("someHeader", simple("some header value")) .beanRef("myBean", "beanMethod"); And I have a bean that I cannot change that looks like this : public class MyBean { public void beanMethod(String headerExpected) { // do something with the value here. } } Basically, I want to pass the value of someHeader from myRoute to beanMethod within MyBean . Knowing that beanMethod can accept a String , how can I pass the