Jakarta ee 我可以使用哪些maven依赖项为Glassfish创建独立的JMS客户机?
我想创建一个非常简单的JMS独立客户机,用于托管在Glassfish服务器上的JMS主题 我的项目是使用maven构建的 我知道在使用JMS依赖项方面似乎有一些混乱,所以,我应该在pom中使用哪些依赖项来解决这个问题Jakarta ee 我可以使用哪些maven依赖项为Glassfish创建独立的JMS客户机?,jakarta-ee,maven,glassfish,jms,Jakarta Ee,Maven,Glassfish,Jms,我想创建一个非常简单的JMS独立客户机,用于托管在Glassfish服务器上的JMS主题 我的项目是使用maven构建的 我知道在使用JMS依赖项方面似乎有一些混乱,所以,我应该在pom中使用哪些依赖项来解决这个问题 连接到我的JNDI上下文 能够阅读我的JMS主题吗 我的Java测试方法是 /** Thanks to WELD CDI, this method is not static */ public void main(@Observes ContainerInitialized ev
/** Thanks to WELD CDI, this method is not static */
public void main(@Observes ContainerInitialized event) throws Throwable {
Context context = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) context.lookup(JMSNotifierConstants.CONNECTION_FACTORY_NAME);
Connection connection = factory.createConnection();
Topic topic = (Topic) context.lookup(JMSNotifierConstants.NOTIFICATION_TOPIC);
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(topic);
connection.start();
while (true) {
Message received = consumer.receive();
System.out.println(received);
}
}
目前,我的pom包含以下依赖项
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.0-SP1</version>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-se</artifactId>
<version>1.0.1-Final</version>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-logger</artifactId>
<version>1.0.0-CR2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.jms</artifactId>
<version>3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>appserv-rt</artifactId>
<version>3.1</version>
</dependency>
javax.enterprise
CDIAPI
1.0-SP1
org.jboss.weld
焊接se
1.0.1-最终版本
org.jboss.weld
焊接记录器
1.0.0-CR2
罐子
编译
org.slf4j
slf4j api
1.6.1
org.slf4j
slf4j-jdk14
1.6.1
玻璃鱼
javax.jms
3
编译
org.glassfish.extras
appserv rt
3.1
我正在从GF 2.1转换到3.1,但我还没有使用客户端软件(它肯定在我的列表中),但据我所知,您需要使用GF 3.1安装大部分glassfish才能启动客户端。(对于GF 2.1,包含文件的容量为15+mb)
“gf-client.jar引用了GlassFish安装目录中的许多其他.jar,因此最好从安装目录本身中引用它,而不是将它(以及所有其他.jar)复制到另一个位置”
您可以使用自动生成的webstart launch with Application Client容器,也可以打包客户端并手动部署它 好吧,这一次相当棘手 经过一些搜索和尝试后,我删除了焊接依赖项(以便返回到更经典的main) 然后,我用
<dependency>
<groupId>org.glassfish.appclient</groupId>
<artifactId>gf-client</artifactId>
<version>3.1</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
关联到imqjmsra.jar
及
我完全可以轮询我的JMS队列。您可以通过添加以下内容获得imqbroker:
<dependency>
<groupId>com.sun.messaging.mq</groupId>
<artifactId>imqbroker</artifactId>
<version>4.5.1-b03</version>
</dependency>
com.sun.messaging.mq
imqbroker
4.5.1-b03
对我来说,有效的方法是从glassfish安装文件夹添加gf-client.jar,但从maven存储库添加gf-client不起作用
在使用maven依赖项时,我发现这是可行的:
org.glassfish.main.extras
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.glassfish.external.jms</groupId>
<artifactId>imqbroker</artifactId>
<version>3.1.0</version>
<description>POM was created by Sonatype Nexus</description>
</project>
<dependency>
<groupId>org.glassfish.appclient</groupId>
<artifactId>gf-client</artifactId>
<version>3.1</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.external.jms</groupId>
<artifactId>imqjmsra</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.sun.messaging.mq</groupId>
<artifactId>imqbroker</artifactId>
<version>4.5.1-b03</version>
</dependency>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2</version>
</dependency>