forked from MassTransit/MassTransit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from MassTransit/develop
Update from original
- Loading branch information
Showing
152 changed files
with
1,945 additions
and
708 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: MassTransit | ||
env: | ||
MASSTRANSIT_VERSION: 8.2.2 | ||
MASSTRANSIT_VERSION: 8.2.3 | ||
on: | ||
push: | ||
paths: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
--- | ||
navigation.title: PostgreSQL | ||
--- | ||
|
||
# PostgreSQL Quick Start | ||
|
||
> This tutorial will get you from zero to up and running with [SQL](/documentation/transports/sql) and MassTransit. | ||
> Walkthrough Video TBD | ||
- The source for this sample is available [on GitHub](https://github.com/MassTransit/Sample-GettingStarted). | ||
|
||
## Prerequisites | ||
|
||
::alert{type="info"} | ||
The following instructions assume you are starting from a completed [In-Memory Quick Start](/quick-starts/in-memory) | ||
:: | ||
|
||
This example requires the following: | ||
|
||
- a functioning installation of the dotnet runtime and sdk (at least 6.0) | ||
- a functioning installation of _Docker_ with _Docker Compose_ support enabled. | ||
|
||
## Run PostgreSQL | ||
|
||
For this quick start, we recommend running the preconfigured [official Docker image of Postgres](https://hub.docker.com/_/postgres). | ||
|
||
```bash | ||
$ docker run -p 5432:5432 postgres | ||
``` | ||
|
||
If you are running on an ARM platform | ||
|
||
```bash | ||
$ docker run --platform linux/arm64 -p 5432:5432 postgres | ||
``` | ||
|
||
Once its up and running you can use your preferred tool to browse into the database. | ||
|
||
## Configure PostgreSQL | ||
|
||
Add the _MassTransit.SqlTransport.PostgreSQL_ package to the project. | ||
|
||
```bash | ||
$ dotnet add package MassTransit.SqlTransport.PostgreSQL | ||
``` | ||
|
||
### Edit Program.cs | ||
|
||
Change _UsingInMemory_ to _UsingPostgres_ as shown below. | ||
|
||
```csharp | ||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureServices((hostContext, services) => | ||
{ | ||
services.AddOptions<SqlTransportOptions>().Configure(options => | ||
{ | ||
options.Host = "localhost"; | ||
options.Database = "sample"; | ||
options.Schema = "transport"; | ||
options.Role = "transport"; | ||
options.Username = "masstransit"; | ||
options.Password = "H4rd2Gu3ss!"; | ||
|
||
// credentials to run migrations | ||
options.AdminUsername = "migration-user"; | ||
options.AdminPassword = "H4rderTooGu3ss!!; | ||
}); | ||
// MassTransit will run the migrations on start up | ||
services.AddPostgresMigrationHostedService(); | ||
services.AddMassTransit(x => | ||
{ | ||
// elided... | ||
x.UsingPostgres((context,cfg) => | ||
{ | ||
cfg.ConfigureEndpoints(context); | ||
}); | ||
}); | ||
|
||
services.AddHostedService<Worker>(); | ||
}); | ||
``` | ||
|
||
| Setting | Description | | ||
|-----------------|-------------------------------------------------------------------------------------------| | ||
| `Host` | The host to connect to. We are using `localhost` to connect to the docker container | | ||
| `Port` | We are using the default `5432`, so we aren't setting it. | | ||
| `Database` | The name of the database to connect to | | ||
| `Schema` | The schema to place the tables and functions inside of | | ||
| `Role` | the role to assign for all created tables, functions, etc. | | ||
| `Username` | The username of the user to login as for normal operations | | ||
| `Password` | The password of the user to login as for normal operations | | ||
| `AdminUsername` | The username of the admin user to login as when running migration commands | | ||
| `AdminPassword` | The password of the admin user to login as when running migration commands | | ||
|
||
|
||
## Run the Project | ||
|
||
```bash | ||
$ dotnet run | ||
``` | ||
|
||
The output should have changed to show the message consumer generating the output (again, press Control+C to exit). Notice that the bus address now starts with _db_. | ||
|
||
``` | ||
Building... | ||
info: MassTransit[0] | ||
Configured endpoint Message, Consumer: GettingStarted.MessageConsumer | ||
info: Microsoft.Hosting.Lifetime[0] | ||
Application started. Press Ctrl+C to shut down. | ||
info: Microsoft.Hosting.Lifetime[0] | ||
Hosting environment: Development | ||
info: Microsoft.Hosting.Lifetime[0] | ||
Content root path: /Users/chris/Garbage/start/GettingStarted | ||
info: MassTransit[0] | ||
Bus started: db://localhost/ | ||
info: GettingStarted.MessageConsumer[0] | ||
Received Text: The time is 3/24/2021 12:11:10 PM -05:00 | ||
``` | ||
|
||
At this point the service is connecting to PostgreSQL on _localhost_ and publishing messages which are received by the consumer. | ||
|
||
:tada: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.