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

pl.allegro.tech.hermes.consumers.consumer.sender.resolver.EndpointAddressResolver Maven / Gradle / Ivy

There is a newer version: 2.10.0
Show newest version
package pl.allegro.tech.hermes.consumers.consumer.sender.resolver;

import pl.allegro.tech.hermes.api.EndpointAddress;
import pl.allegro.tech.hermes.api.EndpointAddressResolverMetadata;
import pl.allegro.tech.hermes.consumers.consumer.Message;
import pl.allegro.tech.hermes.consumers.consumer.batch.MessageBatch;

import java.net.URI;
import java.util.Collections;
import java.util.List;

public interface EndpointAddressResolver {

    default URI resolve(EndpointAddress address, Message message, EndpointAddressResolverMetadata metadata)
            throws EndpointAddressResolutionException {
        return resolve(address);
    }

    default URI resolve(EndpointAddress address, MessageBatch batch, EndpointAddressResolverMetadata metadata)
            throws EndpointAddressResolutionException {
        return resolve(address);
    }

    static URI resolve(EndpointAddress address) throws EndpointAddressResolutionException {
        try {
            return address.getUri();
        } catch (Exception ex) {
            throw new EndpointAddressResolutionException(address, ex);
        }
    }

    default List resolveAll(EndpointAddress address, Message message, EndpointAddressResolverMetadata metadata)
            throws EndpointAddressResolutionException {
        return Collections.singletonList(resolve(address, message, metadata));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy