Example #1
0
 /// <summary>
 /// Convenience for "at-most once delivery" semantics. Each message is acked to RabbitMQ
 /// before it is emitted downstream.
 /// </summary>
 /// <param name="settings"></param>
 /// <param name="bufferSize"></param>
 /// <returns></returns>
 public static Source <IncomingMessage, NotUsed> AtMostOnceSource(IAmqpSourceSettings settings, int bufferSize)
 {
     return(CommittableSource(settings, bufferSize)
            .SelectAsync(1, async cm =>
     {
         await cm.Ack();
         return cm.Message;
     }));
 }
Example #2
0
            public AmqpSourceStageLogic(AmqpSourceStage <T> stage, Attributes attributes) : base(stage.Shape)
            {
                _outlet             = stage.Out;
                _amqpSourceSettings = stage.AmqpSourceSettings;
                _receiver           = stage.AmqpSourceSettings.GetReceiverLink();
                _decider            = attributes.GetDeciderOrDefault();

                SetHandler(_outlet, () =>
                {
                    if (_queue.TryDequeue(out var msg))
                    {
                        PushMessage(msg);
                    }
                }, onDownstreamFinish: CompleteStage);
Example #3
0
 /// <summary>
 /// The `committableSource` makes it possible to commit (ack/nack) messages to RabbitMQ.
 /// This is useful when "at-least once delivery" is desired, as each message will likely be
 /// delivered one time but in failure cases could be duplicated.
 /// If you commit the offset before processing the message you get "at-most once delivery" semantics,
 /// and for that there is a <see cref="AtMostOnceSource"/>.
 /// Compared to auto-commit, this gives exact control over when a message is considered consumed.
 /// </summary>
 /// <param name="settings"></param>
 /// <param name="bufferSize"></param>
 /// <returns>TBD</returns>
 public static Source <CommittableIncomingMessage, NotUsed> CommittableSource(IAmqpSourceSettings settings, int bufferSize)
 {
     return(Source.FromGraph(new AmqpSourceStage(settings, bufferSize)));
 }
Example #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="settings">The source settings</param>
 /// <param name="bufferSize">The max number of elements to prefetch and buffer at any given time.</param>
 public AmqpSourceStage(IAmqpSourceSettings settings, int bufferSize)
 {
     Settings   = settings;
     BufferSize = bufferSize;
 }
Example #5
0
 public static Source <T, NotUsed> Create <T>(IAmqpSourceSettings <T> sourceSettings)
 {
     return(Source.FromGraph(new AmqpSourceStage <T>(sourceSettings)));
 }
Example #6
0
 public AmqpSourceStage(IAmqpSourceSettings <T> amqpSourceSettings)
 {
     Out   = new Outlet <T>("AmqpSource.Out");
     Shape = new SourceShape <T>(Out);
     AmqpSourceSettings = amqpSourceSettings;
 }