从应用程序创建 Glassfish JMS 队列

Creating Glassfish JMS queues from application

我目前在我的 JEE 应用程序中使用多个 JMS 队列。由于我们的团队正在使用不同的登台服务器,我想在我的应用程序服务器中自动创建这些目的地。

我希望这可以通过脚本实现,但我真的希望通过 Java 应用程序实现。但是,我一直在对此进行研究,我发现的只是人们说这应该手动完成。

如果可能的话,你能告诉我一些 resources/examples 在 Java 中是如何完成的吗?否则我想要 shell.

的那些资源

感谢阅读!

您可以使用注释创建 JMS 资源like in this example

@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);
        }
    }

}