--- apiVersion: v1 kind: List items: - apiVersion: v1 kind: ConfigMap metadata: labels: funktion.fabric8.io/kind: Connector provider: fabric8 project: connector-binding version: 1.1.37 group: io.fabric8.funktion.connector name: binding data: deployment.yml: | --- apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: funktion.fabric8.io/kind: Subscription connector: binding spec: replicas: 1 template: metadata: labels: funktion.fabric8.io/kind: Subscription connector: binding spec: containers: - image: funktion/connector-binding:1.1.37 name: connector schema.yml: | --- component: kind: component scheme: binding syntax: binding:bindingName:delegateUri title: Binding description: The binding component is used for as a of wrapping an Endpoint in a contract with a data format. label: core,transformation deprecated: false async: false javaType: org.apache.camel.component.binding.BindingNameComponent groupId: org.apache.camel artifactId: camel-core version: 2.18.1 componentProperties: {} properties: bindingName: kind: path group: common required: true type: string javaType: java.lang.String deprecated: false secret: false description: Name of the binding to lookup in the Camel registry. order: 0 delegateUri: kind: path group: common required: true type: string javaType: java.lang.String deprecated: false secret: false description: Uri of the delegate endpoint. order: 1 bridgeErrorHandler: kind: parameter group: consumer label: consumer type: boolean javaType: boolean optionalPrefix: consumer. deprecated: false secret: false defaultValue: false description: Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. order: 2 exceptionHandler: kind: parameter group: consumer (advanced) label: consumer,advanced type: object javaType: org.apache.camel.spi.ExceptionHandler optionalPrefix: consumer. deprecated: false secret: false description: To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. order: 3 exchangePattern: kind: parameter group: consumer (advanced) label: consumer,advanced type: string javaType: org.apache.camel.ExchangePattern enum: - InOnly - RobustInOnly - InOut - InOptionalOut - OutOnly - RobustOutOnly - OutIn - OutOptionalIn deprecated: false secret: false description: Sets the default exchange pattern when creating an exchange. order: 4 synchronous: kind: parameter group: advanced label: advanced type: boolean javaType: boolean deprecated: false secret: false defaultValue: false description: Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). order: 5 documentation.adoc: | [[Binding-Binding]] Binding ------- In Camel terms a _binding_ is a way of wrapping an link:endpoint.html[Endpoint] in a contract; such as a link:data-format.html[Data Format], a link:content-enricher.html[Content Enricher] or validation step. Bindings are completely optional and you can choose to use them on any link:components.html[camel endpoint]. Bindings are inspired by the work of http://www.jboss.org/switchyard[SwitchYard project] adding service contracts to various technologies like Camel and many others. But rather than the SwitchYard approach of wrapping Camel in SCA, _Camel Bindings_ provide a way of wrapping Camel endpoints with contracts inside the Camel framework itself; so you can use them easily inside any Camel route. [[Binding-Options]] Options ^^^^^^^ // component options: START The Binding component has no options. // component options: END // endpoint options: START The Binding component supports 6 endpoint options which are listed below: {% raw %} [width="100%",cols="2,1,1m,1m,5",options="header"] |======================================================================= | Name | Group | Default | Java Type | Description | bindingName | common | | String | *Required* Name of the binding to lookup in the Camel registry. | delegateUri | common | | String | *Required* Uri of the delegate endpoint. | bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored. | exceptionHandler | consumer (advanced) | | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored. | exchangePattern | consumer (advanced) | | ExchangePattern | Sets the default exchange pattern when creating an exchange. | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). |======================================================================= {% endraw %} // endpoint options: END [[Binding-UsingBindings]] Using Bindings ~~~~~~~~~~~~~~ A Binding is currently a bean which defines the contract (though we'll hopefully add bindings to the Camel DSL). There are a few approaches to defining a bound endpoint (i.e. an endpoint bound with a Binding). [[Binding-UsingthebindingURI]] Using the binding URI ^^^^^^^^^^^^^^^^^^^^^ You can prefix any endpoint URI with *binding:nameOfBinding:* where _nameOfBinding_ is the name of the Binding bean in your registry. [source,java] ------------------------------------------------------------------------------ from("binding:jaxb:activemq:myQueue").to("binding:jaxb:activemq:anotherQueue") ------------------------------------------------------------------------------ Here we are using the "jaxb" binding which may, for example, use the JAXB link:data-format.html[Data Format] to marshal and unmarshal messages. [[Binding-UsingaBindingComponent]] Using a BindingComponent ^^^^^^^^^^^^^^^^^^^^^^^^ There is a link:component.html[Component] called BindingComponent which can be configured in your link:registry.html[Registry] by dependency injection which allows the creation of endpoints which are already bound to some binding. For example if you registered a new component called "jsonmq" in your registry using code like this [source,java] ----------------------------------------------------------------------------------------------------- JacksonDataFormat format = new JacksonDataFormat(MyBean.class); context.bind("jsonmq", new BindingComponent(new DataFormatBinding(format), "activemq:foo.")); ----------------------------------------------------------------------------------------------------- Then you could use the endpoint as if it were any other endpoint. [source,java] ------------------------------------------------ from("jsonmq:myQueue").to("jsonmq:anotherQueue") ------------------------------------------------ which would be using the queueus "foo.myQueue" and "foo.anotherQueue" and would use the given Jackson link:data-format.html[Data Format] to marshal on and off the queue. [[Binding-WhentouseBindings]] When to use Bindings ~~~~~~~~~~~~~~~~~~~~ If you only use an endpoint once in a single route; a binding may actually be more complex and more work than just using the 'raw' endpoint directly and using explicit marshalling and validation in the camel route as normal. However bindings can help when you are composing many routes together; or using a single route as a 'template' that is configured input and output endpoints; bindings then provide a nice way to wrap up a contract and endpoint together. Another good use case for bindings is when you are using many endpoints which use the same binding; rather than always having to mention a specific data format or validation rule, you can just use the BindingComponent to wrap the endpoints in the binding of your choice. So bindings are a composition tool really; only use them when they make sense - the extra complexity may not be worth it unless you have lots of routes or endpoints.