任何幫助將不勝感激。我試圖用spring JMSListener創建一個MDB的替代品。我希望目標名稱作爲註釋傳遞,但我注意到org.springframework.jms.listener.DefaultMessageListenerContainer
容器配置有destinationName
或destination
爲必填項。我錯過了什麼嗎?如何利用目標解析器使用來自@JmsListener
註釋的隊列名稱?如何使Spring JMS從註釋中選擇目標隊列名稱@JmsListener
@Component
public class InitStRspnLstnr {
@JmsListener(destination = "${xyz.company.MQ.INITST.RSPN.FADS.Q}")
public void onMessage(Message msg) throws JMSException {
System.out.println("**********************************************"+msg);
}}
下面是我的XML粘貼,我評論的容器就目前來看,春季以來試圖連接到虛擬隊列,而不是一個在註解..
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
">
<import resource="classpath*:com/xyz/svc/component.xml"/>
<mvc:annotation-driven enable-matrix-variables="true"/>
<context:component-scan base-package="com.xyz.css.rplr.initst"></context:component-scan>
<!-- WebSphere MQ Connection setup start -->
<bean id="mqIdsConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName"><value>${xyz.company.MQ.HOST.NM}</value></property>
<property name="port"><value>${xyz.company.MQ.PORT}</value></property>
<property name="queueManager"><value>${xyz.company.MQ.QMNGR}</value></property>
<property name="channel"><value>${xyz.company.MQ.CHANNEL}</value></property>
<property name="CCSID"><value>819</value></property>
<property name="transportType">
<util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP" />
</property>
</bean>
<bean id="jmsQueueIdsConnectionFactory"
class="org.springframework.jms.connection.SingleConnectionFactory">
<property name="targetConnectionFactory">
<ref bean="mqIdsConnectionFactory" />
</property>
</bean>
<bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination.DynamicDestinationResolver">
</bean>
<bean id="jmsQueueIdsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="jmsQueueIdsConnectionFactory" />
</property>
<property name="destinationResolver">
<ref bean="jmsDestinationResolver" />
</property> <!--
<property name="defaultDestinationName">
<value>${xyz.company.MQ.INITST.Q}</value>
</property>-->
<property name="pubSubDomain">
<value>false</value>
</property>
<property name="receiveTimeout">
<value>20000</value>
</property>
</bean>
<!-- <bean id="jmsContainer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory">
<ref bean="jmsQueueIdsConnectionFactory" />
</property>
<property name="destinationResolver">
<ref bean="jmsDestinationResolver" />
</property>
<property name="destinationName" value="dummyQueue"/>
<property name="concurrency" value="3-10" />
</bean> -->
<!-- WebSphere MQ Connection setup end -->
</beans>
對於初學者來說,首先正確配置的東西。您沒有任何內容可用於基於註釋的JMS支持。就像[參考指南]中所解釋的那樣(https://docs.spring.io/spring/docs/current/spring-framework-reference/html/jms.html#jms-annotated-support)。 –
得到它的工作....感謝指出它..我已經嘗試它,並缺少一個罐子。 ' <豆ID = 「jmsListenerContainerFactory」 類= 「org.springframework.jms.config.DefaultJmsListenerContainerFactory」> \t \t <屬性名= 「connectionFactory的」> \t \t \t \t \t \t \t <屬性名= 「DestinationResolver的」> \t \t \t \t \t \t \t <屬性名=「併發」值=「3-10」 /> ' – Jugunu
@Jugunu你應該張貼一個答案與你沒有解決您的問題是什麼細節你自己的問題,這將是格式化比沒有格式化的評論好得多。 – JoshMc