Firstly - you shouldn't be using HornetQ internal objects directly.
Please stick to the API objects (these are the ones in the api package)
It's not possible using the JMS API to create a temp queue with a specific name - this is not a limitation of HornetQ it's just how the JMS API is.
However you can do this using the core API. Problem is you are mixing and matching the two.
If you want to use the JMS API you will need to create a temp queue using the normal JMS means, then send the temp queue name in a message.
The other end can then consume that message and it will know the name of the temp queue.
What you could do (but it is a bit hacky and I don't recommend it), is create your temp queue using the core api with the name "jms.queue.mytempqueue" (you can change the mytempqueue part to what you want).
Then that queue will be available using the JMS api with the name "mytempqueue" (without the jms.queue part).
Also see http://hornetq.sourceforge.net/docs/hornetq-2.0.0.GA/user-manual/en/html/jms-core-mapping.html - basically jms queues map to core queues with the prefix "jms.queue"
Thank you very much for the answer. If I create a temp queue with the core api I'm still not able to use the name from the second connection:
TemporaryQueue mytempq = coreSession.createTemporaryQueue();
MessageConsumer consumer = coreSession.createConsumer(mytempq);
Session session = cf.createConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(session.createQueue(mytempq.getQueueName()));
from what I understood you recommended something like this - am I doing something wrong? I still receive "there is no queue with name ..."
Firstly there is no method createTemporaryQueue() on the core API, so I don't know what you mean here.
I suggest reading the chapter on core messaging in the user manual to understand the differences between address and queue names.
You send messages to an address, not a queue name
I think I understood what you mean, sorry for mixing the things - now looks that it works. Thanks a lot!