目前我正在使用apache camel和wmq。对于camel配置和路由,我使用的是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。可能吗?如果是的话,请给我一些例子或参考资料吗?
非常感谢您的帮助。感谢。
答案 0 :(得分:1)
首先,我建议将this作为关于如何将camel与websphere MQ集成的教程。希望它可以提供帮助。
我认为您应该阅读以下链接,其中有关于使用Websphere MQ或其他JMS实现而不是ActiveMQ的一些好建议。