Exemplo n.º 1
0
    /// <summary>
    /// Configures a publisher for a pre-existing topic.
    /// </summary>
    /// <param name="queueUrl">The URL of the queue to publish to.</param>
    /// <typeparam name="T">The type of the message to publish to.</typeparam>
    /// <returns>The current <see cref="PublicationsBuilder"/>.</returns>
    /// <exception cref="ArgumentNullException"></exception>
    public PublicationsBuilder WithQueueUri <T>(Uri queueUrl)
        where T : Message
    {
        if (queueUrl == null)
        {
            throw new ArgumentNullException(nameof(queueUrl));
        }

        var builder = new QueueAddressPublicationBuilder <T>(QueueAddress.FromUri(queueUrl));

        Publications.Add(builder);

        return(this);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Configures a queue subscription for a pre-existing queue.
    /// </summary>
    /// <param name="queueUrl">The URL of the queue to subscribe to.</param>
    /// <param name="regionName">The AWS region the queue is in.</param>
    /// <param name="configure">An optional delegate to configure a queue subscription.</param>
    /// <typeparam name="T">The type of the message to subscribe to.</typeparam>
    /// <returns>The current <see cref="SubscriptionsBuilder"/>.</returns>
    public SubscriptionsBuilder ForQueueUri <T>(Uri queueUrl, string regionName = null, Action <QueueAddressSubscriptionBuilder <T> > configure = null)
        where T : Message
    {
        if (queueUrl == null)
        {
            throw new ArgumentNullException(nameof(queueUrl));
        }

        var queueAddress = QueueAddress.FromUri(queueUrl, regionName);
        var builder      = new QueueAddressSubscriptionBuilder <T>(queueAddress);

        configure?.Invoke(builder);

        Subscriptions.Add(builder);

        return(this);
    }