chagantivamsi87
New member
- Joined
- Dec 24, 2021
- Messages
- 3
- Programming Experience
- 10+
HI All,
I have scenario where I need to publish "EventGridTopicEvent" data and at the same time I need to store this event information in the Azure Storage Table. I would like to know is there any way to get the information(like T/F) if Publish event successfully done or not(any error), If it is published successfully then only I should save the data into Table storage.
I need to handle the above logic via C# Event Handler(Mediator), I tried with C# TransactionScope but it is not having mechanism like Rollback. If event is not published then rollback the event as well as not store anything in the table storage or I should not make a call to handle the database transaction.
I have also tried _mediator.Publish(request).IsCompletedSuccessfully but it is giving true always even though I pass invalid request data.
code snippet
I have scenario where I need to publish "EventGridTopicEvent" data and at the same time I need to store this event information in the Azure Storage Table. I would like to know is there any way to get the information(like T/F) if Publish event successfully done or not(any error), If it is published successfully then only I should save the data into Table storage.
I need to handle the above logic via C# Event Handler(Mediator), I tried with C# TransactionScope but it is not having mechanism like Rollback. If event is not published then rollback the event as well as not store anything in the table storage or I should not make a call to handle the database transaction.
I have also tried _mediator.Publish(request).IsCompletedSuccessfully but it is giving true always even though I pass invalid request data.
code snippet
C#:
public async Task<Result<Response<XYZ>>> Handle(EventGridTopicEvent request, CancellationToken cancellationToken)
{
using TransactionScope transactionScope = new TransactionScope();
{
try
{
bool eventPublishStatus = _mediator.Publish(request).IsCompletedSuccessfully;
if (eventPublishStatus)
{
//Insert request data to Table storage
}}}}
Last edited by a moderator: