static async Task Main(string[] args) { using var actorSystem = ActorSystem.Create("poc"); using var mat = actorSystem.Materializer(); var connectionSettings = AmqpConnectionDetails.Create("localhost", 5672) .WithCredentials(AmqpCredentials.Create("mirero", "system")) .WithAutomaticRecoveryEnabled(true) .WithNetworkRecoveryInterval(TimeSpan.FromSeconds(1)); var queueName = "Amqp_Test_1"; var queueDeclation = QueueDeclaration.Create(queueName) .WithDurable(false) .WithAutoDelete(true); var amqpSink = AmqpSink.CreateSimple(AmqpSinkSettings.Create(connectionSettings) .WithRoutingKey(queueName) .WithDeclarations(queueDeclation)); var amqpSource = AmqpSource.CommittableSource(NamedQueueSourceSettings.Create(connectionSettings, queueName) .WithDeclarations(queueDeclation), 1); var input = new[] { "one", "two", "three", "four", "five" }; await Source.From(input) .Select(ByteString.FromString) .RunWith(amqpSink, mat); await actorSystem.Terminate(); }
public AmqpConnectorsTest(AmqpFixture fixture, ITestOutputHelper output) : base((ActorSystem)null, output) { _mat = ActorMaterializer.Create(Sys); _connectionSettings = AmqpConnectionDetails .Create(fixture.HostName, fixture.AmqpPort) .WithCredentials(AmqpCredentials.Create(fixture.UserName, fixture.Password)) .WithAutomaticRecoveryEnabled(true) .WithNetworkRecoveryInterval(TimeSpan.FromSeconds(1)); _fixture = fixture; }
public static Source <CommittableIncomingMessage, Akka.NotUsed> CommittableQueue(Action <SimpleQueueOptions> opt) { var option = new SimpleQueueOptions(); opt.Invoke(option); var connectionSettings = AmqpConnectionDetails.Create(option.HostAndPorts.First().Host, option.HostAndPorts.First().Port) .WithHostsAndPorts(option.HostAndPorts.First(), option.HostAndPorts.ToArray()) .WithCredentials(AmqpCredentials.Create(option.UserName, option.Password)) .WithAutomaticRecoveryEnabled(true) .WithNetworkRecoveryInterval(TimeSpan.FromSeconds(1)) .WithVirtualHost(option.VirtualHost); var queueDeclaration = QueueDeclaration.Create(option.QueueName) .WithDurable(false) .WithAutoDelete(false); return(AmqpSource.CommittableSource(NamedQueueSourceSettings.Create(connectionSettings, option.QueueName) .WithDeclarations(queueDeclaration), 1)); }
public static Sink <ByteString, Task> Simple(Action <SimpleQueueOptions> opt) { var option = new SimpleQueueOptions(); opt.Invoke(option); var connectionSettings = AmqpConnectionDetails.Create(option.HostAndPorts.First().Host, option.HostAndPorts.First().Port) .WithHostsAndPorts(option.HostAndPorts.First(), option.HostAndPorts.ToArray()) .WithCredentials(AmqpCredentials.Create(option.UserName, option.Password)) .WithAutomaticRecoveryEnabled(true) .WithNetworkRecoveryInterval(TimeSpan.FromSeconds(1)) .WithVirtualHost(option.VirtualHost ?? "/"); var queueDeclaration = QueueDeclaration.Create(option.QueueName) .WithDurable(false) .WithAutoDelete(false); return(AmqpSink.CreateSimple(AmqpSinkSettings.Create(connectionSettings) .WithRoutingKey(option.QueueName) .WithDeclarations(queueDeclaration))); }