我目前在我的JEE应用程序中使用多个JMS队列。由于我们的团队正在使用不同的临时服务器,因此我希望在我的应用程序服务器中自动创建这些目标。
我希望脚本可以实现这一点,但我真的希望Java应用程序可以实现。但是,我一直在研究这个问题,我发现所有人都说这应该手动完成。
如果可能的话,您能否指出一些如何在Java中完成的资源/示例。否则我想要那些资源用于shell。
感谢阅读!
答案 0 :(得分:1)
您可以使用注释like in this example
创建JMS资源@JMSDestinationDefinition(
name="java:global/queue/simpleQ",
interfaceName="javax.jms.Queue",
destinationName = "simpleQ"
)
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:global/queue/simpleQ"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class MessageConsumer implements MessageListener {
public MessageConsumer() {
}
@Override
public void onMessage(Message message) {
try {
System.out.println("Message received: " + message.getBody(String.class));
} catch (JMSException ex) {
Logger.getLogger(MessageConsumer.class.getName()).log(Level.SEVERE, null, ex);
}
}
}