@ServiceBusQueueTrigger (SpringBoot/Java) executes function when message sent to queue, but function sees message as null.

Damon Stamper 1 Reputation point
2020-10-07T19:57:10.39+00:00

I'm using Java/SpringBoot and am able to send String data (it happens to be a String of JSON) to a ServiceBusQueue. The sending SpringBoot application can read it back just fine, and I can even "peek" at the message through portal.azure.com and see it's contents so I know the String data is there.

I have an Azure Function set to use the ServiceBusQueueTrigger. It triggers when a message is sent to the queue but isn't able to read the data in the message that triggered it. When it runs I get null if I try to log the resulting object, or null pointers if I try to do any methods on the resulting object.

My end goal is to have the SpringBoot application send a message to a queue and have an Azure Function act on that message.

I'm using code that is very similar to https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-trigger?tabs=java.

package com.example.controller;

import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.annotation.FunctionName;
import com.microsoft.azure.functions.annotation.ServiceBusQueueTrigger;

import org.springframework.cloud.function.adapter.azure.AzureSpringBootRequestHandler;

public class HelloHandler {

@FunctionName("sbprocessor")
public void serviceBusProcess( // ServiceBusTrigger supports only JSON and XmlObjectSerializer deseralizations. https://github.com/Azure/azure-webjobs-sdk/issues/2154#issuecomment-495473951
@ServiceBusQueueTrigger(name = "msg",
queueName = "rma-create",
connection = "TheServiceBusEndpoint") String message,
final ExecutionContext context
) {
context.getLogger().info("message:" + message);
}
}

What am I doing wrong or not doing at all?

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
635 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,089 questions
Azure Spring Apps
Azure Spring Apps
An Azure platform as a service for running Spring Boot applications at cloud scale. Previously known as Azure Spring Cloud.
126 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.