Apache Camel:是否可以在不使用 Spring 的情况下配置 WMQ? [英] Apache Camel: Is it possible to configure WMQ without using Spring?

查看:37
本文介绍了Apache Camel:是否可以在不使用 Spring 的情况下配置 WMQ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在使用 apache camel 和 wmq.对于骆驼配置和路由,我使用的是 Java DSL.但是我找不到任何关于如何使用 Java DSL 配置 WMQ 的示例.

这是我尝试配置 WMQ 时得到的结果:

<块引用>

配置文件

<import resource="classpath:/META-INF/spring/components.xml"/><camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"><路线><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) 值 (:#ID, :#FIRSTNAME, :#LASTNAME, TRUE)"/></路线></camelContext></豆类>

<块引用>

组件.xml

<!-- ******************************************************************************** --><!-- *************** JMS - 配置 *************** --><!-- ******************************************************************************** --><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.是否可以?如果是的话,你能给我一些例子或参考吗?

非常感谢您的帮助.谢谢.

解决方案

首先我提议看this 作为关于如何将骆驼与 websphere MQ 集成的教程.希望它能有所帮助.

相反,我认为您应该阅读以下链接,其中有一些关于使用 Websphere MQ 或其他 JMS 实现而不是 ActiveMQ 的好建议.

  1. http://camel.apache.org/jms.html
  2. http://java.dzone.com/articles/apache-camel-tutorial-eip
  3. http://camel.465427.n5.nabble.com/Error-when-using-Camel-write-to-Websphere-MQ-td5727817.html
  4. http://camel.465427.n5.nabble.com/IBM-MQ-and-CAMEL-td5591661.html
  5. http://camel.465427.n5.nabble.com/Can-Camel-communicate-over-IBM-MQ-sender-receiver-channels-td4429050.html
  6. 将 Apache ServiceMix 连接到 Websphere MQ

currently I am working with apache camel and wmq. For the camel configuration and routing, I am using Java DSL. But I could not find any example about how to configure WMQ by using Java DSL.

Here is what I get when I tried to configure 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>

But, as I said before I dont want to use Spring to configure it. I prefer to use Java DSL. Is it possible? If yes could you please give me some example or references?

Your help is so much appreciated. Thanks.

解决方案

First I propose to see this as tutorial about how to integrate camel with websphere MQ. Hope it can help.

Instead of this I think you should read following links which there are some good advice about using Websphere MQ or another JMS implementation rather than ActiveMQ.

  1. http://camel.apache.org/jms.html
  2. http://java.dzone.com/articles/apache-camel-tutorial-eip
  3. http://camel.465427.n5.nabble.com/Error-when-using-Camel-write-to-Websphere-MQ-td5727817.html
  4. http://camel.465427.n5.nabble.com/IBM-MQ-and-CAMEL-td5591661.html
  5. http://camel.465427.n5.nabble.com/Can-Camel-communicate-over-IBM-MQ-sender-receiver-channels-td4429050.html
  6. Connecting Apache ServiceMix to Websphere MQ

这篇关于Apache Camel:是否可以在不使用 Spring 的情况下配置 WMQ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆