Azure / Azure/durabletask

Task activity received "[\"HelloWorld\"]" instead of string "HelloWorld" passed in task orchestration

Open
#573 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.7k
Forks
335
Avg merge
2d 23h
Merged PRs (30d)
6

Description

There are two issues here:

**The first one is** that I pass string "HelloWorld" to a task activity in task orchestration, however when I debug I find that the task activity received the string "[\"HelloWorld\"]".

**The second one is** that the task orchestration ran twice(which is weird for me) and when the twice, I got the exception.
"Object reference not set to an instance of an object." the call stack is

![image](https://user-images.githubusercontent.com/12733681/125599877-733c9969-d152-482b-a20d-759aa69d5b61.png)

My code is very simple: just following the encode video sample but more simple.

1.EncodeOrchestration
```
public class EncodeOrchestration : TaskOrchestration
{
public override async Task RunTask(OrchestrationContext context, string input)
{
Console.WriteLine("The input text is " + input);
string resultFromActivity = await context.ScheduleTask(typeof(EncodeActivity), input);

Console.WriteLine($"The result of {this.GetType().Name} is {resultFromActivity}.");
return resultFromActivity;
}
}
```

2. EncodeActivity
```
public class EncodeActivity : TaskActivity
{
public override string Run(TaskContext context, string activityInput)
{
Console.WriteLine($"{this.GetType().Name} received the input text is as bellow:");
Console.WriteLine(activityInput);

string result = "This is activity.";
return result;
}
}
```

3. I use azure storage create task hub client and create orchestration instance in one application project
```
static void Main(string[] args)
{
//omit some code to initialize task hub client, I use the durable.storage
string orchestrationInput = "HelloWorld3";
var instance = taskHubClient.CreateOrchestrationInstanceAsync(typeof(EncodeOrchestration), orchestrationInput).GetAwaiter().GetResult();

Console.ReadLine();
}
```

4. Then I create another console application project to start task hub worker
```
static void Main(string[] args)
{
//omit some code to initialize task hub worker with the same storage when initializing task hub client
Console.WriteLine("Worker start to run");
var hubworker = .taskHubWorker.AddTaskOrchestrations(typeof(EncodeOrchestration)).AddTaskActivities(typeof(EncodeActivity)).StartAsync().ConfigureAwait(true).GetAwaiter().GetResult();
Console.WriteLine(hubworker.orchestrationService);
Console.ReadLine();
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.