我想结合Akka,Apache,Spring,并且不知道如何在同一个项目中利用这三种东西。
我成功地
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所做的事情。但没有任何确凿的例子。
发布于 2015-10-06 14:16:00
我想你的2号看起来是这样的:
<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配置:
akka.camel.context-provider="myNewContext"新的ContextProvider类:
class myNewContext extends ContextProvider{
override def getContext(system: ExtendedActorSystem): SpringCamelHybridContext
}我猜这就是Spring和Akka之间的bean注入冲突可能发生的地方。我以前从未使用过Akka,所以我的回答是微不足道的,但我想看看我是否能为您提供一些帮助。
发布于 2016-09-13 06:34:37
复活了一根旧线。
阿克卡-斯普林克斯-骆驼图书馆是为了让您的生活无痛的集成阿克卡,春天,骆驼,CXF等。
添加人工制品:
<dependency>
<groupId>com.github.PuspenduBanerjee</groupId>
<artifactId>akka-springctx-camel</artifactId>
<version>1.0.0</version>
</dependency>在Akka配置中添加Camel上下文提供程序:
akka.camel.context-provider=system.SpringCamelContextProvider获取ActorSystem:
implicit val system = SpringContextActorSystemProvider.create创建一个自定义的RouteBuilderother方式可以是Akka
class CustomRouteBuilder(system: ActorSystem, echoActor: ActorRef)
extends RouteBuilder {
def configure {
from("direct:testEP")
.routeId("test-route")
.to(echoActor)
}获取Camel(Spring)上下文并向其添加路由:
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
https://stackoverflow.com/questions/32730031
复制相似问题