QueueSession queueSession = _connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
// This is the only easy way to create and bind a queue from the API :-(
queueSession.createConsumer(validDestination);
QueueSender sender = queueSession.createSender(invalidDestination);
TextMessage msg = queueSession.createTextMessage("Hello");
try
{
sender.send(msg);
fail("Expected InvalidDestinationException");
}
catch (InvalidDestinationException ex)
{
// pass
}
sender.close();
sender = queueSession.createSender(null);
invalidDestination = new AMQQueue("amq.direct","unknownQ");
try
{
sender.send(invalidDestination,msg);
fail("Expected InvalidDestinationException");
}
catch (InvalidDestinationException ex)
{
// pass
}
sender.send(validDestination,msg);
sender.close();
validDestination = new AMQQueue("amq.direct","knownQ");
sender = queueSession.createSender(validDestination);
sender.send(msg);
}