Azure / azure-relay-dotnet

☁️ .NET Standard client library for Azure Relay Hybrid Connections

Home Page:https://docs.microsoft.com/en-us/azure/service-bus-relay/relay-what-is-it

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hybrid-connection as EventGrid endpoint

shibin-george opened this issue · comments

This is not exactly an issue but just checking the behavior. I am using hybrid-connection listener as a endpoint to EventGrid subscription.. I want EventGrid to retry event delivery if there's an exception in the request-handler i.e.


_hybridConnectionlistener.RequestHandler = async (context) =>
    {
        try
        {
            DoSomethingWithEventGridEventThatCouldThrowException();
            context.Response.StatusCode = System.Net.HttpStatusCode.OK;
            context.Response.Close();
        }
        catch (Exception e)
        {
            // At this point, I would like EventGrid to retry delivery
        }
    };

I observed that if I don't call the context.Response.Close() on exception, EventGrid tries redelivery of event but wondering if that's the right way to achieve this?

One alternative is to set the status-code to 500 and then close the context but just wanted to make sure that this status code is not modified by the relay library and is sent to EventGrid as is:


_hybridConnectionlistener.RequestHandler = async (context) =>
    {
        try
        {
            DoSomethingWithEventGridEventThatCouldThrowException();
            context.Response.StatusCode = System.Net.HttpStatusCode.OK;
            context.Response.Close();
        }
        catch (Exception e)
        {
            // At this point, I would like EventGrid to retry delivery
            context.Response.StatusCode = System.Net.HttpStatusCode.InternalServerError;
            context.Response.Close();
        }
    };