我正在构建几个函数来运行我的系统中的cron作业。除此之外,我还想要一些关于httptriggers的。为此,我做了以下工作:
public class AttemptHandler extends AzureSpringBootRequestHandler<User, Greeting> {
@FunctionName("hello")
public HttpResponseMessage execute(@HttpTrigger(name = "request", methods = { HttpMethod.GET,
HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<User>> request,
ExecutionContext context) {
context.getLogger().info("Greeting user name: " + request.getBody().get().getName());
return request.createResponseBuilder(HttpStatus.OK).body(handleRequest(request.getBody().get(), context))
.header("Content-Type", "application/json").build();
}
}
@Component(value = "hello")
public class AttemptFunction implements Function<User, String> {
@Override
public String apply(User user) {
System.out.println("OLAAA");
return "Welcome, " + user.getName();
}
}
public class TimerHandlers extends AzureSpringBootRequestHandler<Void, String> {
@FunctionName("entityOfTheDay")
public HttpResponseMessage entityOfTheDay(@HttpTrigger(name = "request", methods = { HttpMethod.GET,
HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Void> request,
ExecutionContext context) {
context.getLogger().info("Started test");
handleRequest(context);
context.getLogger().info("Ended test");
return null;
}
}
@Component(value = "entityOfTheDay")
public class DailyEntityFunction implements Supplier<String> {
@Override
public String get() {
System.out.println("I ENTERED");
return "Success";
}
}
当然,这些都是单独的文件。尽管这似乎是平等的逻辑,应该工作,第一个功能,一个我建立测试和作为第一次尝试,运行完美。另一方面,第二个函数没有。它调用处理程序中的方法,但随后不运行带有@component注解的actuall函数。我已经尝试和测试了很多东西,包括尝试与供应商,消费者和runnable。它似乎从来没有找到实际的函数,只是找到了“hello”一个。你知道怎么解决吗?
暂无答案!
目前还没有任何答案,快来回答吧!