All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.messaging.servicebus.implementation.ServiceBusConnectionProcessor Maven / Gradle / Ivy

There is a newer version: 7.18.0-beta.1
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.messaging.servicebus.implementation;

import com.azure.core.amqp.AmqpRetryOptions;
import com.azure.core.amqp.implementation.AmqpChannelProcessor;
import com.azure.core.amqp.implementation.RetryUtil;
import com.azure.core.util.logging.ClientLogger;

import java.util.Objects;

/**
 * Responsible for emitting an active {@link ServiceBusAmqpConnection} to downstream subscribers. Fetches a new
 * connection when the existing connection closes.
 */
public class ServiceBusConnectionProcessor extends AmqpChannelProcessor {

    private final String fullyQualifiedNamespace;
    private final AmqpRetryOptions retryOptions;

    public ServiceBusConnectionProcessor(String fullyQualifiedNamespace, AmqpRetryOptions retryOptions) {
        super("", fullyQualifiedNamespace, channel -> channel.getEndpointStates(),
            RetryUtil.getRetryPolicy(retryOptions), new ClientLogger(ServiceBusConnectionProcessor.class));

        this.fullyQualifiedNamespace = Objects.requireNonNull(fullyQualifiedNamespace,
            "'fullyQualifiedNamespace' cannot be null.");
        this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null.");
    }

    /**
     * Gets the fully qualified namespace for the connection.
     *
     * @return The fully qualified namespace this is connection.
     */
    public String getFullyQualifiedNamespace() {
        return fullyQualifiedNamespace;
    }

    /**
     * Gets the retry options associated with the Service Bus connection.
     *
     * @return The retry options associated with the Service Bus connection.
     */
    public AmqpRetryOptions getRetryOptions() {
        return retryOptions;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy