org.springframework.cloud.stream.binder.AbstractBinder Java Examples

The following examples show how to use org.springframework.cloud.stream.binder.AbstractBinder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RabbitBindingCleaner.java    From spring-cloud-stream-binder-rabbit with Apache License 2.0 6 votes vote down vote up
private List<String> findExchanges(Client client, String vhost, String binderPrefix, String entity) {
	List<ExchangeInfo> exchanges = client.getExchanges(vhost);
	String exchangeNamePrefix = adjustPrefix(AbstractBinder.applyPrefix(binderPrefix, entity));
	List<String> exchangesToRemove = exchanges.stream()
			.filter(e -> e.getName().startsWith(exchangeNamePrefix))
			.map(e -> {
				System.out.println(e.getName());
				List<BindingInfo> bindingsBySource = client.getBindingsBySource(vhost, e.getName());
				return Collections.singletonMap(e.getName(), bindingsBySource);
			})
			.map(bindingsMap -> hasNoForeignBindings(bindingsMap, exchangeNamePrefix))
			.collect(Collectors.toList());
	exchangesToRemove.stream()
			.map(exchange -> client.getExchangeBindingsByDestination(vhost, exchange))
			.forEach(bindings -> {
				if (bindings.size() > 0) {
					throw new RabbitAdminException("Cannot delete exchange "
							+ bindings.get(0).getDestination() + "; it is a destination: " + bindings);
				}
			});
	return exchangesToRemove;
}
 
Example #2
Source File: RetryTemplateTests.java    From spring-cloud-stream with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
@Test
public void testSpecificCustomRetryTemplate() throws Exception {
	ApplicationContext context = new SpringApplicationBuilder(
			SpecificCustomRetryTemplateConfiguration.class)
					.web(WebApplicationType.NONE).run("--spring.jmx.enabled=false",
							"--spring.cloud.stream.bindings.input.consumer.retry-template-name=retryTemplateTwo");

	RetryTemplate retryTemplateTwo = context.getBean("retryTemplateTwo",
			RetryTemplate.class);
	BindingServiceProperties bindingServiceProperties = context
			.getBean(BindingServiceProperties.class);
	ConsumerProperties consumerProperties = bindingServiceProperties
			.getConsumerProperties("input");
	AbstractBinder binder = context.getBean(AbstractBinder.class);

	Method m = AbstractBinder.class.getDeclaredMethod("buildRetryTemplate",
			ConsumerProperties.class);
	m.setAccessible(true);
	RetryTemplate retryTemplate = (RetryTemplate) m.invoke(binder,
			consumerProperties);
	assertThat(retryTemplate).isEqualTo(retryTemplateTwo);
}
 
Example #3
Source File: RabbitBindingCleaner.java    From spring-cloud-stream-binder-rabbit with Apache License 2.0 5 votes vote down vote up
private LinkedList<String> findStreamQueues(Client client, String vhost, String binderPrefix, String stream) {
	String queueNamePrefix = adjustPrefix(AbstractBinder.applyPrefix(binderPrefix, stream));
	List<QueueInfo> queues = client.getQueues(vhost);
	return queues.stream()
		.filter(q -> q.getName().startsWith(queueNamePrefix))
		.map(q -> checkNoConsumers(q))
		.collect(Collectors.toCollection(LinkedList::new));
}
 
Example #4
Source File: RetryTemplateTests.java    From spring-cloud-stream with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
@Test
public void testSingleCustomRetryTemplate() throws Exception {
	ApplicationContext context = new SpringApplicationBuilder(
			SingleCustomRetryTemplateConfiguration.class).web(WebApplicationType.NONE)
					.run("--spring.jmx.enabled=false");
	AbstractBinder binder = context.getBean(AbstractBinder.class);
	Field f = AbstractBinder.class.getDeclaredField("consumerBindingRetryTemplates");
	f.setAccessible(true);
	@SuppressWarnings("unchecked")
	Map<String, RetryTemplate> consumerBindingRetryTemplates = (Map<String, RetryTemplate>) f
			.get(binder);
	assertThat(consumerBindingRetryTemplates).hasSize(1);
}