com.github.fridujo.rabbitmq.mock.ConfigurableConnectionFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rabbitmq-mock Show documentation
Show all versions of rabbitmq-mock Show documentation
Mock for RabbitMQ Java amqp-client
package com.github.fridujo.rabbitmq.mock;
import static com.github.fridujo.rabbitmq.mock.exchange.MockExchangeCreator.creatorWithExchangeType;
import com.github.fridujo.rabbitmq.mock.exchange.ConsistentHashExchange;
import com.github.fridujo.rabbitmq.mock.exchange.TypedMockExchangeCreator;
import com.rabbitmq.client.ConnectionFactory;
public abstract class ConfigurableConnectionFactory extends ConnectionFactory {
protected final MockNode mockNode = new MockNode();
@SuppressWarnings("unchecked")
public T withAdditionalExchange(TypedMockExchangeCreator mockExchangeCreator) {
mockNode.getConfiguration().registerAdditionalExchangeCreator(mockExchangeCreator);
return (T) this;
}
/**
* Make available the {@value ConsistentHashExchange#TYPE}'' exchange.
*
* See https://github.com/rabbitmq/rabbitmq-consistent-hash-exchange.
* @return this {@link ConfigurableConnectionFactory} instance (for chaining)
*/
public T enableConsistentHashPlugin() {
return withAdditionalExchange(
creatorWithExchangeType(ConsistentHashExchange.TYPE, ConsistentHashExchange::new)
);
}
}