JMS 1.1 spec Section 4.4.3 2nd paragraph:
Temporary destinations (TemporaryQueue or TemporaryTopic objects) are
destinations that are system-generated uniquely for their connection. Only
their own connection is allowed to create MessageConsumers for them.
I think this means the following test should fail as it tries to create a consumer on the temp queue from a different connection than the one that owns the temp queue. But it passes.
public void testTemporaryQueueScope()
{
try
{
// we stop both sender and receiver connections
senderConnection.stop();
receiverConnection.stop();
// we create a temporary queue to receive messages
tempQueue = receiverSession.createTemporaryQueue();
// we recreate the sender because it has been
// already created with a Destination as parameter
senderSession.createConsumer(tempQueue);
}
catch (JMSException e)
{
fail(e);
}