Azure / azure-functions-java-library

Contains annotations for writing Azure Functions in Java
MIT License
42 stars 42 forks source link

ServiceBusQueueTrigger MessageReceiver Binding throws error #137

Closed musa-pro closed 1 year ago

musa-pro commented 3 years ago

I was trying to get metadata MessageReceiver for a ServiceBusQueueTrigger function using binding annotation, but this throws error. I noticed MessageSession, DeadletterSource throws error too whereas other binding works well. I was following this document https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-trigger?tabs=java

Is this expected or what I'm doing wrong? Here is what I've

    @FunctionName("MessageConsumer")
    public void run(
            @ServiceBusQueueTrigger(name = "msg",
                    queueName = "ServiceBusQueue",
                    connection = "ServiceBusConStr")
                    String message,
            @BindingName("MessageReceiver") MessageReceiver messageReceiver,
            @BindingName("UserProperties") Map<String, Object> properties,
            final ExecutionContext context
    ){
        context.getLogger().info("got message from: "+message);
    }
avs099 commented 1 year ago

this worked for me:

@BindingName("ApplicationProperties") Map<String, Object> properties,

I took binding name from this list: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-trigger?tabs=in-process%2Cextensionv5&pivots=programming-language-csharp#message-metadata

kaibocai commented 1 year ago

Hi @musa-pro , please use link paste by @avs099 for correct binding name. Thank you @avs099 for the help here 💯 . Please reopen this issue if you still has the problem. Thanks.

PengChaoSun commented 1 year ago

Hi @avs099, thanks for your sharing, I have the same issue, and tried your suggestion, but not work for me. and the shared link is for C# not Java. attached the code and error logs. image

image

kaibocai commented 1 year ago

@PengChaoSun , I cannot reproduce your issue with the same code, can you double check if your function is defined correctly?

image