My connection factory:
<connection-factory name="InVmConnectionFactory">
<connectors>
<connector-ref connector-name="in-vm"/>
</connectors>
<entries>
<entry name="java:/ConnectionFactory"/>
</entries>
</connection-factory>
Destination Queue:
<jms-queue name="TestQueue">
<entry name="java:jboss/jms/queue/TestQueue"/>
<durable>true</durable>
</jms-queue>
I have written the below Java sample code to look-up the queue defined in JBoss EAP 6.4, but I'm getting an exception on looking up the queue. The connection factory look up is working
InitialContext ctx = new InitialContext();
QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("/ConnectionFactory");
qc = qcf.createQueueConnection();
qc.setExceptionListener(this);
qsess = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue) ctx.lookup("/jms/queue/TestQueue");
qsndr = qsess.createSender(queue);
Sorry, I found out the issue. I need to specify the fully qualified name otherwise it won't work. Fixed by using this code:
Queue queue = (Queue) ctx.lookup("java:jboss/jms/queue/TestQueue");