Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-2000

Content-based topic routing based on scripting languages

    XMLWordPrintable

Details

    Description

      Similar to the recently added message filter SMT, it should also be possible to determine the topic a record gets sent to using scripting languages such as JavaScript (graal.js) or Groovy. Going beyond the capabilities of the existing logical topic router (which solely works on the original topic name of change events), such script-based router will allow for true content based change event routing.

      E.g. the change events from a table of purchase orders can be routed to two different topics, depending on whether they are B2B or B2C orders:

      ...
      transforms=router
      transforms.router.type=io.debezium.transforms.Router
      transforms.router.language=jsr223.graals
      transforms.router.topics=dbserver1.inventory.purchase_order
      transforms.router.expression=value.after.order_category == 'B2B' ? 'dbserver1.inventory.b2b_orders' : 'dbserver1.inventory.b2c_orders'
      ...
      

      It'd be useful to be able to refer back to capture group(s) from the topics regex from within the script expression.

      Attachments

        Activity

          People

            jpechane Jiri Pechanec
            gmorling@redhat.com Gunnar Morling
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: