You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-src/queuing.md
+81-13Lines changed: 81 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,22 @@
2
2
3
3
InEngine.NET's queue functionality allows for commands to be run in the background with a simple publish/consume model.
4
4
5
-
## Prerequisites
5
+
## Queue Drivers
6
6
7
-
Redis is required to use the InEngine.NET queue feature.
8
-
It can be installed on Ubuntu with this command:
7
+
To make use of queue features, a queue driver must be specified in [appsettings.json](configuration).
8
+
These are the available drivers...
9
+
10
+
### File
11
+
12
+
The file driver writes queued messages to the file system.
13
+
It is useful for testing and development, but probably not suitable for production.
14
+
15
+
### Redis
16
+
17
+
Redis is suitable for production use.
18
+
InEngine.NET utilizes Redis' durable queue features which mean messages will not be lost if InEngine.NET unexpectedly fails.
19
+
20
+
Redis can be installed on Ubuntu with this command:
9
21
10
22
```bash
11
23
sudo apt-get install redis-server
@@ -19,22 +31,78 @@ sudo service redis start
19
31
20
32
<divclass="alert alert-info">
21
33
It is highly recommended to <ahref="https://redis.io/topics/security#authentication-feature">set a password</a> for Redis.
22
-
</div>
34
+
</div>
35
+
36
+
### Sync
37
+
38
+
The sync driver causes the publish command to run a published command synchronously.
39
+
All other queue commands and methods are not supported and will throw an exception if called.
40
+
This driver can be useful for plugin development and testing.
23
41
24
42
## Publishing Commands
25
43
26
-
### From Code
44
+
### With C# Classes
45
+
46
+
[Commands](commands) can be published programmatically with the **InEngine.Core.Queuing.Queue** class:
47
+
48
+
```c#
49
+
Queue.Make().Publish(newMyCommand());
50
+
```
51
+
52
+
Or publish to the secondary queue by passing true to the Make method:
53
+
54
+
```c#
55
+
Queue.Make(true).Publish(newMyCommand());
56
+
```
57
+
58
+
!!! note "Do I have to use Queue.Make()?"
59
+
Queue.Make() is a factory method that autoloads the queue settings from appsettings.json, creates the appropriate queue driver, and returns an instance of Queue.
60
+
You can create your own Queue object an initialize it if you want.
61
+
At the very least you can assign the object returned by Queue.Make() to a local variable or load it into a DI container for later use.
62
+
63
+
### With Lambda Expressions
64
+
65
+
Lambda expressions, aka anonymous functions, can be queued.
66
+
The disadvantage to queuing lambdas is that the helpful functionality available in **InEngine.Core.AbstractCommand** is not available.
0 commit comments