in domain/src/main/java/org/apache/rocketmq/eventbridge/domain/model/source/HTTPEventSourceService.java [158:185]
public String generateToken(String accountId) throws EventBridgeException {
int count = GET_TOKEN_TIMES;
String token = TokenUtil.generateHttpSourceToken();
Set<String> tokenSet = new HashSet<>();
int busCount = eventBusService.getEventBusesCount(accountId);
PaginationResult<List<EventBus>> paginationResult =
eventBusService.listEventBuses(accountId, "0", busCount);
for (EventBus eventBus : paginationResult.getData()) {
int sourceCount = getEventSourceCount(accountId, eventBus.getName());
PaginationResult<List<EventSource>> listEventSources =
listEventSources(accountId, eventBus.getName(), "0", sourceCount);
listEventSources.getData().stream()
.filter(eventSource -> this.match(eventSource.getType(), eventSource.getClassName()))
.forEach(eventSource -> tokenSet.add((String) eventSource.getConfig().get(TOKEN_CONFIG)));
}
if (count > 0 && tokenSet.contains(token)) {
token = TokenUtil.generateHttpSourceToken();
count--;
}
if (count == 0) {
throw new EventBridgeException(GenerateTokenError, "Get token failed with " + GET_TOKEN_TIMES + " retry times");
}
return token;
}