title: Spring Do I need to use an EventListener instead of Async?
body: <p>I am working with an application that uses Spring's <code>ApplicationEventPublisher</code> to publish messages. We will have functions that do some complex read/update functionality against an rdbms and then publish that message to do work like emailing users or even publishing sqs messages for other microservices.</p>
  <pre><code>ApplicationEventPublisher eventPublisher;
  UpdateEvent event = UpdateEvent.builder().eventSource(&quot;SomeUpdate&quot;)
                      .scenarioId(scenarioId).build();
  eventPublisher.publishEvent(event);
  </code></pre>
  <p>and a listener:</p>
  <pre><code>public interface LocalMessageHandlingAsyncService {
  
      @TransactionalEventListener
      void publishUpdateEvent(UpdateEvent mediaPlanUpdateEvent);
  
  </code></pre>
  <p>Because some of the events will do reads against the database around the data that was just worked on we use the <code>@TransactionalEventListener</code> to make sure we work on the latest committed data. As I look at this type of pattern I wonder what the advantage of this is versus just calling a separate async method?</p>
  <p>With an async method we don't have to worry about serializing objects to json or creating separate Event objects to manage. We still have to worry about open transactions, but that is solvable, I believe, using the TransactionSynchronizationManager.</p>
  <p>As far as I can tell the advantage to using events over a call to an async method is that multiple areas of the application might want to listen for the event. That does not match our use case however, as we just have one consumer.</p>