Now we will look at the subscriber, will go back to our solution. If you notice, we have the Handler executed and the Handler raises the event called CustomerAdded.
So if we go to the endpoint, we have our subscriber configured to listen to the Handler End point.
Whatever events are being fired from the Handler will be executed by the subscriber and the subscriber has the bus gamma default subscriber.
This is configured in the common messages That all the subscriber interfaces will be available in the messages, which is used commonly across all the other Solutions.
Bus gamma subscriber receives the event and the subscriber's execute method is called where the way it is written and it is like this because again we are decoupling from the bus and the logic relies with the subscriber file, this can be swapped with any other bus implementation.
public async Task Execute(CustomerAdded @event, IFlexServiceBusContext serviceBusContext)
{
//TODO: Write your business logic here:
_logger.LogInformation(@event.Id);
//TODO: Specify your condition to raise event here...
//TODO: Set the value of OnRaiseEventCondition according to your business logic
OnRaiseEventCondition = CONDITION_ONSUCCESS;
RaiseEventCondition raiseEventCondition = new RaiseEventCondition(OnRaiseEventCondition);
await raiseEventCondition.RaiseEvent<SendEmailToCustomerOnAdded>(this, new object[] { serviceBusContext });
}
private async Task OnSuccess(IFlexServiceBusContextBridge serviceBusContext)
{
EmailSentToCustomerOnAdded @event = new EmailSentToCustomerOnAdded
{
HostContextInfo=serviceBusContext.HostContextInfo,
//Add your properties here
};
await serviceBusContext.Publish(@event);
}