新手 : ActiveMQ with Camel

编程入门 行业动态 更新时间:2024-10-25 11:20:57
本文介绍了新手 : ActiveMQ with Camel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我对这个话题很陌生,需要一些解释......

我们有一个正在运行的 ActiveMQ-Server,现在应该使用 Apache Camel 路由和处理来增强它.我们的整个配置都是基于 XML 的.

我的第一个方法是在我们的 activemq.xml 的末尾做一个简单的 <import resource="camel.xml">,但这似乎是错误的路径.>

这些是当前的传输连接器:

<!-- DOS 保护,将并发连接数限制为 1000,帧大小限制为 100MB --><transportConnector name="openwire" uri="tcp://localdev:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="amqp" uri="amqp://localdev:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="stomp" uri="stomp://localdev:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="mqtt" uri="mqtt://localdev:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="ws" uri="ws://localdev:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="mqtt+ws" uri="ws://localdev:1884?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/><transportConnector name="vm" uri="vm://localdev"/></transportConnectors>

这是我们的camel.xml:

无论我进行什么配置,消息都不会从主题路由到队列,我会收到日志消息:

Broker localhost 未启动,因此使用 localdev连接器 vm://localhost 启动

我是否采用了错误的方法?

非常感谢任何帮助

问题可能在于使用 RuntimeConfigurationPlugin 从 kahadb alogn 加载了大量持久主题吗?加载和创建所有主题需要一段时间,特别是将 log4j 设置为调试.此外,RuntimeConfigurationPlugin 要求代理在初始化期间设置start=false".请参阅此处

解决方案

your import <import resource="camel.xml"/> 必须在 broker 和 beans 元素之间,如果camel.xmlactivemq.xml 位于同一文件夹中:

 </broker><import resource="camel.xml"/></豆类>

尝试删除 <import resource="camel.xml"/> 并将 camel.xml 的内容直接添加到 activemq.xml 通过删除 元素:

 </broker><camelContext id="camel" xmlns="http://camel.apache/schema/spring"depends-on="broker-localdev" ><route id="devRawMap"><description>重定向测试消息</description><来自 uri="activemq:topic:alpha.topic.DEV.INTERNAL.*.RAW"/><to uri="activemq:queue:alpha.queue.DEV"/></路线><route id="liveMap"><description>重定向实时数据</description><from uri="activemq:topic:devRoot.topic.LIVE.*.RAW"/><to uri="activemq:queue:devRoot.queue.LIVE"/></路线></camelContext><bean id="activemq" class="org.apache.activemq.camelponent.ActiveMQComponent" ><属性名称="connectionFactory"><bean class="org.apache.activemq.ActiveMQConnectionFactory"><property name="brokerURL" value="tcp://localhost:61616"/><property name="userName" value="user"/><property name="password" value="pass"/></bean></属性></bean></豆类>

I'm pretty new to this topic and need some explanation...

We have a running ActiveMQ-Server, which should now be enhanced with Apache Camel routing and processing. Our whole configuration is XML based.

My first approach was to do a plain <import resource="camel.xml"> at the end of our activemq.xml, but this seems to be the wrong path.

These are the current transortConnectors:

<transportConnectors>
    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
    <transportConnector name="openwire" uri="tcp://localdev:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://localdev:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://localdev:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://localdev:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://localdev:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt+ws" uri="ws://localdev:1884?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="vm" uri="vm://localdev" />
</transportConnectors>

And this is our camel.xml:

<beans
        xmlns="http://www.springframework/schema/beans"
        xmlns:xsi="http://www.w3/2001/XMLSchema-instance"
        xsi:schemaLocation="
     http://camel.apache/schema/spring http://camel.apache/schema/spring/camel-spring.xsd
     http://www.springframework/schema/beans http://www.springframework/schema/beans/spring-beans.xsd">

    <camelContext id="camel" depends-on="broker-localdev" xmlns="http://camel.apache/schema/spring">
        <route id="devRawMap">
            <description>Redirect for test message</description>
            <from uri="activemq:topic:alpha.topic.DEV.INTERNAL.*.RAW"/>
            <to uri="activemq:queue:alpha.queue.DEV"/>
        </route>
        <route id="liveMap">
            <description>Redirect for Live data</description>
            <from uri="activemq:topic:devRoot.topic.LIVE.*.RAW"/>
            <to uri="activemq:queue:devRoot.queue.LIVE"/>
        </route>
    </camelContext>

    <bean id="activemq" class="org.apache.activemq.camelponent.ActiveMQComponent" >
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL" value="vm://localdev?create=false"/>
                <property name="userName" value="user"/>
                <property name="password" value="pass"/>
            </bean>
        </property>
    </bean>
</beans>

Whatever configuration I make, the messages are not routed from topic to queue and I get the log messages:

Broker localhost not started so using localdev instead
Connector vm://localhost started

Am I following the wrong approach to this?

Any help is highly appreciated

[EDIT 01]

Is the problem maybe in having alot of persisted topics beingh loaded from kahadb alogn with using the RuntimeConfigurationPlugin? It takes a while until all topics are loaded and created, especial with having log4j set to debug. Furthermore the RuntimeConfigurationPlugin requires the broker to set "start=false" during init. see here

解决方案

your import <import resource="camel.xml"/> must be between broker and beans elements like this if the camel.xml is in the same folder than activemq.xml :

    </broker> 
    <import resource="camel.xml"/> 
</beans>

try by removing <import resource="camel.xml"/> and adding directly the content of camel.xml to the activemq.xml by removing <beans> element :

    </broker> 
    <camelContext id="camel" xmlns="http://camel.apache/schema/spring"  depends-on="broker-localdev" >
        <route id="devRawMap">
            <description>Redirect for test message</description>
            <from uri="activemq:topic:alpha.topic.DEV.INTERNAL.*.RAW"/>
            <to uri="activemq:queue:alpha.queue.DEV"/>
        </route>
        <route id="liveMap">
            <description>Redirect for Live data</description>
            <from uri="activemq:topic:devRoot.topic.LIVE.*.RAW"/>
            <to uri="activemq:queue:devRoot.queue.LIVE"/>
        </route>
    </camelContext>

    <bean id="activemq" class="org.apache.activemq.camelponent.ActiveMQComponent" >
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL" value="tcp://localhost:61616"/>
                <property name="userName" value="user"/>
                <property name="password" value="pass"/>
            </bean>
        </property>
    </bean>
</beans>

这篇关于新手 : ActiveMQ with Camel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-19 22:21:11,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:新手   ActiveMQ   Camel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!