Лазурь — вечная оркестровкаJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Лазурь — вечная оркестровка

Сообщение Anonymous »

Я пытаюсь создать вечный оркестратор, но у меня ничего не получается.
Вот фрагмент моего кода.
HTTP-триггер
@FunctionName("MQMessageOrchestrate")
public HttpResponseMessage mqMessageOrchestrate(
@HttpTrigger(name = "req", methods = { HttpMethod.GET,
HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage request,
@DurableClientInput(name = "durableContext") DurableClientContext durableContext,
final ExecutionContext context) {

context.getLogger().info("Java HTTP trigger processed a request.");

// Initialize durable task client
DurableTaskClient client = durableContext.getClient();

// Start orchestration
String instanceId = client.scheduleNewOrchestrationInstance("TestOrchestrator");

// Output instance id
context.getLogger().info("Created new Java orchestration with instance ID = " + instanceId);

// Return status of orchestration in response
return durableContext.createCheckStatusResponse(request, instanceId);
}

Оркестратор
@FunctionName("TestOrchestrator")
public void testOrchestrator(
@DurableOrchestrationTrigger(name = "ctx") TaskOrchestrationContext ctx, ExecutionContext context) {

System.out.println("Processing stuff...");

ctx.createTimer(Duration.ofSeconds(5)).await();

ctx.continueAsNew(null);

}

Ожидание
Я ожидал, что оркестратор повторит, я видел аналогичный код, который не создает та же ошибка, но я не могу понять, в чем дело.
[2024-12-05T01:54:00.002Z] Created new Java orchestration with instance ID = d14eec3b-aad1-4508-92df-32d883201a40
[2024-12-05T01:54:00.011Z] Function "MQMessageOrchestrate" (Id: c125b1d3-35d7-428f-a831-1afe7903eeae) invoked by Java Worker
[2024-12-05T01:54:00.036Z] Executing 'Functions.TestOrchestrator' (Reason='(null)', Id=a087455b-a3ff-4b41-904f-c468d693d7dd)
[2024-12-05T01:54:00.042Z] Executed 'Functions.MQMessageOrchestrate' (Succeeded, Id=c125b1d3-35d7-428f-a831-1afe7903eeae, Duration=833ms)
[2024-12-05T01:54:00.064Z] Processing stuff...
[2024-12-05T01:54:00.078Z] Function "TestOrchestrator" (Id: a087455b-a3ff-4b41-904f-c468d693d7dd) invoked by Java Worker
[2024-12-05T01:54:00.085Z] Executed 'Functions.TestOrchestrator' (Succeeded, Id=a087455b-a3ff-4b41-904f-c468d693d7dd, Duration=57ms)
[2024-12-05T01:54:06.686Z] Executing 'Functions.TestOrchestrator' (Reason='(null)', Id=b8aff574-c31f-4e7a-8269-571d303ec402)
[2024-12-05T01:54:06.693Z] Processing stuff...
[2024-12-05T01:54:00.078Z] Function "TestOrchestrator" (Id: a087455b-a3ff-4b41-904f-c468d693d7dd) invoked by Java Worker
[2024-12-05T01:54:00.085Z] Executed 'Functions.TestOrchestrator' (Succeeded, Id=a087455b-a3ff-4b41-904f-c468d693d7dd, Duration=57ms)
[2024-12-05T01:54:06.686Z] Executing 'Functions.TestOrchestrator' (Reason='(null)', Id=b8aff574-c31f-4e7a-8269-571d303ec402)
[2024-12-05T01:54:06.693Z] Processing stuff...

Реальность
Но именно это и произошло после первой оркестровки. В ошибке говорится, что оркестратор уже завершил работу.
[2024-12-05T01:54:06.693Z] Processing stuff...
[2024-12-05T01:54:06.714Z] Executed 'Functions.TestOrchestrator' (Failed, Id=b8aff574-c31f-4e7a-8269-571d303ec402, Duration=27ms)
[2024-12-05T01:54:06.715Z] System.Private.CoreLib: Exception while executing function: Functions.TestOrchestrator. System.Private.CoreLib: Result: Failure
Exception: IllegalStateException: The orchestrator has already completed
Stack: java.lang.IllegalStateException: The orchestrator has already completed


Подробнее здесь: https://stackoverflow.com/questions/792 ... hestration
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»