{
BindingQuery response = session.bindingQuery(dest.getSimpleAddress());
if (!response.isExists())
{
throw new InvalidDestinationException("Queue " + dest.getName() + " does not exist");
}
consumer = session.createConsumer(dest.getSimpleAddress(), coreFilterString, false);
}
else
{
BindingQuery response = session.bindingQuery(dest.getSimpleAddress());
if (!response.isExists())
{
throw new InvalidDestinationException("Topic " + dest.getName() + " does not exist");
}
SimpleString queueName;
if (subscriptionName == null)
{
// Non durable sub
queueName = new SimpleString(UUID.randomUUID().toString());
session.createTemporaryQueue(dest.getSimpleAddress(), queueName, coreFilterString);
consumer = session.createConsumer(queueName, null, false);
autoDeleteQueueName = queueName;
}
else
{
// Durable sub
if (connection.getClientID() == null)
{
throw new InvalidClientIDException("Cannot create durable subscription - client ID has not been set");
}
if (dest.isTemporary())
{
throw new InvalidDestinationException("Cannot create a durable subscription on a temporary topic");
}
queueName = new SimpleString(HornetQDestination.createQueueNameForDurableSubscription(connection.getClientID(),
subscriptionName));