問題陳述:我尋求幫助的JMS連接工廠暴露在遠程ActiveMQ的實例(監聽TCP)作爲Tomcat7容器資源,使Web應用程序部署在Tomcat7可以訪問它。Tomcat配置連接到遠程的ActiveMQ實例
我的配置:我有一個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" />
我已經在Tomcat7共享庫文件夾中放置了activemq-all-5.12.0.jar。我還在Web應用程序META-INF文件夾下的context.xml文件中創建了相關引用,並在web.xml中爲添加的度量創建了資源引用(此處主要抓取吸管)
我的觀察 :當我啓動,觸發器使用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:[email protected]] 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:[email protected]] 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:[email protected]] DEBUG WireFormatNegotiator - tcp:///10.173.80.42:[email protected] before negotiation: OpenWireFormat{version=11, cacheEnabled=false, stackTraceEnabled=false, tightEncodingEnabled=false, sizePrefixDisabled=false, maxFrameSize=9223372036854775807}
2016-07-19 10:40:07,668 [.42:[email protected]] DEBUG WireFormatNegotiator - tcp:///10.173.80.42:[email protected] 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結束。
在此先感謝!
爲什麼不只是運行一個獨立的經紀人?你已經連接外部 –
@ JonathanS.Fisher,是的,這是一個選項,我也在研究它。但是,從理論上講,上述設置也應該起作用。使用基於Tomee的隊列的另一個原因是因爲Tomee容器託管了一個MDB驅動的服務,該服務與Queue一起工作良好。有關可能導致上述問題的任何想法? – deepthought