private Map<String, List<String>> doClean(String adminUri, String user, String pw, String vhost,
			String busPrefix, String entity, boolean isJob) {
		RestTemplate restTemplate = RabbitManagementUtils.buildRestTemplate(adminUri, user, pw);
		List<String> removedQueues = isJob
				? findJobQueues(adminUri, vhost, busPrefix, entity, restTemplate)
				: findStreamQueues(adminUri, vhost, busPrefix, entity, restTemplate);
		ExchangeCandidateCallback callback;
		if (isJob) {
			String pattern;
			if (entity.endsWith("*")) {
				pattern = entity.substring(0, entity.length() - 1) + "[^.]*";
			}
			else {
				pattern = entity;
			}
			Collection<String> exchangeNames = JobEventsListenerPlugin.getEventListenerChannels(pattern).values();
			final Set<Pattern> jobExchanges = new HashSet<>();
			for (String exchange : exchangeNames) {
				jobExchanges.add(Pattern.compile(MessageBusSupport.applyPrefix(busPrefix,
						MessageBusSupport.applyPubSub(exchange))));
			}
			jobExchanges.add(Pattern.compile(MessageBusSupport.applyPrefix(busPrefix, MessageBusSupport.applyPubSub(
					JobEventsListenerPlugin.getEventListenerChannelName(pattern)))));
			callback = new ExchangeCandidateCallback() {

				@Override
				public boolean isCandidate(String exchangeName) {
					for (Pattern pattern : jobExchanges) {
						Matcher matcher = pattern.matcher(exchangeName);
						if (matcher.matches()) {
							return true;
						}
					}
					return false;
				}

			};
		}
		else {
			final String tapPrefix = adjustPrefix(MessageBusSupport.applyPrefix(busPrefix,
					MessageBusSupport.applyPubSub(BusUtils.constructTapPrefix(entity))));
			callback = new ExchangeCandidateCallback() {

				@Override
				public boolean isCandidate(String exchangeName) {
					return exchangeName.startsWith(tapPrefix);
				}
			};
		}
		List<String> removedExchanges = findExchanges(adminUri, vhost, busPrefix, entity, restTemplate, callback);
		// Delete the queues in reverse order to enable re-running after a partial success.
		// The queue search above starts with 0 and terminates on a not found.
		for (int i = removedQueues.size() - 1; i >= 0; i--) {
			String queueName = removedQueues.get(i);
			URI uri = UriComponentsBuilder.fromUriString(adminUri + "/api")
					.pathSegment("queues", "{vhost}", "{stream}")
					.buildAndExpand(vhost, queueName).encode().toUri();
			restTemplate.delete(uri);
			if (logger.isDebugEnabled()) {
				logger.debug("deleted queue: " + queueName);
			}
		}
		Map<String, List<String>> results = new HashMap<>();
		if (removedQueues.size() > 0) {
			results.put("queues", removedQueues);
		}
		// Fanout exchanges for taps
		for (String exchange : removedExchanges) {
			URI uri = UriComponentsBuilder.fromUriString(adminUri + "/api")
					.pathSegment("exchanges", "{vhost}", "{name}")
					.buildAndExpand(vhost, exchange).encode().toUri();
			restTemplate.delete(uri);
			if (logger.isDebugEnabled()) {
				logger.debug("deleted exchange: " + exchange);
			}
		}
		if (removedExchanges.size() > 0) {
			results.put("exchanges", removedExchanges);
		}
		return results;
	}
Implementation of {@link BusCleaner} for the {@code RabbitMessageBus}.

@author Gary Russell
@since 1.2
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/integration/bus/rabbit/RabbitBusCleaner.java