@@ -35,43 +35,50 @@ Create an exception policy, which you will attach to the regular queue, which is
35
35
36
36
``` csharp
37
37
// create the exception policy
38
- await client .SetExceptionPolicyAsync (
39
- id : " Escalate_XBOX_Policy" ,
40
- name : " Add escalated label and reclassify XBOX Job requests after 5 minutes" ,
41
- rules : new List <ExceptionRule >()
42
- {
43
- new (
44
- id : " Escalated_Rule" ,
45
- trigger : new WaitTimeExceptionTrigger (TimeSpan .FromMinutes (5 )),
46
- actions : new List <ExceptionAction >
38
+ await routerClient .CreateExceptionPolicyAsync (
39
+ new CreateExceptionPolicyOptions (
40
+ exceptionPolicyId : " Escalate_XBOX_Policy" ,
41
+ exceptionRules : new List <ExceptionRule >()
47
42
{
48
- new ReclassifyExceptionAction ( " EscalateReclassifyExceptionAction " )
49
- {
50
- LabelsToUpsert = new LabelCollection (
51
- new Dictionary < string , object >
43
+ new (
44
+ id : " Escalated_Rule " ,
45
+ trigger : new WaitTimeExceptionTrigger ( TimeSpan . FromMinutes ( 5 )),
46
+ actions : new List < ExceptionAction >()
52
47
{
53
- [" Escalated" ] = true ,
54
- })
55
- }
56
- }
57
- )
58
- });
48
+ new ReclassifyExceptionAction (" EscalateReclassifyExceptionAction" )
49
+ {
50
+ LabelsToUpsert = new LabelCollection (
51
+ new Dictionary <string , object >
52
+ {
53
+ [" Escalated" ] = true ,
54
+ })
55
+ }
56
+ }
57
+ )
58
+ {
59
+ Name = " My exception policy"
60
+ }
61
+ );
59
62
```
60
63
61
64
## Classification policy configuration
62
65
63
66
Create a Classification Policy to handle the new label added to the Job . This policy will evaluate the `Escalated ` label and assign the Job to either Queue . The policy will also use the [RulesEngine ](.. / .. / concepts / router / router - rule - concepts .md ) to increase the priority of the Job from `1 ` to `10 `.
64
67
65
68
```csharp
66
- await client .SetClassificationPolicyAsync (
67
- id : " Classify_XBOX_Voice_Jobs" ,
68
- name : " Classify XBOX Voice Jobs" ,
69
- queueSelector : new QueueIdSelector (
70
- new ExpressionRule (
71
- " If(job.Escalated = true, \" XBOX_Queue\" , \" XBOX_Escalation_Queue\" )" )),
72
- workerSelectors : null ,
73
- prioritizationRule : new ExpressionRule (" If(job.Escalated = true, 10, 1)" ),
74
- fallbackQueueId : " Default" );
69
+ await routerAdministrationClient .CreateClassificationPolicyAsync (
70
+ options : new CreateClassificationPolicyOptions (" Classify_XBOX_Voice_Jobs" )
71
+ {
72
+ Name = " Classify XBOX Voice Jobs" ,
73
+ PrioritizationRule = new ExpressionRule (" If(job.Escalated = true, 10, 1)" ),
74
+ QueueSelectors = new List <QueueSelectorAttachment >()
75
+ {
76
+ new QueueIdSelector (
77
+ new ExpressionRule (
78
+ " If(job.Escalated = true, \" XBOX_Queue\" , \" XBOX_Escalation_Queue\" )" ))
79
+ },
80
+ FallbackQueueId = " Default"
81
+ });
75
82
```
76
83
77
84
## Queue configuration
@@ -83,36 +90,42 @@ Create the necessary Queues for regular and escalated Jobs and assign the Except
83
90
84
91
```csharp
85
92
// create a queue for regular Jobs and attach the exception policy
86
- await client . SetQueueAsync (
87
- id : " XBOX_Queue" ,
88
- name : " XBOX Queue " ,
89
- distributionPolicyId : " Round_Robin_Policy " ,
90
- exceptionPolicyId : " XBOX_Escalate_Policy"
91
- );
93
+ await routerAdministrationClient . CreateQueueAsync (
94
+ options : new CreateQueueOptions ( " XBOX_Queue" , " Round_Robin_Policy " )
95
+ {
96
+ Name = " XBOX Queue " ,
97
+ ExceptionPolicyId = " XBOX_Escalate_Policy"
98
+ } );
92
99
93
100
// create a queue for escalated Jobs
94
- await client . SetQueueAsync (
95
- id : " XBOX_Escalation_Queue" ,
96
- name : " XBOX Escalation Queue " ,
97
- distributionPolicyId : " Round_Robin_Policy "
98
- );
101
+ await routerAdministrationClient . CreateQueueAsync (
102
+ options : new CreateQueueOptions ( " XBOX_Escalation_Queue" , " Round_Robin_Policy " )
103
+ {
104
+ Name = " XBOX Escalation Queue " ,
105
+ } );
99
106
```
100
107
101
108
## Job lifecycle
102
109
103
110
When you submit the Job , specify the Classification Policy ID as follows . For this particular example , the requirement would be to find a worker with a label called `XBOX_Hardware `, which has a value greater than or equal to the number `7 `.
104
111
105
112
```csharp
106
- await client .CreateJobWithClassificationPolicyAsync (
107
- channelId : ManagedChannels .AcsVoiceChannel ,
108
- classificationPolicyId : " Classify_XBOX_Voice_Jobs" ,
109
- workerSelectors : new List <LabelSelector >
113
+ await routerClient .CreateJobAsync (
114
+ options : new CreateJobWithClassificationPolicyOptions (
115
+ jobId : " 75c5612e-afb4-4e65-a0bf-3d1b950fad7b" ,
116
+ channelId : ManagedChannels .AcsVoiceChannel ,
117
+ classificationPolicyId : " Classify_XBOX_Voice_Jobs" )
110
118
{
111
- new (
112
- key : " XBOX_Hardware" ,
113
- @operator : LabelOperator .GreaterThanEqual ,
114
- value : 7 )
115
- }
119
+ WorkerSelectors = new List <WorkerSelectorAttachment >
120
+ {
121
+ new WorkerSelector ()
122
+ {
123
+ Key = " XBOX_Hardware" ,
124
+ Operator = LabelOperator .GreaterThanEqual ,
125
+ Value = 7
126
+ }
127
+ }
128
+ });
116
129
);
117
130
```
118
131
0 commit comments