We have a microservice that integrates with a third party system via REST API to handle appointment booking for our customer. It takes advantage of the event-driven model. Our microservice emits out an integration event called the AppointmentCreated event post-appointment booking with the third party service.
The AppointmentCreated event is handled in the processor, which notifies our internal(monolithic) system to do some POST appointment work. Example processes we have in processor and the processor will go to the next step regardless these steps succeed or not, which was okay when we started this project
- Notify the internal system that a customer booked an appointment
- Update User consents based on whether they selected to be opt-in for SMS notification
Current AppointmentCreated C#
public class AppointmentCreated : IntegrationEvent
{
public int Id { get; set; }
public DateTimeOffset CreatedAt { get; set; }
public string PatientName { get; set; }
public DateTimeOffset StartTime { get; set; }
public DateTimeOffset EndTime { get; set; }
public bool SmsConsent { get; set; }
public Guid? ContactKey { get; set; }
public string PatientEmail { get; set; }
}
Now the business is asking to notify the SalesForce team via a REST API call once the appointment is booked in our microservice with what we send out in the REQUEST with the third party and the RESPONSE we get from the third party HTTP call. The business also wants to be notified whether we fail to notify SalesForce for any number of reason, which we can have some alerts set up on the event bus to do that.
Would it make sense to emit out a specific integration event from our microservice just to notify ThirdParty on our event bus and handle the REST API to notify SalesForce in the processor? Emit two events after our microservice is able to book an appointment with the third party.
- AppointmentCreated
- NotifySalesForceAppointmentCreated only needs Request and Response data that we make the call to the third-party application to make an appointment. We only want this data on successful appointment booking. It doesn't care about the current AppointmentCreated content.
Do you guys have any suggestion or anything with this approach?