目前,我正在使用apache camel和wmq。对于骆驼的配置和路由,我使用的是Java DSL。但是我找不到任何有关如何使用Java DSL配置WMQ的示例。
这是我尝试配置WMQ时得到的信息:
config.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:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" default-init-method="init" xmlns:util="http://www.springframework.org/schema/util" xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xs http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
<import resource="classpath:/META-INF/spring/components.xml"/>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="jms:LQ.SERVICEPROVIDER.CAMEL.SERVICEBUS"/>
<setHeader headerName="ID">
<xpath resultType="java.lang.Integer">//id</xpath>
</setHeader>
<setHeader headerName="FIRSTNAME">
<xpath resultType="java.lang.String">//vorname</xpath>
</setHeader>
<setHeader headerName="LASTNAME">
<xpath resultType="java.lang.String">//nachname</xpath>
</setHeader>
<to uri="sql:insert into USERS (ID, FIRSTNAME, LASTNAME, BEARBEITET) values (:#ID, :#FIRSTNAME, :#LASTNAME, TRUE)"/>
</route>
</camelContext>
</beans>
component.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:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" default-init-method="init" xmlns:util="http://www.springframework.org/schema/util" xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xs http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
<!-- ************************************************************************** -->
<!-- *************** JMS - Configuration *************** -->
<!-- ************************************************************************** -->
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsCachedConnectionFactory" />
<property name="exceptionListener" ref="jmsCachedConnectionFactory" />
<property name="transacted" value="true"/>
<property name="transactionManager" ref="txManager" />
</bean>
<bean id="jmsCachedConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
<property name="targetConnectionFactory" ref="jmsConnectionFactory" />
<property name="sessionCacheSize" value="15" />
</bean>
<bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="channel" value="${mq.prod.channel}" />
<property name="hostName" value="${mq.prod.host}" />
<property name="port" value="${mq.prod.port}" />
<property name="queueManager" value="${mq.prod.manager}" />
<property name="transportType" value="1" />
</bean>
<bean id="txManager" class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory" ref="jmsCachedConnectionFactory" />
</bean>
但是,正如我之前所说,我不想使用Spring对其进行配置。我更喜欢使用Java DSL。是否有可能?如果可以,请给我一些例子或参考资料吗?
非常感谢您的帮助。谢谢。
首先,我建议将其视为关于如何将骆驼与Websphere MQ集成的教程。希望能对您有所帮助。
相反,我认为您应该阅读以下链接,这些链接对于使用Websphere MQ或其他JMS实现而不是ActiveMQ有一些好的建议。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句