azure-functions-java-worker icon indicating copy to clipboard operation
azure-functions-java-worker copied to clipboard

ServiceBusQueueTrigger MessageReceiver Binding throws error

Open musa-pro opened this issue 4 years ago • 6 comments

Actual behavior

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?

Source
    @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);
    }

musa-pro avatar Nov 04 '20 14:11 musa-pro

@musa-pro thank you or reporting the issue, please can you share the error you are facing. Also are you referencing the MessageReciever from https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.servicebus.core.messagereceiver?view=azure-dotnet

amamounelsayed avatar Nov 13 '20 20:11 amamounelsayed

any updates on this? MessageReceiver type does not seem available in java world.. The only implementatiopn to be found is in https://mvnrepository.com/artifact/com.microsoft.azure/azure-servicebus/3.6.5, but the com.microsoft.azure.servicebus.MessageReceiver class is non-public and cannot be referenced as such:

    @FunctionName("some-func")
    public void reabFromSbTopic(
            @ServiceBusTopicTrigger(
                    name = "message",
                    topicName = "%topic%",
                    subscriptionName = "%sub%",
                    connection = "sbconn"
            ) String message,
            @BindingName("MessageReceiver") MessageReceiver messageReceiver,
            final ExecutionContext context
    ) {
        //....
        
    }

auju01 avatar Sep 30 '21 05:09 auju01

Hello, Just checking in to see if there's any movement on this.

ashwinp88 avatar Nov 30 '21 21:11 ashwinp88

Is there any movement? It's an incomplete feature. I cannot inject a MessageReceiver into my ServiceBusQueueTrigger. I get the following error message:

Caused by: java.lang.UnsupportedOperationException: Interface can't be instantiated! Interface name: com.microsoft.azure.servicebus.IMessageReceiver

Is there a workaround this?

ielkhalloufi avatar Jun 29 '22 13:06 ielkhalloufi

is there any update on this ? I am facing the same issue with Java when i try to use IMessageReceiver as shown below:

public class TestFunction {

    @FunctionName("Test-Function")
    public void run(
            @ServiceBusQueueTrigger(name = "Message", queueName = "Test_queue",
                    connection = "ServiceBusConnection")  String Message , @BindingName("IMessageReceiver") IMessageReceiver messageReceiver,
            final ExecutionContext context
    ) {
        
    }
}

Error is :

_System.Private.CoreLib: Exception while executing function: Functions.Test-Function. System.Private.CoreLib: Result: Failure
Exception: NullPointerException: 
Stack: java.lang.NullPointerException
at com.microsoft.azure.functions.worker.binding.BindingDataStore.getTriggerMetatDataByName(BindingDataStore.java:66)

Is there any document with clear examples on how to use IMessageReceiver with Java in Azure Functions ?

ghost avatar Aug 19 '22 11:08 ghost

I have similar issue(at least the same exception)

@FunctionName("eventhubTriggerDevice")
    public void execute(
            @EventHubTrigger(
                    name = "eventhubTriggerDevice",
                    eventHubName = "iot-to-eventhub-devices",
                    connection = "AzureEventHubConnectionString",
                    consumerGroup = "group-iot",
                    cardinality = Cardinality.ONE)
            String msg,
            @BindingName("systemPropertiesArray") SystemProperty[] systemProperties,
            final ExecutionContext context) {
        LOGGER.info("Java Event Hub trigger function executed. Device:[{}]", msg);
        handleRequest(user, context);
    }

I want to be able to identify the device that updated. I have a sample that works from azure SDK but not for azure function

image

survivant avatar Sep 20 '22 16:09 survivant