-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More samples #18
Comments
Indeed I'd like to see a sample of how the FetchAndLock and then Complete work. Thanks |
Indeed, It is not clear how to complete the task |
To complete a task, I added to ExternalTaskService.cs: public Task Complete(ExternalTaskInfo externalTask, CompleteExternalTask completeExternalTask) => _api.Complete(externalTask.Id, completeExternalTask); Sample code, which checks, fetches and complete tasks for a certain topic: private const string WorkerName = "MyWorker";
private const string TopicName = "MyTopic";
// build query
var externalTaskQuery = new ExternalTaskQuery() { Active = true, TopicName = TopicName };
// add some sorting
externalTaskQuery
.Sort(ExternalTaskSorting.TaskPriority, SortOrder.Descending)
.Sort(ExternalTaskSorting.LockExpirationTime);
// request external tasks according to query
List<ExternalTaskInfo> tasks = await camunda.ExternalTasks.Query(externalTaskQuery).List();
if (tasks.Any())
{
var fetchedTasks = await camunda.ExternalTasks.FetchAndLock(new FetchExternalTasks()
{
AsyncResponseTimeout = 60 * 1000,
MaxTasks = 1,
WorkerId = WorkerName,
Topics = new List<FetchExternalTaskTopic>() { new FetchExternalTaskTopic(TopicName, 1000) }
});
Console.WriteLine($"Fetched tasks: {fetchedTasks.Count}");
if (fetchedTasks != null && fetchedTasks.Count > 0)
{
foreach (var fetched in fetchedTasks)
{
// Consider the task completed
Console.WriteLine($"Completing task: {fetched.Id}");
CompleteExternalTask completeExternalTask = new CompleteExternalTask() { WorkerId = WorkerName };
await camunda.ExternalTasks.Complete(fetched, completeExternalTask);
}
}
} |
I don't see the Complete method for the ExternalTasks Library. I am using Camunda.Api.Clinet version 2.6.0. Also, where is extend lock? |
Both reside in the ExternalTaskResource you get with ´camundaClient.ExternalTasks[id]´ |
Hi,
It'd be very helpful if you could add more samples:
Thank you.
The text was updated successfully, but these errors were encountered: