This is an incredibly elementary question. Sorry.
I have a HornetQ 2.2.5.Final server running in standalone mode. So far so good. I have modified my installation to grant the createDurableQueue permission to the guest role (just for testing!), but otherwise, it is exactly as it was when i unzipped the download.
I would like to write a Java program, just a simple standalone command-line program, which can connect to the server, and do one (or more) of three things: create a new JMS queue, send a text message to an existing JMS queue, and receive a text message from an existing JMS queue.
I actually want to do much more than this, but this would be a great start!
I've looked at some of the example code, and read quite a bit of the user guide, and this is what i've got:
I can run the create and send operations without apparent error (no exceptions in the client, no messages in the server logs). However, if i try to receive a message that i have previously sent, i get an exception saying "Queue jms.queue.MyQueue does not exist". Here's the exact conversation i have with my program (via a shell script autogenerated by Gradle, which i don't believe is doing anything exciting):
$ build/install/HornetQDemo/bin/hq localhost 5445 MyQueue create jms.queue.MyQueue
$ build/install/HornetQDemo/bin/hq localhost 5445 MyQueue send "hello world"
$ build/install/HornetQDemo/bin/hq localhost 5445 MyQueue receive
Exception in thread "main" javax.jms.InvalidDestinationException: Queue jms.queue.MyQueue does not exist
Caused by: HornetQException[errorCode=100 message=Queue jms.queue.MyQueue does not exist]
... 11 more
I assume that i am not creating the queue properly. What do i need to do to create a queue?
EDIT: I tried the example client code at http://anonsvn.jboss.org/repos/hornetq/trunk/examples/jms/instantiate-connection-factory/src/org/hornetq/jms/example/InstantiateConnectionFactoryExample.java and i get exactly the same error (sending succeeds, receiving fails). That code only accesses the queue, it doesn't create it, so this suggests the problem is the way i create queues, not the way i use them.
If i look at the files $HORNET_HOME/data/bindings/hornetq-bindings-1.bindings, then i can see strings containing the names and addresses of the queues i have created. After running the create command, i can do:
$ strings -e l ./bindings/hornetq-bindings-1.bindings
Similarly, after running the send command, i can see the message in $HORNET_HOME/data/journal/hornetq-data-1.hq:
$ strings -e l ./journal/hornetq-data-1.hq
Can anyone suggest what might be going on? I can feel my sanity slipping away ...
SON OF EDIT: Oh, okay, fixed it.
What i failed to appreciate is that when creating a JMS queue using the core API, the name of the queue needs to have the jms.queue. prefix. So the name and address in my case should both be jms.queue.MyQueue. If i create the queue that way, everything works.
I am still puzzled as to how the message send worked when i was creating the queue wrongly, since i was sending to a nonexistent queue. Now, if don't run the create before the send, it blows up, so it seems the queue does need to be created before it can be sent to. But if i create the queue wrongly, that's good enough for sending, but not for receiving. What's going on there?