Chapter 92. Simple
Chapter 92. Simple The Simple Expression Language was a really simple language when it was created, but has since grown more powerful. It is primarily intended for being a very small and simple language for evaluating Expression or Predicate without requiring any new dependencies or knowledge of other scripting languages such as Groovy. The simple language is designed with intend to cover almost all the common use cases when little need for scripting in your Camel routes. However, for much more complex use cases then a more powerful language is recommended such as: Groovy MVEL OGNL Note The simple language requires camel-bean JAR as classpath dependency if the simple language uses OGNL expressions, such as calling a method named myMethod on the message body: USD{body.myMethod()} . At runtime the simple language will then us its built-in OGNL support which requires the camel-bean component. The simple language uses USD{body} placeholders for complex expressions or functions. Note See also the CSimple language which is compiled. Note Alternative syntax You can also use the alternative syntax which uses USDsimple{ } as placeholders. This can be used in situations to avoid clashes when using for example Spring property placeholder together with Camel. 92.1. Simple Language options The Simple language supports 2 options, which are listed below. Name Default Java Type Description resultType String Sets the class name of the result type (type from output). trim Boolean Whether to trim the value to remove leading and trailing whitespaces and line breaks. 92.2. Variables Variable Type Description camelId String the CamelContext name camelContext. OGNL Object the CamelContext invoked using a Camel OGNL expression. exchange Exchange the Exchange exchange. OGNL Object the Exchange invoked using a Camel OGNL expression. exchangeId String the exchange id id String the message id messageTimestamp String the message timestamp (millis since epoc) that this message originates from. Some systems like JMS, Kafka, AWS have a timestamp on the event/message, that Camel received. This method returns the timestamp, if a timestamp exists. The message timestamp and exchange created are not the same. An exchange always have a created timestamp which is the local timestamp when Camel created the exchange. The message timestamp is only available in some Camel components when the consumer is able to extract the timestamp from the source event. If the message has no timestamp then 0 is returned. body Object the body body. OGNL Object the body invoked using a Camel OGNL expression. bodyAs( type ) Type Converts the body to the given type determined by its classname. The converted body can be null. bodyAs( type ). OGNL Object Converts the body to the given type determined by its classname and then invoke methods using a Camel OGNL expression. The converted body can be null. bodyOneLine String Converts the body to a String and removes all line-breaks so the string is in one line. mandatoryBodyAs( type ) Type Converts the body to the given type determined by its classname, and expects the body to be not null. mandatoryBodyAs( type ). OGNL Object Converts the body to the given type determined by its classname and then invoke methods using a Camel OGNL expression. header.foo Object refer to the foo header header[foo] Object refer to the foo header headers.foo Object refer to the foo header headers:foo Object refer to the foo header headers[foo] Object refer to the foo header header.foo[bar] Object regard foo header as a map and perform lookup on the map with bar as key header.foo. OGNL Object refer to the foo header and invoke its value using a Camel OGNL expression. headerAs( key , type ) Type converts the header to the given type determined by its classname headers Map refer to the headers exchangeProperty.foo Object refer to the foo property on the exchange exchangeProperty[foo] Object refer to the foo property on the exchange exchangeProperty.foo. OGNL Object refer to the foo property on the exchange and invoke its value using a Camel OGNL expression. sys.foo String refer to the JVM system property sysenv.foo String refer to the system environment variable env.foo String refer to the system environment variable exception Object refer to the exception object on the exchange, is null if no exception set on exchange. Will fallback and grab caught exceptions ( Exchange.EXCEPTION_CAUGHT ) if the Exchange has any. exception. OGNL Object refer to the exchange exception invoked using a Camel OGNL expression object exception.message String refer to the exception.message on the exchange, is null if no exception set on exchange. Will fallback and grab caught exceptions ( Exchange.EXCEPTION_CAUGHT ) if the Exchange has any. exception.stacktrace String refer to the exception.stracktrace on the exchange, is null if no exception set on exchange. Will fallback and grab caught exceptions ( Exchange.EXCEPTION_CAUGHT ) if the Exchange has any. date:_command_ Date evaluates to a Date object. Supported commands are: now for current timestamp, exchangeCreated for the timestamp when the current exchange was created, header.xxx to use the Long/Date object header with the key xxx. exchangeProperty.xxx to use the Long/Date object in the exchange property with the key xxx. file for the last modified timestamp of the file (available with a File consumer). Command accepts offsets such as: now-24h or header.xxx+1h or even now+1h30m-100 . date:_command:pattern_ String Date formatting using java.text.SimpleDateFormat patterns. date-with-timezone:_command:timezone:pattern_ String Date formatting using java.text.SimpleDateFormat timezones and patterns. bean:_bean expression_ Object Invoking a bean expression using the language. Specifying a method name you must use dot as separator. We also support the ?method=methodname syntax that is used by the component. Camel will by default lookup a bean by the given name. However if you need to refer to a bean class (such as calling a static method) then you can prefix with type, such as bean:type:fqnClassName . properties:key:default String Lookup a property with the given key. If the key does not exists or has no value, then an optional default value can be specified. routeId String Returns the id of the current route the Exchange is being routed. stepId String Returns the id of the current step the Exchange is being routed. threadName String Returns the name of the current thread. Can be used for logging purpose. hostname String Returns the local hostname (may be empty if not possible to resolve). ref:xxx Object To lookup a bean from the Registry with the given id. type:name.field Object To refer to a type or field by its FQN name. To refer to a field you can append .FIELD_NAME. For example, you can refer to the constant field from Exchange as: org.apache.camel.Exchange.FILE_NAME null null represents a null random(value) Integer returns a random Integer between 0 (included) and value (excluded) random(min,max) Integer returns a random Integer between min (included) and max (excluded) collate(group) List The collate function iterates the message body and groups the data into sub lists of specified size. This can be used with the Splitter EIP to split a message body and group/batch the splitted sub message into a group of N sub lists. This method works similar to the collate method in Groovy. skip(number) Iterator The skip function iterates the message body and skips the first number of items. This can be used with the Splitter EIP to split a message body and skip the first N number of items. messageHistory String The message history of the current exchange how it has been routed. This is similar to the route stack-trace message history the error handler logs in case of an unhandled exception. messageHistory(false) String As messageHistory but without the exchange details (only includes the route stack-trace). This can be used if you do not want to log sensitive data from the message itself. 92.3. OGNL expression support When using OGNL then camel-bean JAR is required to be on the classpath. Camel's OGNL support is for invoking methods only. You cannot access fields. Camel support accessing the length field of Java arrays. The Simple and Bean language now supports a Camel OGNL notation for invoking beans in a chain like fashion. Suppose the Message IN body contains a POJO which has a getAddress() method. Then you can use Camel OGNL notation to access the address object: simple("USD{body.address}") simple("USD{body.address.street}") simple("USD{body.address.zip}") Camel understands the shorthand names for getters, but you can invoke any method or use the real name such as: simple("USD{body.address}") simple("USD{body.getAddress.getStreet}") simple("USD{body.address.getZip}") simple("USD{body.doSomething}") You can also use the null safe operator ( ?. ) to avoid NPE if for example the body does NOT have an address simple("USD{body?.address?.street}") It is also possible to index in Map or List types, so you can do: simple("USD{body[foo].name}") To assume the body is Map based and lookup the value with foo as key, and invoke the getName method on that value. If the key has space, then you must enclose the key with quotes, for example 'foo bar': simple("USD{body['foo bar'].name}") You can access the Map or List objects directly using their key name (with or without dots) : simple("USD{body[foo]}") simple("USD{body[this.is.foo]}") Suppose there was no value with the key foo then you can use the null safe operator to avoid the NPE as shown: simple("USD{body[foo]?.name}") You can also access List types, for example to get lines from the address you can do: simple("USD{body.address.lines[0]}") simple("USD{body.address.lines[1]}") simple("USD{body.address.lines[2]}") There is a special last keyword which can be used to get the last value from a list. simple("USD{body.address.lines[last]}") And to get the 2nd last you can subtract a number, so we can use last-1 to indicate this: simple("USD{body.address.lines[last-1]}") And the 3rd last is of course: simple("USD{body.address.lines[last-2]}") And you can call the size method on the list with simple("USD{body.address.lines.size}") Camel supports the length field for Java arrays as well, eg: String[] lines = new String[]{"foo", "bar", "cat"}; exchange.getIn().setBody(lines); simple("There are USD{body.length} lines") And yes you can combine this with the operator support as shown below: simple("USD{body.address.zip} > 1000") 92.4. Operator support The parser is limited to only support a single operator. To enable it the left value must be enclosed in USD\\{ }. The syntax is: USD{leftValue} OP rightValue Where the rightValue can be a String literal enclosed in ' ' , null , a constant value or another expression enclosed in USD\{ } . Note There must be spaces around the operator. Camel will automatically type convert the rightValue type to the leftValue type, so it is able to eg. convert a string into a numeric, so you can use > comparison for numeric values. The following operators are supported: Operator Description == equals =~ equals ignore case (will ignore case when comparing String values) > greater than >= greater than or equals < less than ⇐ less than or equals != not equals !=~ not equals ignore case (will ignore case when comparing String values) contains For testing if contains in a string based value !contains For testing if not contains in a string based value ~~ For testing if contains by ignoring case sensitivity in a string based value !~~ For testing if not contains by ignoring case sensitivity in a string based value regex For matching against a given regular expression pattern defined as a String value !regex For not matching against a given regular expression pattern defined as a String value in For matching if in a set of values, each element must be separated by comma. If you want to include an empty value, then it must be defined using double comma, eg ',,bronze,silver,gold', which is a set of four values with an empty value and then the three medals. !in For matching if not in a set of values, each element must be separated by comma. If you want to include an empty value, then it must be defined using double comma, eg ',,bronze,silver,gold', which is a set of four values with an empty value and then the three medals. is For matching if the left hand side type is an instance of the value. !is For matching if the left hand side type is not an instance of the value. range For matching if the left hand side is within a range of values defined as numbers: from..to .. !range For matching if the left hand side is not within a range of values defined as numbers: from..to . . startsWith For testing if the left hand side string starts with the right hand string. starts with Same as the startsWith operator. endsWith For testing if the left hand side string ends with the right hand string. ends with Same as the endsWith operator. And the following unary operators can be used: Operator Description ++ To increment a number by one. The left hand side must be a function, otherwise parsed as literal. - To decrement a number by one. The left hand side must be a function, otherwise parsed as literal. \n To use newline character. \t To use tab character. \r To use carriage return character. \} To use the } character as text. This may be needed when building a JSon structure with the simple language. And the following logical operators can be used to group expressions: Operator Description && The logical and operator is used to group two expressions. The logical or operator is used to group two expressions. The syntax for AND is: USD{leftValue} OP rightValue && USD{leftValue} OP rightValue And the syntax for OR is: USD{leftValue} OP rightValue || USD{leftValue} OP rightValue Some examples: // exact equals match simple("USD{header.foo} == 'foo'") // ignore case when comparing, so if the header has value FOO this will match simple("USD{header.foo} =~ 'foo'") // here Camel will type convert '100' into the type of header.bar and if it is an Integer '100' will also be converter to an Integer simple("USD{header.bar} == '100'") simple("USD{header.bar} == 100") // 100 will be converter to the type of header.bar so we can do > comparison simple("USD{header.bar} > 100") 92.4.1. Comparing with different types When you compare with different types such as String and int, then you have to take a bit care. Camel will use the type from the left hand side as 1st priority. And fallback to the right hand side type if both values couldn't be compared based on that type. This means you can flip the values to enforce a specific type. Suppose the bar value above is a String. Then you can flip the equation: simple("100 < USD{header.bar}") which then ensures the int type is used as 1st priority. This may change in the future if the Camel team improves the binary comparison operations to prefer numeric types to String based. It's most often the String type which causes problem when comparing with numbers. // testing for null simple("USD{header.baz} == null") // testing for not null simple("USD{header.baz} != null") And a bit more advanced example where the right value is another expression simple("USD{header.date} == USD{date:now:yyyyMMdd}") simple("USD{header.type} == USD{bean:orderService?method=getOrderType}") And an example with contains, testing if the title contains the word Camel simple("USD{header.title} contains 'Camel'") And an example with regex, testing if the number header is a 4 digit value: simple("USD{header.number} regex '\\d{4}'") And finally an example if the header equals any of the values in the list. Each element must be separated by comma, and no space around. This also works for numbers etc, as Camel will convert each element into the type of the left hand side. simple("USD{header.type} in 'gold,silver'") And for all the last 3 we also support the negate test using not: simple("USD{header.type} !in 'gold,silver'") And you can test if the type is a certain instance, eg for instance a String simple("USD{header.type} is 'java.lang.String'") We have added a shorthand for all java.lang types so you can write it as: simple("USD{header.type} is 'String'") Ranges are also supported. The range interval requires numbers and both from and end are inclusive. For instance to test whether a value is between 100 and 199: simple("USD{header.number} range 100..199") Notice we use .. in the range without spaces. It is based on the same syntax as Groovy. simple("USD{header.number} range '100..199'") As the XML DSL does not have all the power as the Java DSL with all its various builder methods, you have to resort to use some other languages for testing with simple operators. Now you can do this with the simple language. In the sample below we want to test if the header is a widget order: <from uri="seda:orders"> <filter> <simple>USD{header.type} == 'widget'</simple> <to uri="bean:orderService?method=handleWidget"/> </filter> </from> 92.4.2. Using and / or If you have two expressions you can combine them with the && or || operator. For instance: simple("USD{header.title} contains 'Camel' && USD{header.type'} == 'gold'") And of course the || is also supported. The sample would be: simple("USD{header.title} contains 'Camel' || USD{header.type'} == 'gold'") 92.5. Examples In the XML DSL sample below we filter based on a header value: <from uri="seda:orders"> <filter> <simple>USD{header.foo}</simple> <to uri="mock:fooOrders"/> </filter> </from> The Simple language can be used for the predicate test above in the Message Filter pattern, where we test if the in message has a foo header (a header with the key foo exists). If the expression evaluates to true then the message is routed to the mock:fooOrders endpoint, otherwise the message is dropped. The same example in Java DSL: from("seda:orders") .filter().simple("USD{header.foo}") .to("seda:fooOrders"); You can also use the simple language for simple text concatenations such as: from("direct:hello") .transform().simple("Hello USD{header.user} how are you?") .to("mock:reply"); Notice that we must use USD\\{ } placeholders in the expression now to allow Camel to parse it correctly. And this sample uses the date command to output current date. from("direct:hello") .transform().simple("The today is USD{date:now:yyyyMMdd} and it is a great day.") .to("mock:reply"); And in the sample below we invoke the bean language to invoke a method on a bean to be included in the returned string: from("direct:order") .transform().simple("OrderId: USD{bean:orderIdGenerator}") .to("mock:reply"); Where orderIdGenerator is the id of the bean registered in the Registry. If using Spring then it is the Spring bean id. If we want to declare which method to invoke on the order id generator bean we must prepend .method name such as below where we invoke the generateId method. from("direct:order") .transform().simple("OrderId: USD{bean:orderIdGenerator.generateId}") .to("mock:reply"); We can use the ?method=methodname option that we are familiar with the Bean component itself: from("direct:order") .transform().simple("OrderId: USD{bean:orderIdGenerator?method=generateId}") .to("mock:reply"); You can also convert the body to a given type, for example to ensure that it is a String you can do: <transform> <simple>Hello USD{bodyAs(String)} how are you?</simple> </transform> There are a few types which have a shorthand notation, so we can use String instead of java.lang.String . These are: byte[], String, Integer, Long . All other types must use their FQN name, e.g. org.w3c.dom.Document . It is also possible to lookup a value from a header Map : <transform> <simple>The gold value is USD{header.type[gold]}</simple> </transform> In the code above we lookup the header with name type and regard it as a java.util.Map and we then lookup with the key gold and return the value. If the header is not convertible to Map an exception is thrown. If the header with name type does not exist null is returned. You can nest functions, such as shown below: <setHeader name="myHeader"> <simple>USD{properties:USD{header.someKey}}</simple> </setHeader> 92.6. Setting result type You can now provide a result type to the Simple expression, which means the result of the evaluation will be converted to the desired type. This is most usable to define types such as booleans, integers, etc. For example to set a header as a boolean type you can do: .setHeader("cool", simple("true", Boolean.class)) And in XML DSL <setHeader name="cool"> <!-- use resultType to indicate that the type should be a java.lang.Boolean --> <simple resultType="java.lang.Boolean">true</simple> </setHeader> 92.7. Using new lines or tabs in XML DSLs It is easier to specify new lines or tabs in XML DSLs as you can escape the value now <transform> <simple>The following text\nis on a new line</simple> </transform> 92.8. Leading and trailing whitespace handling The trim attribute of the expression can be used to control whether the leading and trailing whitespace characters are removed or preserved. The default value is true, which removes the whitespace characters. <setBody> <simple trim="false">You get some trailing whitespace characters. </simple> </setBody> 92.9. Loading script from external resource You can externalize the script and have Camel load it from a resource such as "classpath:" , "file:" , or "http:" . This is done using the following syntax: "resource:scheme:location" , e.g. to refer to a file on the classpath you can do: .setHeader("myHeader").simple("resource:classpath:mysimple.txt") 92.10. Spring Boot Auto-Configuration When using simple with Spring Boot make sure to use the following Maven dependency to have support for auto configuration: <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-core-starter</artifactId> </dependency> The component supports 147 options, which are listed below. Name Description Default Type camel.cloud.consul.service-discovery.acl-token Sets the ACL token to be used with Consul. String camel.cloud.consul.service-discovery.block-seconds The seconds to wait for a watch event, default 10 seconds. 10 Integer camel.cloud.consul.service-discovery.configurations Define additional configuration definitions. Map camel.cloud.consul.service-discovery.connect-timeout-millis Connect timeout for OkHttpClient. Long camel.cloud.consul.service-discovery.datacenter The data center. String camel.cloud.consul.service-discovery.enabled Enable the component. true Boolean camel.cloud.consul.service-discovery.password Sets the password to be used for basic authentication. String camel.cloud.consul.service-discovery.properties Set client properties to use. These properties are specific to what service call implementation are in use. For example if using ribbon, then the client properties are define in com.netflix.client.config.CommonClientConfigKey. Map camel.cloud.consul.service-discovery.read-timeout-millis Read timeout for OkHttpClient. Long camel.cloud.consul.service-discovery.url The Consul agent URL. String camel.cloud.consul.service-discovery.user-name Sets the username to be used for basic authentication. String camel.cloud.consul.service-discovery.write-timeout-millis Write timeout for OkHttpClient. Long camel.cloud.dns.service-discovery.configurations Define additional configuration definitions. Map camel.cloud.dns.service-discovery.domain The domain name;. String camel.cloud.dns.service-discovery.enabled Enable the component. true Boolean camel.cloud.dns.service-discovery.properties Set client properties to use. These properties are specific to what service call implementation are in use. For example if using ribbon, then the client properties are define in com.netflix.client.config.CommonClientConfigKey. Map camel.cloud.dns.service-discovery.proto The transport protocol of the desired service. _tcp String camel.cloud.etcd.service-discovery.configurations Define additional configuration definitions. Map camel.cloud.etcd.service-discovery.enabled Enable the component. true Boolean camel.cloud.etcd.service-discovery.password The password to use for basic authentication. String camel.cloud.etcd.service-discovery.properties Set client properties to use. These properties are specific to what service call implementation are in use. For example if using ribbon, then the client properties are define in com.netflix.client.config.CommonClientConfigKey. Map camel.cloud.etcd.service-discovery.service-path The path to look for for service discovery. /services/ String camel.cloud.etcd.service-discovery.timeout To set the maximum time an action could take to complete. Long camel.cloud.etcd.service-discovery.type To set the discovery type, valid values are on-demand and watch. on-demand String camel.cloud.etcd.service-discovery.uris The URIs the client can connect to. String camel.cloud.etcd.service-discovery.user-name The user name to use for basic authentication. String camel.cloud.kubernetes.service-discovery.api-version Sets the API version when using client lookup. String camel.cloud.kubernetes.service-discovery.ca-cert-data Sets the Certificate Authority data when using client lookup. String camel.cloud.kubernetes.service-discovery.ca-cert-file Sets the Certificate Authority data that are loaded from the file when using client lookup. String camel.cloud.kubernetes.service-discovery.client-cert-data Sets the Client Certificate data when using client lookup. String camel.cloud.kubernetes.service-discovery.client-cert-file Sets the Client Certificate data that are loaded from the file when using client lookup. String camel.cloud.kubernetes.service-discovery.client-key-algo Sets the Client Keystore algorithm, such as RSA when using client lookup. String camel.cloud.kubernetes.service-discovery.client-key-data Sets the Client Keystore data when using client lookup. String camel.cloud.kubernetes.service-discovery.client-key-file Sets the Client Keystore data that are loaded from the file when using client lookup. String camel.cloud.kubernetes.service-discovery.client-key-passphrase Sets the Client Keystore passphrase when using client lookup. String camel.cloud.kubernetes.service-discovery.configurations Define additional configuration definitions. Map camel.cloud.kubernetes.service-discovery.dns-domain Sets the DNS domain to use for DNS lookup. String camel.cloud.kubernetes.service-discovery.enabled Enable the component. true Boolean camel.cloud.kubernetes.service-discovery.lookup How to perform service lookup. Possible values: client, dns, environment. When using client, then the client queries the kubernetes master to obtain a list of active pods that provides the service, and then random (or round robin) select a pod. When using dns the service name is resolved as name.namespace.svc.dnsDomain. When using dnssrv the service name is resolved with SRV query for . ... svc... When using environment then environment variables are used to lookup the service. By default environment is used. environment String camel.cloud.kubernetes.service-discovery.master-url Sets the URL to the master when using client lookup. String camel.cloud.kubernetes.service-discovery.namespace Sets the namespace to use. Will by default use namespace from the ENV variable KUBERNETES_MASTER. String camel.cloud.kubernetes.service-discovery.oauth-token Sets the OAUTH token for authentication (instead of username/password) when using client lookup. String camel.cloud.kubernetes.service-discovery.password Sets the password for authentication when using client lookup. String camel.cloud.kubernetes.service-discovery.port-name Sets the Port Name to use for DNS/DNSSRV lookup. String camel.cloud.kubernetes.service-discovery.port-protocol Sets the Port Protocol to use for DNS/DNSSRV lookup. String camel.cloud.kubernetes.service-discovery.properties Set client properties to use. These properties are specific to what service call implementation are in use. For example if using ribbon, then the client properties are define in com.netflix.client.config.CommonClientConfigKey. Map camel.cloud.kubernetes.service-discovery.trust-certs Sets whether to turn on trust certificate check when using client lookup. false Boolean camel.cloud.kubernetes.service-discovery.username Sets the username for authentication when using client lookup. String camel.cloud.ribbon.load-balancer.client-name Sets the Ribbon client name. String camel.cloud.ribbon.load-balancer.configurations Define additional configuration definitions. Map camel.cloud.ribbon.load-balancer.enabled Enable the component. true Boolean camel.cloud.ribbon.load-balancer.namespace The namespace. String camel.cloud.ribbon.load-balancer.password The password. String camel.cloud.ribbon.load-balancer.properties Set client properties to use. These properties are specific to what service call implementation are in use. For example if using ribbon, then the client properties are define in com.netflix.client.config.CommonClientConfigKey. Map camel.cloud.ribbon.load-balancer.username The username. String camel.hystrix.allow-maximum-size-to-diverge-from-core-size Allows the configuration for maximumSize to take effect. That value can then be equal to, or higher, than coreSize. false Boolean camel.hystrix.circuit-breaker-enabled Whether to use a HystrixCircuitBreaker or not. If false no circuit-breaker logic will be used and all requests permitted. This is similar in effect to circuitBreakerForceClosed() except that continues tracking metrics and knowing whether it should be open/closed, this property results in not even instantiating a circuit-breaker. true Boolean camel.hystrix.circuit-breaker-error-threshold-percentage Error percentage threshold (as whole number such as 50) at which point the circuit breaker will trip open and reject requests. It will stay tripped for the duration defined in circuitBreakerSleepWindowInMilliseconds; The error percentage this is compared against comes from HystrixCommandMetrics.getHealthCounts(). 50 Integer camel.hystrix.circuit-breaker-force-closed If true the HystrixCircuitBreaker#allowRequest() will always return true to allow requests regardless of the error percentage from HystrixCommandMetrics.getHealthCounts(). The circuitBreakerForceOpen() property takes precedence so if it set to true this property does nothing. false Boolean camel.hystrix.circuit-breaker-force-open If true the HystrixCircuitBreaker.allowRequest() will always return false, causing the circuit to be open (tripped) and reject all requests. This property takes precedence over circuitBreakerForceClosed();. false Boolean camel.hystrix.circuit-breaker-request-volume-threshold Minimum number of requests in the metricsRollingStatisticalWindowInMilliseconds() that must exist before the HystrixCircuitBreaker will trip. If below this number the circuit will not trip regardless of error percentage. 20 Integer camel.hystrix.circuit-breaker-sleep-window-in-milliseconds The time in milliseconds after a HystrixCircuitBreaker trips open that it should wait before trying requests again. 5000 Integer camel.hystrix.configurations Define additional configuration definitions. Map camel.hystrix.core-pool-size Core thread-pool size that gets passed to java.util.concurrent.ThreadPoolExecutor#setCorePoolSize(int). 10 Integer camel.hystrix.enabled Enable the component. true Boolean camel.hystrix.execution-isolation-semaphore-max-concurrent-requests Number of concurrent requests permitted to HystrixCommand.run(). Requests beyond the concurrent limit will be rejected. Applicable only when executionIsolationStrategy == SEMAPHORE. 20 Integer camel.hystrix.execution-isolation-strategy What isolation strategy HystrixCommand.run() will be executed with. If THREAD then it will be executed on a separate thread and concurrent requests limited by the number of threads in the thread-pool. If SEMAPHORE then it will be executed on the calling thread and concurrent requests limited by the semaphore count. THREAD String camel.hystrix.execution-isolation-thread-interrupt-on-timeout Whether the execution thread should attempt an interrupt (using Future#cancel ) when a thread times out. Applicable only when executionIsolationStrategy() == THREAD. true Boolean camel.hystrix.execution-timeout-enabled Whether the timeout mechanism is enabled for this command. true Boolean camel.hystrix.execution-timeout-in-milliseconds Time in milliseconds at which point the command will timeout and halt execution. If executionIsolationThreadInterruptOnTimeout == true and the command is thread-isolated, the executing thread will be interrupted. If the command is semaphore-isolated and a HystrixObservableCommand, that command will get unsubscribed. 1000 Integer camel.hystrix.fallback-enabled Whether HystrixCommand.getFallback() should be attempted when failure occurs. true Boolean camel.hystrix.fallback-isolation-semaphore-max-concurrent-requests Number of concurrent requests permitted to HystrixCommand.getFallback(). Requests beyond the concurrent limit will fail-fast and not attempt retrieving a fallback. 10 Integer camel.hystrix.group-key Sets the group key to use. The default value is CamelHystrix. CamelHystrix String camel.hystrix.keep-alive-time Keep-alive time in minutes that gets passed to ThreadPoolExecutor#setKeepAliveTime(long,TimeUnit). 1 Integer camel.hystrix.max-queue-size Max queue size that gets passed to BlockingQueue in HystrixConcurrencyStrategy.getBlockingQueue(int) This should only affect the instantiation of a threadpool - it is not eliglible to change a queue size on the fly. For that, use queueSizeRejectionThreshold(). -1 Integer camel.hystrix.maximum-size Maximum thread-pool size that gets passed to ThreadPoolExecutor#setMaximumPoolSize(int) . This is the maximum amount of concurrency that can be supported without starting to reject HystrixCommands. Please note that this setting only takes effect if you also set allowMaximumSizeToDivergeFromCoreSize. 10 Integer camel.hystrix.metrics-health-snapshot-interval-in-milliseconds Time in milliseconds to wait between allowing health snapshots to be taken that calculate success and error percentages and affect HystrixCircuitBreaker.isOpen() status. On high-volume circuits the continual calculation of error percentage can become CPU intensive thus this controls how often it is calculated. 500 Integer camel.hystrix.metrics-rolling-percentile-bucket-size Maximum number of values stored in each bucket of the rolling percentile. This is passed into HystrixRollingPercentile inside HystrixCommandMetrics. 10 Integer camel.hystrix.metrics-rolling-percentile-enabled Whether percentile metrics should be captured using HystrixRollingPercentile inside HystrixCommandMetrics. true Boolean camel.hystrix.metrics-rolling-percentile-window-buckets Number of buckets the rolling percentile window is broken into. This is passed into HystrixRollingPercentile inside HystrixCommandMetrics. 6 Integer camel.hystrix.metrics-rolling-percentile-window-in-milliseconds Duration of percentile rolling window in milliseconds. This is passed into HystrixRollingPercentile inside HystrixCommandMetrics. 10000 Integer camel.hystrix.metrics-rolling-statistical-window-buckets Number of buckets the rolling statistical window is broken into. This is passed into HystrixRollingNumber inside HystrixCommandMetrics. 10 Integer camel.hystrix.metrics-rolling-statistical-window-in-milliseconds This property sets the duration of the statistical rolling window, in milliseconds. This is how long metrics are kept for the thread pool. The window is divided into buckets and rolls by those increments. 10000 Integer camel.hystrix.queue-size-rejection-threshold Queue size rejection threshold is an artificial max size at which rejections will occur even if maxQueueSize has not been reached. This is done because the maxQueueSize of a BlockingQueue can not be dynamically changed and we want to support dynamically changing the queue size that affects rejections. This is used by HystrixCommand when queuing a thread for execution. 5 Integer camel.hystrix.request-log-enabled Whether HystrixCommand execution and events should be logged to HystrixRequestLog. true Boolean camel.hystrix.thread-pool-key Sets the thread pool key to use. Will by default use the same value as groupKey has been configured to use. CamelHystrix String camel.hystrix.thread-pool-rolling-number-statistical-window-buckets Number of buckets the rolling statistical window is broken into. This is passed into HystrixRollingNumber inside each HystrixThreadPoolMetrics instance. 10 Integer camel.hystrix.thread-pool-rolling-number-statistical-window-in-milliseconds Duration of statistical rolling window in milliseconds. This is passed into HystrixRollingNumber inside each HystrixThreadPoolMetrics instance. 10000 Integer camel.language.constant.enabled Whether to enable auto configuration of the constant language. This is enabled by default. Boolean camel.language.constant.trim Whether to trim the value to remove leading and trailing whitespaces and line breaks. true Boolean camel.language.csimple.enabled Whether to enable auto configuration of the csimple language. This is enabled by default. Boolean camel.language.csimple.trim Whether to trim the value to remove leading and trailing whitespaces and line breaks. true Boolean camel.language.exchangeproperty.enabled Whether to enable auto configuration of the exchangeProperty language. This is enabled by default. Boolean camel.language.exchangeproperty.trim Whether to trim the value to remove leading and trailing whitespaces and line breaks. true Boolean camel.language.file.enabled Whether to enable auto configuration of the file language. This is enabled by default. Boolean camel.language.file.trim Whether to trim the value to remove leading and trailing whitespaces and line breaks. true Boolean camel.language.header.enabled Whether to enable auto configuration of the header language. This is enabled by default. Boolean camel.language.header.trim Whether to trim the value to remove leading and trailing whitespaces and line breaks. true Boolean camel.language.ref.enabled Whether to enable auto configuration of the ref language. This is enabled by default. Boolean camel.language.ref.trim Whether to trim the value to remove leading and trailing whitespaces and line breaks. true Boolean camel.language.simple.enabled Whether to enable auto configuration of the simple language. This is enabled by default. Boolean camel.language.simple.trim Whether to trim the value to remove leading and trailing whitespaces and line breaks. true Boolean camel.language.tokenize.enabled Whether to enable auto configuration of the tokenize language. This is enabled by default. Boolean camel.language.tokenize.group-delimiter Sets the delimiter to use when grouping. If this has not been set then token will be used as the delimiter. String camel.language.tokenize.trim Whether to trim the value to remove leading and trailing whitespaces and line breaks. true Boolean camel.resilience4j.automatic-transition-from-open-to-half-open-enabled Enables automatic transition from OPEN to HALF_OPEN state once the waitDurationInOpenState has passed. false Boolean camel.resilience4j.circuit-breaker-ref Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreaker instance to lookup and use from the registry. When using this, then any other circuit breaker options are not in use. String camel.resilience4j.config-ref Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreakerConfig instance to lookup and use from the registry. String camel.resilience4j.configurations Define additional configuration definitions. Map camel.resilience4j.enabled Enable the component. true Boolean camel.resilience4j.failure-rate-threshold Configures the failure rate threshold in percentage. If the failure rate is equal or greater than the threshold the CircuitBreaker transitions to open and starts short-circuiting calls. The threshold must be greater than 0 and not greater than 100. Default value is 50 percentage. Float camel.resilience4j.minimum-number-of-calls Configures the minimum number of calls which are required (per sliding window period) before the CircuitBreaker can calculate the error rate. For example, if minimumNumberOfCalls is 10, then at least 10 calls must be recorded, before the failure rate can be calculated. If only 9 calls have been recorded the CircuitBreaker will not transition to open even if all 9 calls have failed. Default minimumNumberOfCalls is 100. 100 Integer camel.resilience4j.permitted-number-of-calls-in-half-open-state Configures the number of permitted calls when the CircuitBreaker is half open. The size must be greater than 0. Default size is 10. 10 Integer camel.resilience4j.sliding-window-size Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed. slidingWindowSize configures the size of the sliding window. Sliding window can either be count-based or time-based. If slidingWindowType is COUNT_BASED, the last slidingWindowSize calls are recorded and aggregated. If slidingWindowType is TIME_BASED, the calls of the last slidingWindowSize seconds are recorded and aggregated. The slidingWindowSize must be greater than 0. The minimumNumberOfCalls must be greater than 0. If the slidingWindowType is COUNT_BASED, the minimumNumberOfCalls cannot be greater than slidingWindowSize . If the slidingWindowType is TIME_BASED, you can pick whatever you want. Default slidingWindowSize is 100. 100 Integer camel.resilience4j.sliding-window-type Configures the type of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed. Sliding window can either be count-based or time-based. If slidingWindowType is COUNT_BASED, the last slidingWindowSize calls are recorded and aggregated. If slidingWindowType is TIME_BASED, the calls of the last slidingWindowSize seconds are recorded and aggregated. Default slidingWindowType is COUNT_BASED. COUNT_BASED String camel.resilience4j.slow-call-duration-threshold Configures the duration threshold (seconds) above which calls are considered as slow and increase the slow calls percentage. Default value is 60 seconds. 60 Integer camel.resilience4j.slow-call-rate-threshold Configures a threshold in percentage. The CircuitBreaker considers a call as slow when the call duration is greater than slowCallDurationThreshold Duration. When the percentage of slow calls is equal or greater the threshold, the CircuitBreaker transitions to open and starts short-circuiting calls. The threshold must be greater than 0 and not greater than 100. Default value is 100 percentage which means that all recorded calls must be slower than slowCallDurationThreshold. Float camel.resilience4j.wait-duration-in-open-state Configures the wait duration (in seconds) which specifies how long the CircuitBreaker should stay open, before it switches to half open. Default value is 60 seconds. 60 Integer camel.resilience4j.writable-stack-trace-enabled Enables writable stack traces. When set to false, Exception.getStackTrace returns a zero length array. This may be used to reduce log spam when the circuit breaker is open as the cause of the exceptions is already known (the circuit breaker is short-circuiting calls). true Boolean camel.rest.api-component The name of the Camel component to use as the REST API (such as swagger) If no API Component has been explicit configured, then Camel will lookup if there is a Camel component responsible for servicing and generating the REST API documentation, or if a org.apache.camel.spi.RestApiProcessorFactory is registered in the registry. If either one is found, then that is being used. String camel.rest.api-context-path Sets a leading API context-path the REST API services will be using. This can be used when using components such as camel-servlet where the deployed web application is deployed using a context-path. String camel.rest.api-context-route-id Sets the route id to use for the route that services the REST API. The route will by default use an auto assigned route id. String camel.rest.api-host To use an specific hostname for the API documentation (eg swagger) This can be used to override the generated host with this configured hostname. String camel.rest.api-property Allows to configure as many additional properties for the api documentation (swagger). For example set property api.title to my cool stuff. Map camel.rest.api-vendor-extension Whether vendor extension is enabled in the Rest APIs. If enabled then Camel will include additional information as vendor extension (eg keys starting with x-) such as route ids, class names etc. Not all 3rd party API gateways and tools supports vendor-extensions when importing your API docs. false Boolean camel.rest.binding-mode Sets the binding mode to use. The default value is off. RestBindingMode camel.rest.client-request-validation Whether to enable validation of the client request to check whether the Content-Type and Accept headers from the client is supported by the Rest-DSL configuration of its consumes/produces settings. This can be turned on, to enable this check. In case of validation error, then HTTP Status codes 415 or 406 is returned. The default value is false. false Boolean camel.rest.component The Camel Rest component to use for the REST transport (consumer), such as netty-http, jetty, servlet, undertow. If no component has been explicit configured, then Camel will lookup if there is a Camel component that integrates with the Rest DSL, or if a org.apache.camel.spi.RestConsumerFactory is registered in the registry. If either one is found, then that is being used. String camel.rest.component-property Allows to configure as many additional properties for the rest component in use. Map camel.rest.consumer-property Allows to configure as many additional properties for the rest consumer in use. Map camel.rest.context-path Sets a leading context-path the REST services will be using. This can be used when using components such as camel-servlet where the deployed web application is deployed using a context-path. Or for components such as camel-jetty or camel-netty-http that includes a HTTP server. String camel.rest.cors-headers Allows to configure custom CORS headers. Map camel.rest.data-format-property Allows to configure as many additional properties for the data formats in use. For example set property prettyPrint to true to have json outputted in pretty mode. The properties can be prefixed to denote the option is only for either JSON or XML and for either the IN or the OUT. The prefixes are: json.in. json.out. xml.in. xml.out. For example a key with value xml.out.mustBeJAXBElement is only for the XML data format for the outgoing. A key without a prefix is a common key for all situations. Map camel.rest.enable-cors Whether to enable CORS headers in the HTTP response. The default value is false. false Boolean camel.rest.endpoint-property Allows to configure as many additional properties for the rest endpoint in use. Map camel.rest.host The hostname to use for exposing the REST service. String camel.rest.host-name-resolver If no hostname has been explicit configured, then this resolver is used to compute the hostname the REST service will be using. RestHostNameResolver camel.rest.json-data-format Name of specific json data format to use. By default json-jackson will be used. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance. String camel.rest.port The port number to use for exposing the REST service. Notice if you use servlet component then the port number configured here does not apply, as the port number in use is the actual port number the servlet component is using. eg if using Apache Tomcat its the tomcat http port, if using Apache Karaf its the HTTP service in Karaf that uses port 8181 by default etc. Though in those situations setting the port number here, allows tooling and JMX to know the port number, so its recommended to set the port number to the number that the servlet engine uses. String camel.rest.producer-api-doc Sets the location of the api document (swagger api) the REST producer will use to validate the REST uri and query parameters are valid accordingly to the api document. This requires adding camel-swagger-java to the classpath, and any miss configuration will let Camel fail on startup and report the error(s). The location of the api document is loaded from classpath by default, but you can use file: or http: to refer to resources to load from file or http url. String camel.rest.producer-component Sets the name of the Camel component to use as the REST producer. String camel.rest.scheme The scheme to use for exposing the REST service. Usually http or https is supported. The default value is http. String camel.rest.skip-binding-on-error-code Whether to skip binding on output if there is a custom HTTP error code header. This allows to build custom error messages that do not bind to json / xml etc, as success messages otherwise will do. false Boolean camel.rest.use-x-forward-headers Whether to use X-Forward headers for Host and related setting. The default value is true. true Boolean camel.rest.xml-data-format Name of specific XML data format to use. By default jaxb will be used. Important: This option is only for setting a custom name of the data format, not to refer to an existing data format instance. String camel.rest.api-context-id-pattern Deprecated Sets an CamelContext id pattern to only allow Rest APIs from rest services within CamelContext's which name matches the pattern. The pattern name refers to the CamelContext name, to match on the current CamelContext only. For any other value, the pattern uses the rules from PatternHelper#matchPattern(String,String). String camel.rest.api-context-listing Deprecated Sets whether listing of all available CamelContext's with REST services in the JVM is enabled. If enabled it allows to discover these contexts, if false then only the current CamelContext is in use. false Boolean
simple("USD{body.address}") simple("USD{body.address.street}") simple("USD{body.address.zip}") simple("USD{body.address}") simple("USD{body.getAddress.getStreet}") simple("USD{body.address.getZip}") simple("USD{body.doSomething}") simple("USD{body?.address?.street}") simple("USD{body[foo].name}") simple("USD{body['foo bar'].name}") simple("USD{body[foo]}") simple("USD{body[this.is.foo]}") simple("USD{body[foo]?.name}") simple("USD{body.address.lines[0]}") simple("USD{body.address.lines[1]}") simple("USD{body.address.lines[2]}") simple("USD{body.address.lines[last]}") simple("USD{body.address.lines[last-1]}") simple("USD{body.address.lines[last-2]}") simple("USD{body.address.lines.size}") String[] lines = new String[]{"foo", "bar", "cat"}; exchange.getIn().setBody(lines); simple("There are USD{body.length} lines") simple("USD{body.address.zip} > 1000") USD{leftValue} OP rightValue USD{leftValue} OP rightValue && USD{leftValue} OP rightValue USD{leftValue} OP rightValue || USD{leftValue} OP rightValue // exact equals match simple("USD{header.foo} == 'foo'") // ignore case when comparing, so if the header has value FOO this will match simple("USD{header.foo} =~ 'foo'") // here Camel will type convert '100' into the type of header.bar and if it is an Integer '100' will also be converter to an Integer simple("USD{header.bar} == '100'") simple("USD{header.bar} == 100") // 100 will be converter to the type of header.bar so we can do > comparison simple("USD{header.bar} > 100") simple("100 < USD{header.bar}") // testing for null simple("USD{header.baz} == null") // testing for not null simple("USD{header.baz} != null") simple("USD{header.date} == USD{date:now:yyyyMMdd}") simple("USD{header.type} == USD{bean:orderService?method=getOrderType}") simple("USD{header.title} contains 'Camel'") simple("USD{header.number} regex '\\d{4}'") simple("USD{header.type} in 'gold,silver'") simple("USD{header.type} !in 'gold,silver'") simple("USD{header.type} is 'java.lang.String'") simple("USD{header.type} is 'String'") simple("USD{header.number} range 100..199") simple("USD{header.number} range '100..199'") <from uri="seda:orders"> <filter> <simple>USD{header.type} == 'widget'</simple> <to uri="bean:orderService?method=handleWidget"/> </filter> </from> simple("USD{header.title} contains 'Camel' && USD{header.type'} == 'gold'") simple("USD{header.title} contains 'Camel' || USD{header.type'} == 'gold'") <from uri="seda:orders"> <filter> <simple>USD{header.foo}</simple> <to uri="mock:fooOrders"/> </filter> </from> from("seda:orders") .filter().simple("USD{header.foo}") .to("seda:fooOrders"); from("direct:hello") .transform().simple("Hello USD{header.user} how are you?") .to("mock:reply"); from("direct:hello") .transform().simple("The today is USD{date:now:yyyyMMdd} and it is a great day.") .to("mock:reply"); from("direct:order") .transform().simple("OrderId: USD{bean:orderIdGenerator}") .to("mock:reply"); from("direct:order") .transform().simple("OrderId: USD{bean:orderIdGenerator.generateId}") .to("mock:reply"); from("direct:order") .transform().simple("OrderId: USD{bean:orderIdGenerator?method=generateId}") .to("mock:reply"); <transform> <simple>Hello USD{bodyAs(String)} how are you?</simple> </transform> <transform> <simple>The gold value is USD{header.type[gold]}</simple> </transform> <setHeader name="myHeader"> <simple>USD{properties:USD{header.someKey}}</simple> </setHeader> .setHeader("cool", simple("true", Boolean.class)) <setHeader name="cool"> <!-- use resultType to indicate that the type should be a java.lang.Boolean --> <simple resultType="java.lang.Boolean">true</simple> </setHeader> <transform> <simple>The following text\nis on a new line</simple> </transform> <setBody> <simple trim="false">You get some trailing whitespace characters. </simple> </setBody> .setHeader("myHeader").simple("resource:classpath:mysimple.txt") <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-core-starter</artifactId> </dependency>