Skip to content

Commit 2a964a0

Browse files
committed
improve README file with local example
1 parent 26a937b commit 2a964a0

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@ The usage with Flowable Cloud is simpler, since everything is pre-configured.
3737
However, it's required to either use the user credentials or to pre-configure a personal access token.
3838

3939
```csharp
40+
using System.Net.Http.Headers;
41+
using FlowableExternalWorkerClient.Client;
42+
using FlowableExternalWorkerClient.Rest;
43+
4044
var auth = new AuthenticationHeaderValue("Bearer", "<personal-access-token>");
4145

4246
var externalWorkerClient = new ExternalWorkerClient(authentication: auth);
4347
var subscription = externalWorkerClient.Subscribe("myTopic", new HandleJobs());
4448

45-
// ...
49+
// Keep the application running
50+
Console.WriteLine("Waiting for external worker jobs. Press Enter to exit...");
51+
Console.ReadLine();
4652

4753
class HandleJobs : IExternalWorkerCallbackHandler
4854
{
@@ -55,3 +61,33 @@ class HandleJobs : IExternalWorkerCallbackHandler
5561
}
5662
}
5763
```
64+
65+
### Local
66+
67+
The following is an example how you can connect to a Flowable instance running at `http://localhost:8090` and process all messages retrieved on the topic `myTopic`:
68+
69+
```csharp
70+
using System.Net.Http.Headers;
71+
using System.Text;
72+
using FlowableExternalWorkerClient.Client;
73+
using FlowableExternalWorkerClient.Rest;
74+
75+
var auth = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes("admin:test")));
76+
77+
var externalWorkerClient = new ExternalWorkerClient(flowableHost: "http://localhost:8090/flowable-work", authentication: auth);
78+
var subscription = externalWorkerClient.Subscribe("myTopic", new HandleJobs());
79+
80+
// Keep the application running
81+
Console.WriteLine("Waiting for external worker jobs. Press Enter to exit...");
82+
Console.ReadLine();
83+
84+
class HandleJobs : IExternalWorkerCallbackHandler
85+
{
86+
public IWorkResult Handle(ExternalWorkerAcquireJobResponse job, IWorkResultBuilder work)
87+
{
88+
Console.WriteLine("Handle job: " + job.Id);
89+
return work
90+
.Success();
91+
}
92+
}
93+
```

0 commit comments

Comments
 (0)