private CommandSubscription(final String topic) { Objects.requireNonNull(topic); final String[] parts = topic.split("\\/"); if (parts.length != 5 || !"#".equals(parts[4])) { throw new IllegalArgumentException("topic filter does not match pattern: control|c/+/+/req|q/#"); } endpoint = parts[0]; if (!CommandConstants.isCommandEndpoint(endpoint)) { throw new IllegalArgumentException( "the endpoint needs to be '" + CommandConstants.COMMAND_ENDPOINT + "' or '" + CommandConstants.COMMAND_ENDPOINT_SHORT + "'"); } req = parts[3]; if (!CommandConstants.COMMAND_RESPONSE_REQUEST_PART.equals(req) && !CommandConstants.COMMAND_RESPONSE_REQUEST_PART_SHORT.equals(req)) { throw new IllegalArgumentException( "the request part needs to be '" + CommandConstants.COMMAND_RESPONSE_REQUEST_PART + "' or '" + CommandConstants.COMMAND_RESPONSE_REQUEST_PART_SHORT + "'"); } if (!"+".equals(parts[1])) { tenant = parts[1]; } if (!"+".equals(parts[2])) { deviceId = parts[2]; } }
private CommandSubscription(final String topic) { Objects.requireNonNull(topic); this.topic = topic; final String[] parts = topic.split("\\/"); if (parts.length != 5 || !"#".equals(parts[4])) { throw new IllegalArgumentException("topic filter does not match pattern: control|c/+/+/req|q/#"); } endpoint = parts[0]; if (!CommandConstants.isCommandEndpoint(endpoint)) { throw new IllegalArgumentException( "the endpoint needs to be '" + CommandConstants.COMMAND_ENDPOINT + "' or '" + CommandConstants.COMMAND_ENDPOINT_SHORT + "'"); } req = parts[3]; if (!CommandConstants.COMMAND_RESPONSE_REQUEST_PART.equals(req) && !CommandConstants.COMMAND_RESPONSE_REQUEST_PART_SHORT.equals(req)) { throw new IllegalArgumentException( "the request part needs to be '" + CommandConstants.COMMAND_RESPONSE_REQUEST_PART + "' or '" + CommandConstants.COMMAND_RESPONSE_REQUEST_PART_SHORT + "'"); } if (!"+".equals(parts[1])) { tenant = parts[1]; } if (!"+".equals(parts[2])) { deviceId = parts[2]; } }
.map(validAddress -> { if (CommandConstants.isCommandEndpoint(validAddress.getEndpoint())) { return openCommandSenderLink(sender, validAddress, authenticatedDevice, span) .map(consumer -> {