我正在研究Spring應用程序,我們已經實現了通過IBM MQ發送消息的代碼。IBM MQ vs JMS - Spring實現
現在我們已建議不要直接直接使用MQ API,而應使用JMS。我跟着
的步驟:
創建的JNDI名稱來連接到消息隊列配置爲:
<bean id="emailQueueDestination" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true"> <property name="jndiName" value="<<JNDI name of Queue" >>/> </bean>
我需要一個connecton工廠對象連接到JMS提供者和我已將其配置爲:
<bean id="emailQueueConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory"> <property name="queueManager" value="" /> <property name="hostName" value="" /> <property name="channel" value="" /> <property name="port" value="1414" /> </bean>
而且我已經注入上述2種豆在JmsTemplate類:
<bean id="emailQueueTemplate" class="org.springframework.jms.core.JmsTemplate" lazy-init="true">
<property name="connectionFactory" ref="emailQueueConnectionFactory" />
<property name="defaultDestination" ref="emailQueueDestination" />
</bean>
現在,因爲我的目的是消除對MQ API的依賴,你覺得以上(特別是連接工廠)看起來很不錯的配置?
那麼,你的問題到底是什麼?「它看起來不錯嗎?」其實並不是一個真正的問題 –
嗨..我的問題是上面的實現是否使我的代碼獨立於IBM MQ。如果IBM MQ將來會被其他任何技術所取代,那麼這段代碼就可以工作 – user966506