title: How to update the value of a Key in ObjectStore in Mule4?
body: <p>My requirement is, i need to count messages which are processed for a day.
  So, i created a subflow, where I created a persistent objectstore . I retrive it initially with the default value 0. Then , I  pass that to java AtomicInteger class to do increment each time, when request comes in. Now I store the new value.</p>
  
  <pre><code>    &lt;sub-flow name="impl-message-counter:\counter-set-flow" doc:id="929c5fa5-74a2-4e8e-b1a0-43209b57222c" &gt;
  
  
     &lt;os:retrieve doc:name="Retrieve" doc:id="565ecf6c-ffba-491e-b2c9-35ef4b4f52ad" key="counter" objectStore="Object_store" target="count"&gt;
              &lt;os:default-value &gt;&lt;![CDATA[0]]&gt;&lt;/os:default-value&gt;
          &lt;/os:retrieve&gt;
              &lt;java:new constructor="AtomicInteger(int)" doc:name="New" doc:id="f0e75c0b-914a-44ee-9e24-a597025afd77" class="java.util.concurrent.atomic.AtomicInteger" target="atomicinteger"&gt;
                  &lt;java:args &gt;&lt;![CDATA[#[output application/java
      ---
      {
      arg0 : vars.count as Number {class: "java.lang.Integer"}
      }]]]&gt;&lt;/java:args&gt;
              &lt;/java:new&gt;
              &lt;java:invoke doc:name="Invoke" doc:id="60779082-ad71-4770-b871-8d86044aa62a" instance="#[vars.atomicinteger]" class="java.util.concurrent.atomic.AtomicInteger" method="incrementAndGet()" target="newVal"/&gt;
          &lt;os:store doc:name="Store" doc:id="8f85aa4f-5bce-4248-8a3b-a8cde27a1307" key="counter" objectStore="Object_store"&gt;
              &lt;os:value&gt;&lt;![CDATA[#[vars.newVal]]]&gt;&lt;/os:value&gt;
          &lt;/os:store&gt; 
  
          &lt;/sub-flow&gt;
  </code></pre>
  
  <p>In the above flow, i want to add a check processor, to see the day is passed or not. If it passes midnight I wnat to reassign it to 0. Else continue with increment;</p>
  
  <pre><code>&lt;choice doc:name="Choice" doc:id="120b1f05-7afe-4cfc-a103-0b26f9df7140" &gt;
              &lt;when expression="#[now().hour==23 and now().minutes==59 and now().seconds==60]"&gt;
                  &lt;os:store doc:name="Store" doc:id="3d995b22-a648-4c7f-af54-33d70b23705c" key="counter" objectStore="Object_store" &gt;
                      &lt;os:value &gt;&lt;![CDATA[#[0]]]&gt;&lt;/os:value&gt;
                  &lt;/os:store&gt;
              &lt;/when&gt;
              &lt;otherwise &gt;
                  &lt;os:store doc:name="Store" doc:id="8f85aa4f-5bce-4248-8a3b-a8cde27a1307" key="counter" objectStore="Object_store"&gt;
              &lt;os:value&gt;&lt;![CDATA[#[vars.newVal]]]&gt;&lt;/os:value&gt;
          &lt;/os:store&gt;
              &lt;/otherwise&gt;
          &lt;/choice&gt;
  </code></pre>
  
  <p>But above will work? I think it will skip if same key present in same objectstore? How can I update existing key?</p>