title: In Flink, how can I access the Key when applying a Process Function on a Keyed Stream?
body: <p>In Flink, I have a keyed stream to which I am applying a Process Function.  </p>
  
  <pre><code>myDataStream
    .keyBy(new MyKeySelector())
    .process(new FooBarProcessFunction())
  </code></pre>
  
  <p>My Key Selector looks something like this...</p>
  
  <pre><code>public class MyKeySelector implements KeySelector&lt;FooBar, FooKey&gt;
  
  public FooKey getKey (FooBar value) {
     return new FooKey (value);
  }
  </code></pre>
  
  <p>And FooBarProcessFunction looks something like this...</p>
  
  <pre><code>public class FooBarProcessFunction extends ProcessFunction&lt;FooBar, TransformedFooBar&gt; {
  
      public void processElement(FooBar newFooBar, Context ctx, Collector&lt;FooBar&gt; out) {
          //do something with newFooBar
          // *****but I also want to know the Key (FooKey) here***** 
      }
  }
  </code></pre>
  
  <p>In FooBarProcessFunction, I would like to obtain the Key which was created by MyKeySelector's getKey method.  Is that doable?</p>
  
  <p>At present, I am using a workaround wherein I essentially recreate the Key in the processElement function.  But it would be ideal if I can avoid doing so.</p>