public BStream(BType type, String name) { if (((BStreamType) type).getConstrainedType() == null) { throw new BallerinaException("a stream cannot be declared without a constraint"); } try { this.brokerInstance = BallerinaBroker.getBrokerInstance(); } catch (Exception e) { throw new BallerinaException("Error starting up internal broker for streams"); } this.constraintType = ((BStreamType) type).getConstrainedType(); this.type = new BStreamType(constraintType); if (constraintType instanceof BIndexedType) { this.topicName = TOPIC_NAME_PREFIX + ((BIndexedType) constraintType).getElementType() + "_" + name; } else if (constraintType != null) { this.topicName = TOPIC_NAME_PREFIX + constraintType + "_" + name; } else { this.topicName = TOPIC_NAME_PREFIX + name; //TODO: check for improvement } topicName = topicName.concat("_").concat(UUID.randomUUID().toString()); this.streamId = name; }