0

I have a Message Driven Bean

@MessageDriven(ejbName = "TestMDB", 
    destinationJndiName="test.QueueIn", destinationType = "javax.jms.Queue")
public class TestMDB extends GenericMessageDrivenBean implements
    MessageDrivenBean, MessageListener {
    .....
}

I'd like to replace the direct destination reference "test.QueueIn" with the "java:comp/env/jms/TestQueueIn" notation. This should allow me to specify the MDB destination in the deployment descriptor instead of in the java code. That is, I want to determine the MDB destination in the deployment time, not in the compile time.

Is this possible? Or, is there a better way of creating the reference indirection?

xarx
  • 627
  • 1
  • 11
  • 27
  • Do you want to configure it through deployment descriptor – Nayan Wadekar Mar 28 '12 at 18:55
  • Yes, I want to have in the code only a resource reference, and to have the resource specified in the deployment descriptor. This question has two parts: Which annotation to use in the code instead of destinationJndiName. And what to write into the deployment descriptor. – xarx Mar 28 '12 at 19:24

1 Answers1

1

I found a way how to do it, though I don't know if its ideal.

@ResourceEnvRef(name="jms/RequestQueue", type="javax.jms.Queue", jndiName="test.QueueIn"),
@MessageDriven(ejbName = "TestMDB", destinationJndiName="java:comp/env/jms/RequestQueue", destinationType = "javax.jms.Queue")
public class TestMDB extends GenericMessageDrivenBean implements
    MessageDrivenBean, MessageListener {
    .....
}

The jndiName in @ResourceEnvRef is an optional attribute, so you don't need to specify it in the code. However, even if you do, it serves merely as a default value, you can always change it in the (generated) deployment descriptor.

xarx
  • 627
  • 1
  • 11
  • 27