anchor.diff: +// Category: debezium-using
  +// Type: assembly
  +// ModuleID: routing-change-event-records-to-topics-according-to-event-content
  +// Title: Routing change event records to topics according to event content
   [id="content-based-routing"]
  -= Content-Based Routing
  += Content-based routing
   
   :toc:
   :toc-placement: macro
  
positive.code: 
  toc::[]
  
  [NOTE]
  ====
  This SMT is currently in incubating state, i.e. exact semantics, configuration options etc. may change in future revisions, based on the feedback we receive. Please let us know if you encounter any problems while using this routing transformation.
  ====
  
  With real-life applications, it is often necessary to route the events not only to a static topic but to a topic based on the message content.
  This is expressed as the https://www.enterpriseintegrationpatterns.com/patterns/messaging/ContentBasedRouter.html[Content-Based Router] integration pattern.
  Kafka Connect provides a generic mechanism to do the routing in the form of link:https://cwiki.apache.org/confluence/display/KAFKA/KIP-66%3A+Single+Message+Transforms+for+Kafka+Connect[Simple Message Transforms] (SMT).
  
  The SMT is a Java class that encodes the routing logic.
  This is a very powerful mechanism but has two drawbacks:
  
  * It is necessary to compile the transformation upfront and deploy it to Kafka Connect.
  * Every change needs code recompilation and redeployment, leading to inflexible operations.
  
  To solve this problem, {prodname} comes with the Content-Based Router SMT.
  This SMT allows the operator to write an expression that is evaluated for each event and according to the result, it is either kept in the original topic or re-routed to another one.
  The current implementation supports any scripting language which integrates with https://jcp.org/en/jsr/detail?id=223[JSR 223] (Scripting for the Java(TM) Platform).
  
  The Content-Based Router SMT can be used like so:
  
  [source]
  ----
  
negative.code: 
  |[[content-based-router-topic-regex]]<<content-based-router-topic-regex, `topic.regex`>>
  |
  |An optional regular expression that evaluates the name of the destination topic for an event to determine whether to apply the condition logic. 
  If the name of the destination topic matches the value in `topic.regex`, the transformation applies the condition logic before it passes the event to the topic.
  If the name of the topic does not match the value in `topic.regex`, the SMT passes the event to the topic unmodified.
  
  |[[content-based-router-language]]<<content-based-router-language, `language`>>
  |
  |The language in which the expression is written. Must begin with `jsr223.`, e.g. `jsr223.groovy`, or `jsr223.graal.js`. {prodname} supports bootstrapping through the https://jcp.org/en/jsr/detail?id=223[JSR 223 API ("Scripting for the Java (TM) Platform")] only.
  
  |[[content-based-router-topic-expression]]<<content-based-router-topic-expression, `topic.expression`>>
  |
  |The expression to be evaluated for every message. Must evaluate to a `String` value where a result of non-null reroutes the message to a new topic, and a `null` value routes the message to the default topic.
  
  |[[content-based-router-null-handling-mode]]<<content-based-router-null-handling-mode, `null.handling.mode`>>
  |`keep`
  a|Specifies how the transformation handles `null` (tombstone) messages. You can specify one of the following options: 
  
  `keep`:: (Default) Pass the messages through.
  `drop`:: Remove the messages completely.
  `evaluate`:: Apply the condition logic to the messages.
  |===
  