Spring cloud azure function without return type

Vipin Sharma 116 Reputation points

I am developing a Azure function (QueueTrigger) using spring cloud.
Example code suggested is given at below github locations.
Spring cloud function we want to run: https://github.com/Azure-Samples/hello-spring-function-azure/blob/master/src/main/java/com/example/Hello.java
Azure function that is going to trigger spring cloud function: https://github.com/Azure-Samples/hello-spring-function-azure/blob/master/src/main/java/com/example/HelloHandler.java
2 questions I have here:

  1. In my case this is QueueTrigger Function so I do not have return type, in this case what should be type defined for FunctionInvoker. Below is sample given in github example.
    public class HelloHandler extends FunctionInvoker<User, Greeting>
  2. Spring cloud function in example looks like below
      public class Hello implements Function<Mono<User>, Mono<Greeting>> {  
         public Mono<Greeting> apply(Mono<User> mono) {  
           return mono.map(user -> new Greeting("Hello, " + user.getName() + "!\n"));  

But I have written code like this, because I dont have any output return type. is it standard practice suggested or any other better way available?

public class Hello implements Consumer<Integer> {  

    public void accept(Integer requestId) {  
        //some logic  
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,637 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.
116 questions
{count} votes

Accepted answer
  1. Kaibo Cai 76 Reputation points Microsoft Employee

    Hi @vipin sharma , we are working on creating examples for all types of triggers and bindings using spring cloud function. I will let you know once they are created.

    For now I think you can use below type for your case

    public class QueueTriggerHandler extends FunctionInvoker<Integer, Void>

    We are also release a new feature to enable more seamless integration with spring cloud on azure functions, you can found some example at https://github.com/spring-cloud/spring-cloud-function/tree/main/spring-cloud-function-samples/function-azure-di-samples, it should be fully released next one week or two. I will let you know. With this new feature you won't have the issue as you currently have witht the FunctionInvoker


0 additional answers

Sort by: Most helpful