首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >阿克卡骆驼与春天

阿克卡骆驼与春天
EN

Stack Overflow用户
提问于 2015-09-23 02:31:39
回答 2查看 602关注 0票数 7

我想结合Akka,Apache,Spring,并且不知道如何在同一个项目中利用这三种东西。

我成功地

代码语言:javascript
复制
1. write some working code with akka, akka-camel extension and camel routes(Java DSL)
2. use camel and spring (use java DSL but spring for transactions and etc..)

现在我需要把1和2结合起来。有人能建议我实现这一点的最简单的方法吗?

编辑有人说AKKA不再支持为什么akka的spring集成文档只存在于1.3.1,而不存在于下一个版本,因为为什么akka的spring集成文档只存在于1.3.1,而不存在于下一个版本下面的链接中的对象实例化存在冲突

此外,也有一个类似的问题,没有适当的解决方案,但该职位是大约2年前的akka-camel 2.2.1使用Spring定义路由

在一篇博客文章(我现在无法获得链接)中,描述了一种方法,概括地说,参与者被定义并使用Akka方式,以及处理Akka参与者时使用Spring所做的事情。但没有任何确凿的例子。

EN

回答 2

Stack Overflow用户

发布于 2015-10-06 14:16:00

我想你的2号看起来是这样的:

代码语言:javascript
复制
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:ctx="http://www.springframework.org/schema/context"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd >

  <!-- Camel route configuration -->
    <camelContext id = "testCamelRouteContext" xmlns="http://camel.apache.org/schema/spring">
        <route id="test_data_webservice">
            <from uri="jetty:http://localhost:8888/myTestService"/>
            <log logName="HTTP LOG" loggingLevel="INFO" message="HTTP REQUEST: ${in.header.testdata}"/>
            <process ref="myTestService"/>
        </route>
    </camelContext>

    <context:annotation-config />

    <bean class="com.package.service" id="myTestService"/>

        <bean id="genericDao" class="com.dao.Impl">
        <property name="dataSource" ref="datasource" />
    </bean>

    <bean id="testingDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        datasource stuff
    </bean>
</beans>

你有可能通过Akka获得这个骆驼的上下文吗?就像。

添加您的Akka配置:

代码语言:javascript
复制
akka.camel.context-provider="myNewContext"

新的ContextProvider类:

代码语言:javascript
复制
class myNewContext extends ContextProvider{
    override def getContext(system: ExtendedActorSystem): SpringCamelHybridContext
}

我猜这就是Spring和Akka之间的bean注入冲突可能发生的地方。我以前从未使用过Akka,所以我的回答是微不足道的,但我想看看我是否能为您提供一些帮助。

票数 1
EN

Stack Overflow用户

发布于 2016-09-13 06:34:37

复活了一根旧线。

阿克卡-斯普林克斯-骆驼图书馆是为了让您的生活无痛的集成阿克卡,春天,骆驼,CXF等。

添加人工制品:

代码语言:javascript
复制
<dependency>
   <groupId>com.github.PuspenduBanerjee</groupId>
   <artifactId>akka-springctx-camel</artifactId>
   <version>1.0.0</version>
</dependency>

在Akka配置中添加Camel上下文提供程序:

代码语言:javascript
复制
akka.camel.context-provider=system.SpringCamelContextProvider

获取ActorSystem:

代码语言:javascript
复制
implicit val system = SpringContextActorSystemProvider.create

创建一个自定义的RouteBuilderother方式可以是Akka

代码语言:javascript
复制
class CustomRouteBuilder(system: ActorSystem, echoActor: ActorRef)
  extends RouteBuilder {
  def configure {
    from("direct:testEP")
      .routeId("test-route")
      .to(echoActor)

  }

获取Camel(Spring)上下文并向其添加路由:

代码语言:javascript
复制
val camel = CamelExtension(system)
    camel.context.addRoutes(
         new CustomRouteBuilder(system, system.actorOf(Props[EchoActor])))

这个测试用例将给您一个详细的想法:https://github.com/PuspenduBanerjee/akka-springctx-camel/blob/master/src/test/scala/AkkaSpringCtxTestSpec.scala

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32730031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档