问题陈述:我正在寻找帮助,将JMS连接工厂暴露给远程ActiveMQ实例(侦听tcp)作为Tomcat7中的容器资源,以便部署在Tomcat7上的Web应用程序可以访问它
我的配置:我在服务器上运行了Tomee和Tomcat7实例。 Tomee是ActiveMQ的主机,代理配置为侦听tcp wireformat连接(下面的tomee.xml):
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<!-- see http://tomee.apache.org/containers-and-resources.html -->
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = broker:(tcp://10.173.80.42:61619)
ServerUrl = tcp://10.173.80.42:61619
</Resource>
<Resource id="jms/ConnectionFactory" type="javax.jms.ConnectionFactory">
ResourceAdapter = MyJmsResourceAdapter
</Resource>
<Container id="MyJmsMdbContainer" type="MESSAGE">
ResourceAdapter = MyJmsResourceAdapter
</Container>
<Resource id="myqueue" type="javax.jms.Queue"/>
<!-- activate next line to be able to deploy applications in apps -->
<Deployments dir="apps" />
</tomee>
在我的Tomcat7实例中,我将server.xml配置为:
<Resource name="jms/ConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://10.173.80.42:61619?soTimeout=60000"
brokerName="ActiveMQStageBroker"
useEmbeddedBroker="false" />
<Resource name="myQueue"
auth="Container"
type="org.apache.activemq.command.ActiveMQQueue"
proxy-interface="javax.jms.Queue"
description="My Queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="myQueue" />
我已将activemq-all-5.12.0.jar放在Tomcat7共享库文件夹中。我还在Web应用程序META-INF文件夹下的context.xml文件中创建了相关的引用,并在web.xml中创建了一个额外的度量资源-ref(在这里基本上抓住了吸管)
我的观察:当我启动触发与ActiveMQ通信的操作时,我在日志文件中看到以下条目:
2016-07-19 10:40:07,659 [system ] DEBUG WireFormatNegotiator - Sending: WireFormatInfo { version=11, properties={MaxFrameSize=9223372036854775807, CacheSize=1024, CacheEnabled=true, Host=10.173.80.42, SizePrefixDisabled=false, MaxInactivityDurationInitalDelay=10000, TcpNoDelayEnabled=true, MaxInactivityDuration=30000, TightEncodingEnabled=true, StackTraceEnabled=true}, magic=[A,c,t,i,v,e,M,Q]}
2016-07-19 10:40:07,666 [.42:61619@45620] DEBUG InactivityMonitor - Using min of local: WireFormatInfo { version=11, properties={MaxFrameSize=9223372036854775807, CacheSize=1024, CacheEnabled=true, Host=10.173.80.42, SizePrefixDisabled=false, MaxInactivityDurationInitalDelay=10000, TcpNoDelayEnabled=true, MaxInactivityDuration=30000, TightEncodingEnabled=true, StackTraceEnabled=true}, magic=[A,c,t,i,v,e,M,Q]} and remote: WireFormatInfo { version=10, properties={CacheSize=1024, MaxFrameSize=9223372036854775807, CacheEnabled=true, SizePrefixDisabled=false, TcpNoDelayEnabled=true, MaxInactivityDurationInitalDelay=10000, MaxInactivityDuration=30000, TightEncodingEnabled=true, StackTraceEnabled=true}, magic=[A,c,t,i,v,e,M,Q]}
2016-07-19 10:40:07,667 [.42:61619@45620] DEBUG WireFormatNegotiator - Received WireFormat: WireFormatInfo { version=10, properties={CacheSize=1024, MaxFrameSize=9223372036854775807, CacheEnabled=true, SizePrefixDisabled=false, TcpNoDelayEnabled=true, MaxInactivityDurationInitalDelay=10000, MaxInactivityDuration=30000, TightEncodingEnabled=true, StackTraceEnabled=true}, magic=[A,c,t,i,v,e,M,Q]}
2016-07-19 10:40:07,667 [.42:61619@45620] DEBUG WireFormatNegotiator - tcp:///10.173.80.42:61619@45620 before negotiation: OpenWireFormat{version=11, cacheEnabled=false, stackTraceEnabled=false, tightEncodingEnabled=false, sizePrefixDisabled=false, maxFrameSize=9223372036854775807}
2016-07-19 10:40:07,668 [.42:61619@45620] DEBUG WireFormatNegotiator - tcp:///10.173.80.42:61619@45620 after negotiation: OpenWireFormat{version=10, cacheEnabled=true, stackTraceEnabled=true, tightEncodingEnabled=true, sizePrefixDisabled=false, maxFrameSize=9223372036854775807}
2016-07-19 10:40:08,834 [WriteCheckTimer] DEBUG AbstractInactivityMonitor - WriteChecker: 10000ms elapsed since last write check.
2016-07-19 10:40:08,836 [yMonitor Worker] DEBUG AbstractInactivityMonitor - Running WriteCheck[tcp://10.173.80.42:61619]
2016-07-19 10:40:08,834 [WriteCheckTimer] DEBUG AbstractInactivityMonitor - WriteChecker: 10000ms elapsed since last write check.
2016-07-19 10:40:08,836 [yMonitor Worker] DEBUG AbstractInactivityMonitor - Running WriteCheck[tcp://10.173.80.42:61619]
2016-07-19 10:40:18,835 [WriteCheckTimer] DEBUG AbstractInactivityMonitor - WriteChecker: 10000ms elapsed since last write check.
2016-07-19 10:40:18,835 [yMonitor Worker] DEBUG AbstractInactivityMonitor - Running WriteCheck[tcp://10.173.80.42:61619]
2016-07-19 10:40:27,667 [WriteCheckTimer] DEBUG AbstractInactivityMonitor - WriteChecker: 10000ms elapsed since last write check.
2016-07-19 10:40:27,668 [yMonitor Worker] DEBUG AbstractInactivityMonitor - Running WriteCheck[tcp://10.173.80.42:61619]
2016-07-19 10:40:28,813 [ ReadCheckTimer] DEBUG AbstractInactivityMonitor - 30000ms elapsed since last read check.
2016-07-19 10:40:28,834 [WriteCheckTimer] DEBUG AbstractInactivityMonitor - WriteChecker: 10000ms elapsed since last write check.
2016-07-19 10:40:28,834 [yMonitor Worker] DEBUG AbstractInactivityMonitor - Running WriteCheck[tcp://10.173.80.42:61619]
2016-07-19 10:40:37,667 [WriteCheckTimer] DEBUG AbstractInactivityMonitor - WriteChecker: 10000ms elapsed since last write check.
2016-07-19 10:40:37,668 [yMonitor Worker] DEBUG AbstractInactivityMonitor - Running WriteCheck[tcp://10.173.80.42:61619]
2016-07-19 10:40:38,834 [WriteCheckTimer] DEBUG AbstractInactivityMonitor - WriteChecker: 10000ms elapsed since last write check.
2016-07-19 10:40:38,835 [yMonitor Worker] DEBUG AbstractInactivityMonitor - Running WriteCheck[tcp://10.173.80.42:61619]
2016-07-19 10:40:47,667 [ ReadCheckTimer] DEBUG AbstractInactivityMonitor - 30000ms elapsed since last read check.
另外,当我查看我的队列的EnqueueCount和DequeueCount时,我发现它们没有改变。
由于日志表明我的Tomcat7容器实际上从远程实例接收了信息(参考“Received Wireformat:...”),因此可以传达这两个实例。但为什么我无法发送数据?
附录:部署在承载ActiveMQ的Tomee实例中的相同Web应用程序可以与队列无缝通信。
感谢任何关于我可能做错的想法,或者我可以在Tomee和Tomcat7端尝试的选项。
提前致谢!
答案 0 :(得分:0)
在花费了不少时间试图让上述配置工作之后,原来是:
无论如何,所有这些都排序了,这就是我找到的:
上面提到的配置工作正常,ActiveMQ配置为作为Tomee容器的一部分运行,并且Tomcat7上的Connection代理作为全局共享资源暴露给部署在其中的WebApps(知道你的JNDI!)。 p>
我也可以使用@ JonathanS.Fisher建议的配置。我能够将ActiveMQ作为独立实例启动,并将我的应用程序托管在Tomcat7和Tomee上。
希望这有助于任何陷入类似情况的人。
干杯