Created
November 30, 2018 13:16
-
-
Save stephenpatten/1f1e15ad6b6dc88bedc5b72d3d186853 to your computer and use it in GitHub Desktop.
MT - Basic Publisher
This file contains hidden or 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
namespace Publisher | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Contracts; | |
using MassTransit; | |
using MassTransit.RabbitMqTransport; | |
class Program | |
{ | |
static async Task Main() | |
{ | |
IBusControl bus = Bus.Factory.CreateUsingRabbitMq( | |
sbc => sbc.Host( | |
new Uri("rabbitmq://localhost/filepersistence"), | |
h => | |
{ | |
h.Username("filepersistence"); | |
h.Password("filepersistence"); | |
})); | |
await bus.StartAsync().ConfigureAwait(false); | |
for (int i = 0; i < 100; i++) | |
{ | |
var message = new PayloadCreatedMessage | |
{ | |
Message = File.ReadAllText("d:\\logs\\SystemOut_18.08.03_13.23.46.log"), | |
Path = "c:\\logs\\payload\\foo.xml", | |
When = DateTime.UtcNow | |
}; | |
await bus.Publish<PayloadCreatedMessage>(message).ConfigureAwait(false); | |
} | |
Console.ReadLine(); | |
await bus.StopAsync().ConfigureAwait(false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment