The Apache Qpid Java client API has an AMQConnection class that is used to make a connection to a Qpid message broker. I'm using the single-String constructor (AMQConnection(String connection)
). I have a utility method that creates the connection string first, which is then passed to the AMQConnection constructor.
The connection string is of the form amqp://<username>:<password>@<clientID>/?brokerlist='tcp://<hostname>:<port>'
.
If the constructor is passed a connection string with incorrect syntax, it throws a URLSyntaxException
.
I would like to move the connection string syntax check to the utility method (I'm of the opinion that it shouldn't be able to return broken information), but I have not found any way of validating the connection string short of trying to set up a connection to the message broker. Is there any way of doing this, or do I just have to rely on the URLSyntaxException
being thrown from the constructor?