title: design issue with sending email notification while calling jersey service (PUT)
body: <p>I am having a design issue here. I have a RESTful web service implemented with <a href="http://jersey.java.net/" rel="nofollow" title="jersey">jersey</a>. I am also using spring mail to send email.</p>
  
  <p>My specification needs to notify a certain group of users (15-20 approx.) that a PUT request has been made and inform them with the modification of a resource. Also I need to send a JSON array to the client who made the request as a response.</p>
  
  <p>Right now what I have done is after the modification in my method where I process the PUT service,I send emails to the users and then I return the JSON status.</p>
  
  <p>But why should the client wait for the mail notification to finish?What if my suer list is long and clients wait a long time to get a response.  It is not his headache. But also I need to notify users too within the PUT method. If I return JSON I lost the context to send notification by getting out from the request response cycle.</p>
  
  <p>Is there  a better way to do that?</p>
  
  <p>To have an idea,I am providing the relevant part of my code:</p>
  
  <pre><code> //first notify users
   notifyUsers(event,jsonEntity,NotificationType.TicketType.UPDATED);
  
   //then return response  
   return new JSONObject()
              .put("response_code:", Response.status(Status.OK).build())
              .put("title", evento.getDescrizioneevento())
              .put("status", getEventAsString(evento.getStatoevento()))
              .put("solved", evento.getCausascatenante());
  </code></pre>