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

Updating from 4.2.1 to 5.1.0 introduces issue with MessageReceiver #25375

Closed
jenp-jb opened this issue Nov 17, 2021 · 12 comments
Closed

Updating from 4.2.1 to 5.1.0 introduces issue with MessageReceiver #25375

jenp-jb opened this issue Nov 17, 2021 · 12 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Functions issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus

Comments

@jenp-jb
Copy link

jenp-jb commented Nov 17, 2021

Query/Question
Upgrading the extension nuget package from 4.2.1 to 5.1.0 resulted in IMessageReceiver and MessageReceiver in my function / class becoming unknown. I use this in order to be able to Complete and Deadletter messages according to our logic as some failures will never succeed so there's no point retrying.

I tried to fix this by installing the deprecated Microsoft.Azure.ServiceBus nuget package 5.2.0. This allows for the code to be compiled but running the function gives me the error:
Microsoft.Azure.WebJobs.Host: Error indexing method 'XXX'. Microsoft.Azure.WebJobs.Host: Can't bind parameter 'messageReceiver' to type 'Microsoft.Azure.ServiceBus.Core.MessageReceiver'.
The reason I use IMessageReceiver is for moq unit test purposes so I can assert that a message was completed/deadlettered as expected.

image

image

Whilst there is documentation on how to instantiate a MessageReceiver - I can't seem to find any reference to accessing it within the ServiceBusTriggered Function.

It doesn't seem like MessageReceiver is part of the newer Azure.Messaging.ServiceBus package as I explored using that as well.

Environment:

  • Microsoft.Azure.WebJobs.Extensions.ServiceBus 5.1.0
  • Azure Function App (but also fails locally)
    -Visual Studio 16.11.5
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 17, 2021
@JoshLove-msft
Copy link
Member

JoshLove-msft commented Nov 17, 2021

Hi @jenp-jb,
The MessageReceiver has been replaced with ServiceBusMessageActions in version 5.0.0. Please have a look at our samples to see how this type is used.

In terms of the unit testing, can you share an example test to help me understand?

@JoshLove-msft JoshLove-msft added Client This issue points to a problem in the data-plane of the library. Service Bus labels Nov 17, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Nov 17, 2021
@JoshLove-msft JoshLove-msft added Functions needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Nov 17, 2021
@JoshLove-msft JoshLove-msft self-assigned this Nov 17, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Nov 17, 2021
@JoshLove-msft JoshLove-msft added the needs-author-feedback Workflow: More information is needed from author to address the issue. label Nov 17, 2021
@jenp-jb
Copy link
Author

jenp-jb commented Nov 17, 2021

@JoshLove-msft So I have an internal property on my function that I set in the test with a mock so that I can verify completed or deadlettered was called as expected:

image

I did make some progress with the ServiceBusMessageActions but am struggling to find how to add the retryOptions to my host.json file. For some reason Visual Studio is reporting invalid values (even if I use the example on the microsoft page) https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus#additional-settings-for-version-5x

For version 4.2.1 I was using:
image

But trying to add the clientRetryOptions like so:

image
gives me this warning (and doesn't have the desired impact on running my function)
image

@ghost ghost added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. labels Nov 17, 2021
@srivelicheti
Copy link

srivelicheti commented Nov 18, 2021

@JoshLove-msft - I am also facing similar issue with being able to mock ServiceBusMessageActions for unit-testing purposes as it doesn't contain public parameter-less constructor.

I see that all of the methods on this ServiceBusMessageActions are virtual but, trying to mock ServiceBusMessageActions class would result in an exception because of the lack of parameter-less ctor.
image

Most of the other SDK classes like ServiceBusClient or ServiceBusMessageReceiver have a parameter-less ctor or have factory classes (like ServiceBusModelFactory) to aid in unit-testing. Any chance of adding a parameter-less ctor to ServiceBusMessageActions? If not, can you please help with any alternate options to mock this class?

Appreciate your help, this is blocking us from migrating to .net6.0 and v4 azure functions.

@JoshLove-msft
Copy link
Member

Yes, it looks like we are missing the mocking constructor for the actions types - we will get this added in an upcoming release.

@srivelicheti
Copy link

Yes, it looks like we are missing the mocking constructor for the actions types - we will get this added in an upcoming release.

Thank you, would it be possible to give an ETA on the next release cycle?

@JoshLove-msft
Copy link
Member

Yes, it looks like we are missing the mocking constructor for the actions types - we will get this added in an upcoming release.

Thank you, would it be possible to give an ETA on the next release cycle?

Will have to get back to you on this. When do you need this by?

@jenp-jb
Copy link
Author

jenp-jb commented Nov 21, 2021

@JoshLove-msft any ideas on my config errors I was getting or should I create a different thread?

Keen on knowing the ETA for the next release cycle too as that's a blocker for us upgrading.

@JoshLove-msft
Copy link
Member

Hi @jenp-jb, I will try to repro this and get back to you.

@JoshLove-msft
Copy link
Member

A new release is available with the constructors required for mocking - https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.ServiceBus/5.2.0

Regarding the schema validation, I was able to reproduce this and will look into getting this fixed.

@AbhishekTripathi
Copy link

MessageReceiver provided APIs to manually renew the message lock token using RenewMessageLockAsync. These APIs are no longer available under ServiceBusMessageActions. In our scenario, we renew the locks using these APIs as we find the auto-renewal not reliable when the infrastructure is under stress. The documentation doesn't state anything about it. Can someone kindly provide me guidance on how we can manually renew the message lock?

@jsquire jsquire added issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. and removed needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Nov 17, 2022
@ghost
Copy link

ghost commented Nov 17, 2022

Hi @jenp-jb. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@ghost
Copy link

ghost commented Nov 24, 2022

Hi @jenp-jb, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

@ghost ghost closed this as completed Nov 24, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Functions issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Bus
Projects
None yet
Development

No branches or pull requests

5 participants