title: HashMap with Flux in Reactive Programming
body: <p>I have to convert the following code into the non-blocking(asynchronous) process.</p>
  <h2>EmpController class</h2>
  <pre><code>@RestController
  @RequestMapping(&quot;/emp&quot;)
  public class EmpController {
  
   private EmployeeRepository empRepo;
  
  @Autowired
  public EmpController(EmployeeRepository empRepo)
  {
      this.empRepo=empRepo;
  }
  
     @PostMapping(&quot;/save/all&quot;)
      @Consumes({MediaType.APPLICATION_JSON})
      public void saveEmpAll(@RequestBody List&lt;Employee&gt; emps)
      {
          empRepo.saveEmpAll(emps);
      }
  }
  </code></pre>
  <h2>EmployeeRepository class</h2>
  <pre><code>@Repository
  public class EmployeeRepository implements EmployeeDAO {
  
   @Override
      public void saveEmpAll(List&lt;Employee&gt; emps) {
  
          Map&lt;Long,Employee&gt; employees=new HashMap&lt;&gt;();
  
          emps.forEach(emp-&gt;{
              emp.setDate(new Date());
              employees.put(emp.getId(),emp);
          });
          hashOperations.putAll(&quot;EMP&quot;,employees);
      }
  
  }
  </code></pre>
  <p>Use Reactive Programming with Spring Webflux</p>
  <p>controller</p>
  <pre><code>@PostMapping(&quot;/save/all&quot;)
      @Consumes({MediaType.APPLICATION_JSON})
      public void saveEmpAll(@RequestBody Flux&lt;Employee&gt; emps)
      {
          emps.collectMap(e-&gt;{
             e.setDate(new Date());
             // todo.............( can I do like this? is it the right way?)
          });
      }
  </code></pre>
  <p>ropository</p>
  <pre><code>  @Override
      public void saveEmpAll(Map&lt;Long,Employee&gt; employees) {
          hashOperations.putAll(&quot;EMP&quot;,employees);
      }
  </code></pre>
  <p>is there any other way to create HashMap and put values into it in an asynchronous way with Flux?</p>