我的项目中有这个消息驱动的Bean实现类:
@MessageDriven(
name="Updater",
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/delete_topic"),
@ActivationConfigProperty(propertyName = "providerAdapterJNDI", propertyValue="java:/MyJMSProvider"),
@ActivationConfigProperty(propertyName = "reconnectAttempts", propertyValue=""+Integer.MAX_VALUE),
@ActivationConfigProperty(propertyName = "reconnectInterval", propertyValue="15"),
@ActivationConfigProperty(propertyName = "user", propertyValue=JbossJaasAuthenticator.principal),
@ActivationConfigProperty(propertyName = "password", propertyValue=JbossJaasAuthenticator.credentials)
})
@Interceptors(MediaExchangeSpringBeanAutowiringInterceptor.class)
public class MyUpdater implements MessageListener {...}
当我的服务器无法访问时(经常发生),我在日志文件中得到了这个:
org.jboss.resource.adapter.jms.inflow.JmsActivation Unable to reconnect org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@28d79ac8(ra=org.jboss.resource.adapter.jms.JmsResourceAdapter@6eff0db7 destination=topic/delete_topic destinationType=javax.jms.Topic tx=true durable=false reconnect=15 provider=java:/MyJMSProvider user=myuser pass=<not shown> maxMessages=1 minSession=1 maxSession=15 keepAlive=60000 useDLQ=true DLQHandler=org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler DLQJndiName=queue/DLQ DLQUser=null DLQMaxResent=5)javax.naming.CommunicationException: Could not obtain connection to any of these urls: my.url.net:49227 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] [Root exception is javax.naming.CommunicationException: Failed to connect to server my.url.net/10.0.9.60:49227 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server my.url.net/10.0.9.60:49227 [Root exception is java.net.NoRouteToHostException: No route to host]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1763)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:693)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at org.jboss.util.naming.Util.lookup(Util.java:222)
at org.jboss.resource.adapter.jms.inflow.dlq.AbstractDLQHandler.setupDLQDestination(AbstractDLQHandler.java:106)
at org.jboss.resource.adapter.jms.inflow.dlq.AbstractDLQHandler.setup(AbstractDLQHandler.java:82)
at org.jboss.resource.adapter.jms.inflow.dlq.JBossMQDLQHandler.setup(JBossMQDLQHandler.java:48)
at org.jboss.resource.adapter.jms.inflow.JmsActivation.setupDLQ(JmsActivation.java:413)
at org.jboss.resource.adapter.jms.inflow.JmsActivation.setup(JmsActivation.java:351)
at org.jboss.resource.adapter.jms.inflow.JmsActivation.handleFailure(JmsActivation.java:292)
at org.jboss.resource.adapter.jms.inflow.dlq.AbstractDLQHandler.onException(AbstractDLQHandler.java:94)
at org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener.handleConnectionException(ConsolidatedRemotingConnectionListener.java:113)
at org.jboss.remoting.ConnectionValidator$1.run(ConnectionValidator.java:633)
Caused by: javax.naming.CommunicationException: Failed to connect to server my.url.net/10.0.9.60:49227 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server my.url.net/10.0.9.60:49227 [Root exception is java.net.NoRouteToHostException: No route to host]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:335)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1734)
... 13 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server my.url.net/10.0.9.60:49227 [Root exception is java.net.NoRouteToHostException: No route to host]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:305)
... 14 more
Caused by: java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:97)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:82)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:301)
... 14 more
我使用log4j。我需要做什么才能打印出异常的第一行,而不是完整的堆栈跟踪?是否需要调整一些JMS配置,或者我可以在log4j中执行哪些操作?