【发布时间】:2019-06-13 15:52:31
【问题描述】:
当代码部署在 STS Tomcat 服务器上时,我有一个正在运行的 springboot 代码,它充当侦听器并使用来自 Jboss EAP 7 队列的消息。
我现在需要在队列所在的 jboss EAP 7 服务器上部署相同的代码。
当我部署代码时,我会收到一条消息,表明战争已成功部署。之后,将打印 NO ERROR 或 SUCCESS 日志。
但是,当我检查队列时,它显示没有消费者。我尝试在调试模式下检查日志,我得到的只是以下消息。 如何在 jboss 上部署它,是否需要任何特定配置?如果我们在 Tomcat 上部署并从 jboss Q 消费,则相同的代码可以工作
2019-06-13 22:05:30,715 FINE [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 133) Completed initializing Mojarra (2.2.12-jbossorg-2 ) for context ''{0}''
2019-06-13 22:05:30,715 FINE [javax.enterprise.resource.webcontainer.jsf.timing] (ServerService Thread Pool -- 133) [TIMING] - [1025ms] : Initialization of context
2019-06-13 22:05:30,716 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 133) WFLYUT0021: Registered web context: /
2019-06-13 22:05:30,730 INFO [org.jboss.as.server] (ServerService Thread Pool -- 129) WFLYSRV0010: Deployed "Sample-0.0.1.war" (runtime-name : "Sample-0.0.1.war")
2019-06-13 22:05:30,730 DEBUG [org.jboss.as.server.deployment.scanner] (ServerService Thread Pool -- 133) Updating status after deployment notification for Sample-0.0.1.war
2019-06-13 22:05:32,942 DEBUG [org.apache.activemq.artemis.core.server] (activemq-expiry-reaper-thread) Cannot expire from jms.queue.ExpiryQueue into jms.queue.ExpiryQueue
我的队列配置如下:
@Bean JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory,
DefaultJmsListenerContainerFactoryConfigurer configurer) throws NamingException {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(getConnectionFactory());
return factory;
}
private ConnectionFactory getConnectionFactory() throws NamingException {
Context namingContext = null;
final Properties env = new Properties();
String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
String JBOSSQ_USERNAME = "admin";
String JBOSSQ_PASSWORD = "admin";
String INTIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
String PROVIDER_URL = "http-remoting://127.10.10.101:8080";
env.put(Context.INITIAL_CONTEXT_FACTORY,INTIAL_CONTEXT_FACTORY);
env.put(Context.PROVIDER_URL,System.getProperty(Context.PROVIDER_URL,PROVIDER_URL));
try {
namingContext = new InitialContext(env);
} catch (NamingException e) {
e.printStackTrace();
}
ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup(DEFAULT_CONNECTION_FACTORY);
UserCredentialsConnectionFactoryAdapter userCredentialsConnectionFactoryAdapter = new UserCredentialsConnectionFactoryAdapter();
userCredentialsConnectionFactoryAdapter.setUsername(JBOSSQ_USERNAME);
userCredentialsConnectionFactoryAdapter.setPassword(JBOSSQ_PASSWORD);
userCredentialsConnectionFactoryAdapter.setTargetConnectionFactory(connectionFactory);
return userCredentialsConnectionFactoryAdapter;
}
我的消费者代码如下:
@JmsListener(destination = "testingQ", containerFactory = "myFactory")
public void receiveMessage(String msg) {
System.out.println("Received :" + msg);
【问题讨论】:
-
分享你的消费者代码和队列配置
-
我已经更新了上面问题中的消费者代码和队列配置。您能否建议如何将这段代码部署在 jboss 而不是 tomcat 上?
标签: jboss spring-jms jboss-eap-7