예외 정책
예외 정책은 조건이 트리거될 때 실행할 작업을 정의하는 규칙 집합입니다. 작업 라우터 내부에 이러한 정책을 저장한 다음, 하나 이상의 큐에 연결할 수 있습니다.
트리거
다음 트리거를 사용하여 작업을 유도할 수 있습니다.
큐 길이 - 큐에 작업을 추가하는 동안 큐 길이가 지정된 임계값을 초과하면 실행됩니다.
대기 시간 - 작업이 지정된 임계값 동안 큐에서 대기 중일 때 발생합니다.
이러한 트리거가 실행되면 하나 이상의 작업을 실행하고 Event Grid를 통해 예외 트리거 이벤트를 보냅니다.
actions
취소 - 작업을 취소하고 큐에서 제거합니다.
재분류 - 레이블이 수정된 지정된 분류 정책을 작업에 다시 적용합니다.
수동 재분류 - 작업에 대한 큐, 우선 순위 및 작업자 선택기를 수정합니다.
예제
다음 예에서는 길이가 100보다 큰 큐에 합류하기 전에 작업을 취소하는 예외 정책을 구성합니다.
await administrationClient.CreateExceptionPolicyAsync(new CreateExceptionPolicyOptions(
exceptionPolicyId: "maxQueueLength",
exceptionRules: new List<ExceptionRule>
{
new (id: "cancelJob",
trigger: new QueueLengthExceptionTrigger(threshold: 100),
actions: new List<ExceptionAction>{ new CancelExceptionAction() })
}) { Name = "Max Queue Length Policy" });
await administrationClient.path("/routing/exceptionPolicies/{exceptionPolicyId}", "maxQueueLength").patch({
body: {
name: "Max Queue Length Policy",
exceptionRules: [
{
id: "cancelJob",
trigger: { kind: "queueLength", threshold: 100 },
actions: [{ kind: "cancel" }]
}
]
}
});
administration_client.upsert_exception_policy(
exception_policy_id = "maxQueueLength",
name = "Max Queue Length Policy",
exception_rules = [
ExceptionRule(
id = "cancelJob",
trigger = QueueLengthExceptionTrigger(threshold = 100),
actions = [ CancelExceptionAction() ]
)
]
)
administrationClient.createExceptionPolicy(new CreateExceptionPolicyOptions("maxQueueLength",
List.of(new ExceptionRule(
"cancelJob",
new QueueLengthExceptionTrigger(100),
List.of(new CancelExceptionAction())))
).setName("Max Queue Length Policy"));
다음 예에서는 다음과 같은 규칙을 사용하여 예외 정책을 구성합니다.
- 큐에서 1분 동안 대기한 후 작업 우선 순위를 10으로 설정합니다.
- 5분 동안 대기한 후 작업을
queue2
로 이동합니다.
await administrationClient.CreateExceptionPolicyAsync(new CreateExceptionPolicyOptions(
exceptionPolicyId: "policy2",
exceptionRules: new List<ExceptionRule>
{
new(
id: "increasePriority",
trigger: new WaitTimeExceptionTrigger(threshold: TimeSpan.FromMinutes(1)),
actions: new List<ExceptionAction>
{
new ManualReclassifyExceptionAction { Priority = 10 }
}),
new(
id: "changeQueue",
trigger: new WaitTimeExceptionTrigger(threshold: TimeSpan.FromMinutes(5)),
actions: new List<ExceptionAction>
{
new ManualReclassifyExceptionAction { QueueId = "queue2" }
})
}) { Name = "Escalation Policy" });
await administrationClient.path("/routing/exceptionPolicies/{exceptionPolicyId}", "policy2").patch({
body: {
name: "Escalation Policy",
exceptionRules: [
{
id: "increasePriority",
trigger: { kind: "waitTime", thresholdSeconds: "60" },
actions: [{ "manual-reclassify", priority: 10 }]
},
{
id: "changeQueue",
trigger: { kind: "waitTime", thresholdSeconds: "300" },
actions: [{ kind: "manual-reclassify", queueId: "queue2" }]
}]
},
contentType: "application/merge-patch+json"
});
administration_client.upsert_exception_policy(
exception_policy_id = "policy2",
name = "Escalation Policy",
exception_rules = [
ExceptionRule(
id = "increasePriority",
trigger = WaitTimeExceptionTrigger(threshold_seconds = 60),
actions = [ ManualReclassifyExceptionAction(priority = 10) ]
),
ExceptionRule(
id = "changeQueue",
trigger = WaitTimeExceptionTrigger(threshold_seconds = 60),
actions = [ ManualReclassifyExceptionAction(queue_id = "queue2") ]
)
]
)
administrationClient.createExceptionPolicy(new CreateExceptionPolicyOptions("policy2", List.of(
new ExceptionRule("increasePriority", new WaitTimeExceptionTrigger(Duration.ofMinutes(1)),
List.of(new ManualReclassifyExceptionAction().setPriority(10))),
new ExceptionRule("changeQueue", new WaitTimeExceptionTrigger(Duration.ofMinutes(5)),
List.of(new ManualReclassifyExceptionAction().setQueueId("queue2"))))
).setName("Escalation Policy"));