Skip to content

Commit a04039f

Browse files
Ticket #63 : Add documentation : "EventMesh installation" + "EventMesh portal" + "EventMesh listen topics" + "EventMesh Publish messages"
1 parent 33acd97 commit a04039f

File tree

60 files changed

+1746
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1746
-241
lines changed

docs/docfx.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
{
2929
"files": [
3030
"documentation/**.png",
31-
"charts/**"
31+
"charts/**",
32+
"logo.svg"
3233
]
3334
}
3435
],
27.8 KB
Loading

docs/documentation/eventmesh/installation.md

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,42 +37,4 @@ cd src/EventMeshServer
3737
dotnet run
3838
```
3939

40-
![Architecture](images/installation-1.png)
41-
42-
## Listen topics
43-
44-
A client can subscribe to one or more topics and receive messages from them.
45-
46-
Topic subscription can be implemented by any type of DOTNET CORE applications.
47-
48-
First the Nuget package `EventMesh.Runtime` must be installed.
49-
50-
```
51-
dotnet add package EventMesh.Runtime`
52-
```
53-
54-
A session must be established with the server.
55-
56-
57-
```
58-
private static async Task<string> CreateSession(string clientId)
59-
{
60-
var helloResponse = await _runtimeClient.Hello(new UserAgent
61-
{
62-
ClientId = clientId,
63-
Environment = "TST",
64-
Password = "password",
65-
Pid = 2000,
66-
BufferCloudEvents = 1,
67-
Version = "0",
68-
Purpose = UserAgentPurpose.SUB
69-
});
70-
return helloResponse.SessionId;
71-
}
72-
```
73-
74-
TODO
75-
76-
## Publish messages
77-
78-
TODO
40+
![Architecture](images/installation-1.png)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Listen topics
2+
3+
> [!NOTE]
4+
> The source code of this project can be found [here](https://github.com/simpleidserver/FaasNet/tree/master/samples/EventMeshClientSubscribe).
5+
6+
A client can subscribe to one or more topics and receive messages from them.
7+
8+
Topic subscription can be implemented by any types of DOTNET CORE application.
9+
10+
## Configuration steps
11+
12+
First, the Nuget package `EventMesh.Runtime` must be installed.
13+
14+
```
15+
dotnet add package EventMesh.Runtime
16+
```
17+
18+
A session must be established between the client and the server in order to subscribe to one or more topics.
19+
20+
```
21+
private static async Task<string> CreateSession(RuntimeClient runtimeClient)
22+
{
23+
var helloResponse = await runtimeClient.Hello(new UserAgent
24+
{
25+
ClientId = "clientId",
26+
Environment = "TST",
27+
Password = "password",
28+
Pid = 2000,
29+
BufferCloudEvents = 1,
30+
Version = "0",
31+
Purpose = UserAgentPurpose.SUB
32+
});
33+
return helloResponse.SessionId;
34+
}
35+
```
36+
37+
> [!WARNING]
38+
> In-memory implementation of the MessageBroker doesn't support wildcard in topic name.
39+
40+
Subscribe to one topic `Person.Created` and display the messages received.
41+
42+
```
43+
private static async Task<SubscriptionResult> SubscribeTopic(RuntimeClient runtimeClient, string sessionId)
44+
{
45+
return await runtimeClient.Subscribe("clientId", sessionId, new List<SubscriptionItem>
46+
{
47+
new SubscriptionItem
48+
{
49+
Topic = "Person.Created",
50+
}
51+
}, (msg) =>
52+
{
53+
var cloudEvts = string.Join(",", msg.CloudEvents.Select(c => c.Data));
54+
Console.WriteLine($"Receive '{msg.CloudEvents.Count()}' messages: {cloudEvts}, BrokerName : {msg.BrokerName}, urn : {string.Join(',', msg.BridgeServers.Select(b => b.Urn))}");
55+
});
56+
}
57+
```
58+
59+
When both methods are added. The `RuntimeClient` instance can be configured to receive messages.
60+
61+
```
62+
var runtimeClient = new RuntimeClient("localhost", 4000);
63+
var sessionId = CreateSession(runtimeClient).Result;
64+
var subscriptionResult = SubscribeTopic(runtimeClient, sessionId).Result;
65+
Console.WriteLine("Please press enter to quit the application ...");
66+
Console.ReadLine();
67+
subscriptionResult.Stop();
68+
runtimeClient.Disconnect("clientId", sessionId).Wait();
69+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Portal
2+
3+
A portal can be installed to administrate an EventMesh Server.
4+
5+
```
6+
mkdir QuickStart
7+
cd QuickStart
8+
9+
mkdir src
10+
cd src
11+
12+
dotnet new evtmeshinmemui -n EventMeshServer
13+
```
14+
15+
The following files will be created :
16+
17+
* *Program.cs* and *Startup.cs* : application entry point.
18+
* *Pages* : Razor pages.
19+
20+
In case the Visual Studio Support is needed, a solution can be created :
21+
22+
```
23+
cd ..
24+
dotnet new sln -n QuickStart
25+
```
26+
27+
Add the EventMesh server into the solution :
28+
29+
```
30+
dotnet sln add ./src/EventMeshServer/EventMeshServer.csproj
31+
```
32+
33+
Run the EventMesh server and browse the URL : [http://localhost:5001](http://localhost:5001).
34+
35+
```
36+
cd src/EventMeshServer
37+
dotnet run --urls=http://localhost:5001
38+
```
39+
40+
The following UI is displayed. It contains four options :
41+
42+
* *Status* : Display the status of the EventMesh server.
43+
* *Clients* : Display all the clients.
44+
* *Brokers* : Display all the configured message brokers.
45+
* *Bridges* : Display all the bridges.
46+
47+
![Portal](images/portal-1.png)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Publish messages
2+
3+
> [!NOTE]
4+
> The source code of this project can be found [here](https://github.com/simpleidserver/FaasNet/tree/master/samples/EventMeshClientPublish).
5+
6+
A client can publish messages to a topic.
7+
8+
## Configuration steps
9+
10+
First, the Nuget package `EventMesh.Runtime` must be installed.
11+
12+
```
13+
dotnet add package EventMesh.Runtime`
14+
```
15+
16+
A session must be established between the client and the server in order to publish messages.
17+
18+
```
19+
private static async Task<string> CreateSession(RuntimeClient runtimeClient)
20+
{
21+
var helloResponse = await runtimeClient.Hello(new UserAgent
22+
{
23+
ClientId = "pubClientId",
24+
Environment = "TST",
25+
Password = "password",
26+
Pid = 2000,
27+
BufferCloudEvents = 1,
28+
Version = "0",
29+
Purpose = UserAgentPurpose.PUB
30+
});
31+
return helloResponse.SessionId;
32+
}
33+
```
34+
35+
Publish a message to the topic `Person.Created`.
36+
37+
```
38+
private static Task<Package> PublishMessage(RuntimeClient runtimeClient, string sessionId)
39+
{
40+
var cloudEvent = new CloudEvent
41+
{
42+
Type = "com.github.pull.create",
43+
Source = new Uri("https://github.com/cloudevents/spec/pull"),
44+
Subject = "123",
45+
Id = "A234-1234-1234",
46+
Time = new DateTimeOffset(2018, 4, 5, 17, 31, 0, TimeSpan.Zero),
47+
DataContentType = "application/json",
48+
Data = "person is created",
49+
["comexampleextension1"] = "value"
50+
};
51+
return runtimeClient.PublishMessage("pubClientId", sessionId, "Person.Created", cloudEvent);
52+
}
53+
```
54+
55+
When both methods are added. The `RuntimeClient` instance can be configured to publish messages.
56+
57+
```
58+
var runtimeClient = new RuntimeClient("localhost", 4000);
59+
var sessionId = CreateSession(runtimeClient).Result;
60+
PublishMessage(runtimeClient, sessionId).Wait();
61+
Console.WriteLine("Please press enter to quit the application ...");
62+
Console.ReadLine();
63+
runtimeClient.Disconnect("pubClientId", sessionId).Wait();
64+
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# RabbitMQ
2+
3+
An EventMesh server can be configured to consume and publish messages from / to RabbitMQ.
4+
5+
> [!WARNING]
6+
> Before you start, Make sure there is a Visual Studio Solution with a [configured EventMesh server](/documentation/eventmesh/installation.html).
7+
8+
## Source Code
9+
10+
The source code of this project can be found [here](https://github.com/simpleidserver/FaasNet/tree/master/samples/EventMeshServerRabbitMQ).
11+
12+
## Configure EventMesh server
13+
14+
The Nuget package `EventMesh.Runtime.AMQP` must be installed.
15+
16+
```
17+
dotnet add package EventMesh.Runtime.AMQP
18+
```
19+
20+
Edit the file which contains the configuration of the EventMesh server and add the line `AddAMQP()` after `RuntimeHostBuilder` or `AddRuntime`.
21+
22+
Standalone EventMesh server :
23+
24+
```
25+
new RuntimeHostBuilder(opt =>
26+
{
27+
opt.Port = "localhost";
28+
opt.Urn = 4000;
29+
}).AddAMQP();
30+
```
31+
32+
33+
EventMesh server with UI :
34+
35+
```
36+
services.AddRuntimeWebsite(opt =>
37+
{
38+
opt.Urn = "localhost";
39+
opt.Port = 4000;
40+
}).AddAMQP();
41+
```
42+
43+
The `AddAMQP` accepts one optional parameter in entry. It can be used to update update the options.
44+

docs/documentation/toc.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
href: eventmesh/concepts.md
2525
- name: Installation
2626
href: eventmesh/installation.md
27+
- name: Message brokers
28+
items:
29+
- name: RabbitMQ
30+
href: eventmesh/rabbitmq.md
31+
- name: Portal
32+
href: eventmesh/portal.md
33+
- name: Listen topics
34+
href: eventmesh/listentopics.md
35+
- name: Publish messages
36+
href: eventmesh/publishmessages.md
2737
- name: Protocol
2838
href: eventmesh/protocol.md
2939
- name: CLI

0 commit comments

Comments
 (0)