使用消息驱动 BEans 时,接收消息的目标名称在注解中硬编码@MessageDriven(mappedName = "someDestinationName")
有没有办法在运行时添加这些信息?Bellow 是一个示例消息驱动 Bean 类。
package mdb.beans;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Message;
import javax.jms.MessageListener;
@MessageDriven(mappedName = "someDestinationName", activationConfig =
{
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class MDBSample implements MessageListener
{
public MDBSample()
{
// constructor
}
@Override
public void onMessage(Message message)
{
// logic when message received
}
}