Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# BasicDeliverEventArgs not available #240

Open
niwrA opened this issue Nov 14, 2024 · 4 comments
Open

C# BasicDeliverEventArgs not available #240

niwrA opened this issue Nov 14, 2024 · 4 comments

Comments

@niwrA
Copy link

niwrA commented Nov 14, 2024

When I setup a trigger to receive the BasicDeliverEventArgs, I get an empty object:

For instance, when I do this:

public void Run(
    [RabbitMQTrigger("queue", ConnectionStringSetting = "RabbitMQConnection")] BasicDeliverEventArgs args)
{

For me I need the reply-to property, which is generated by RabbitMQ when you send a message using the direct-reply method and has a unique id attached to it that I can only find here. So there is no other way for me to solve this issue, rendering azure functions useless for me for this purpose at the moment.

I'm testing this locally. If I use this, as I do in another trigger where I don't need reply-to, I do get the message correctly:

public void Run(
    [RabbitMQTrigger("otherqueue", ConnectionStringSetting = "RabbitMQConnection")] string message)
{

Documentation around the web suggested that this method should work and I couldn't find any other method to get the replyto property. Can anyone help?

@aloiva
Copy link

aloiva commented Nov 26, 2024

Hi @niwrA, we have tested the scenario you mentioned in local setup using samples in the repo and were able to receive a populated BasicDeliverEventArgs object. Would you mind sharing more details about your function, settings etc to let us help you?

Regarding the second part of your query, you can access the reply-to property in your function using BasicDeliverEventArgs.BasicProperties.ReplyTo.

@niwrA
Copy link
Author

niwrA commented Nov 27, 2024

Thank you for your reply. Here are my project settings/dependencies:


<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net8</TargetFramework>
        <AzureFunctionsVersion>V4</AzureFunctionsVersion>
        <OutputType>Exe</OutputType>
        <Nullable>enable</Nullable>
    </PropertyGroup>
    <ItemGroup>
        <FrameworkReference Include="Microsoft.AspNetCore.App"/>
        <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Core" Version="1.19.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.3.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.RabbitMQ" Version="2.0.3" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Grpc" Version="1.16.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk.Analyzers" Version="1.2.1" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk.Generators" Version="1.3.0" />
        <PackageReference Include="WebJobs.Extensions.RabbitMQ" Version="1.1.1" />
    </ItemGroup>
    <ItemGroup>
        <None Update="host.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Update="local.settings.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
            <CopyToPublishDirectory>Never</CopyToPublishDirectory>
        </None>
        <None Update="host.json">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
          <CopyToPublishDirectory>Never</CopyToPublishDirectory>
        </None>
    </ItemGroup>
    <ItemGroup>
        <Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
    </ItemGroup>
</Project>

@niwrA
Copy link
Author

niwrA commented Nov 27, 2024

Here are my local.settings.json

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=false",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
        "ServiceBusConnection__fullyQualifiedNamespace": "redacted.servicebus.windows.net",
        "RabbitMQConnection": "amqp://guest:guest@localhost:5672"
    },
    "Host": {
        "LocalHttpPort": 7071,
        "CORS": "*",
        "CORSCredentials": false
      }
}

@vigouredelaruse
Copy link

i also have this problem with and only with the rabbitmq trigger in durable functions dotnet-isolated

this is to report that if you inject FunctionContext as per the attached you may find the items you're looking for in BasicDeliverEventArgs
Image

i'm about to try this workaround out now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants