Apache camel 与 rabbitmq 集成。

我想实现一个功能,在做完数据库操作后,将操作内容作为消息发送到rabbitmq队列中去。
学习了一下Apache camel ,不是很懂,要如何在数据库操作以后启动camel来发送消息,网上查找资料有代码的方式和xml配置两种方式,

from("").to("rabbitmq://localhost:5672/myexchange?username=guest&password=guest&queue=userQueue")
<bean id="customConnectionFactory" class="com.rabbitmq.client.ConnectionFactory">
        <property name="host" value="xx.xx.xx.xx"  />
        <property name="port"  value="5672"/>
        <property name="username" value="guest" />
        <property name="password" value="guest" />
    </bean>

    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">                        
         <route>
            <from uri=""/>
            <to uri="rabbitmq://xx.xx.xx.xx:5672/myexchange?connectionFactory=#customConnectionFactory"/>
          </route>
    </camelContext>

这里的from中应该怎么调用?

如果是xml配置的方式,我要如何使它跟随spring一起启动,我已经添加了camel.xml文件并关联,但是好像不生效

阅读 2.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题