title: How to create a callback in Groovy
body: <p>I'm developing a DSL with groovy which allows to study data coming from kafka topics, my DSL looks like that</p>
  
  <pre><code>study(timestamp,region){
      content {
          // in the block content I can declare several variables which are then used in the block where
          data1 = topic(“topic1”) // the topic method allows you to subscribe to the topic with the name "topic1"
          data2 = topic(“topic2”) // the topic method allows you to subscribe to the topic with the name "topic2"
              }
      where {
             // define predicates on the data such as 'in', '&gt; =', '&lt;=', '==', etc.
             data1["timestamp"] == timestamp AND data2["region"] == region
           }
      then {
            // make actions when the block where return true
           }
  }
  </code></pre>
  
  <p>my problem is how to execute the block where each time I receive a new data from kafka and how to use the variables defined in the scope of the closure content in the block where, for example the variable data1 is defined in the closure content so how I can use it in the where block.</p>