title: Updating global store from data within transform
body: <p>I currently have a simple topology:</p>
  
  <pre><code>    KStream&lt;String, Event&gt; eventsStream = builder.stream(sourceTopic);
      eventsStream.transformValues(processorSupplier, "nameCache")
          .to(destinationTopic);
  </code></pre>
  
  <p>My events sometimes have a key/value pair and other times have just the key.  I want to be able to add the value to those events that are missing the value.  I have this working fine with a local state store but when I add more tasks, sometimes the key/value events and the value events are in different threads and so they aren't updated correctly.</p>
  
  <p>I'd like to use a global state store for this but I'm having difficulty figuring out how to update the global store when new key/value pairs come in.  I've created a global state store with the following code:</p>
  
  <pre><code>    builder.addGlobalStore(stateStore, "global_store", Consumed.with(Serdes.String(), Serdes.String()), new ProcessorSupplier&lt;String, String&gt;() {
        @Override
        public Processor&lt;String, String&gt; get() {
          return new Processor&lt;String, String&gt;() {
            private ProcessorContext context;
            @Override
            public void init(final ProcessorContext processorContext) {
              this.context = processorContext;
            }
  
            @Override
            public void process(final String key, final String value) {
              context.forward(key, value);
            }
  
            @Override
            public void close() {
            }
          };
        }
      });
  </code></pre>
  
  <p>As far as I can tell, it is working but since there is no data in the topic, I'm not sure.</p>
  
  <p>So my question is how do I update the global store from inside of the transformValues?  <code>store.put()</code> fails with an error that global store is read only.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/56239980/write-to-globalstatestore-on-kafka-streams">Write to GlobalStateStore on Kafka Streams</a> but the accepted answer just says to update the underlying topic but I don't see how I can do that since the topic isn't in my stream.</p>
  
  <p>---Edited---</p>
  
  <p>I updated the code per #1 in the accepted answer.  I see the new key/value pairs show up in <code>global_store</code>.  But the globalStore doesn't seem to see the new keys.  If I restart the application, it fills the cache with the data in the topic but new keys aren't visible until after I stop/start the application.</p>
  
  <p>I added logging to the <code>process(String, String)</code> in the global store processor and it shows new keys being processed.  Any ideas?</p>