2015-09-23 9 views
6

私はAkka、Apache Camel、Springを組み合わせたいと思っています。同じプロジェクトで3つのものを活用する方法を知りません。Akka Camelと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、誰もが私にこれを達成する最も簡単な方法を提案することができますを結合する必要がありますか?

EDIT いくつかはまた、同様の質問が適切な解決策が提示されずに存在しているが、ポストは約2であるアッカは、もはや Why spring integration doc for akka exists only for 1.3.1 but not for next versions

下のリンクごとに起因するオブジェクトのインスタンス化の紛争に春をサポートして言いません年齢は akka-camel 2.2.1 route definition using Spring XML

(私はリンクをすぐに取得することはできません)要約されている方法では、アクターが定義され、Akkaの方法を使用して、俳優たちはSpringを使用して配線されます。しかし、実例はありませんでした。

+0

をあなたがなぜ投票していないのかについてもコメントしてください。このコメントは役に立ちそうです。 – SashikaXP

答えて

1

私はあなたの#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.camel.context-provider="myNewContext" 

新ContextProviderクラス:

class myNewContext extends ContextProvider{ 
    override def getContext(system: ExtendedActorSystem): SpringCamelHybridContext 
} 

私は春とAkkaの間豆注入衝突が発生する可能性があるところ、これは推測しています。私は前にAkkaを使ったことがないので、私の答えは簡単ですが、私はあなたに何か助けを与えることができるかどうかを見たいと思っていました。

0

古いスレッドを復活させる。

akka-springctx-camelライブラリAkka、Spring、Camel、CXFなどを統合するためにあなたの人生を苦労させるためにそこにあります。

アーティファクトを追加します。

<dependency> 
    <groupId>com.github.PuspenduBanerjee</groupId> 
    <artifactId>akka-springctx-camel</artifactId> 
    <version>0.0.5</version> 
</dependency> 

は、アッカの設定でキャメル・コンテキスト・プロバイダを追加します。

akka.camel.context-provider=system.SpringCamelContextProvider 

ActorSystemのホールドを取得:

implicit val system = SpringContextActorSystemProvider.create 

をRouteBuilder [他の方法は、可能性がカスタムを作成します。 Akka Consumer]

class CustomRouteBuilder(system: ActorSystem, echoActor: ActorRef) 
    extends RouteBuilder { 
    def configure { 
    from("direct:testEP") 
     .routeId("test-route") 
     .to(echoActor) 

    } 

キャメル(春)コンテキストを取得し、それへのルートを追加します。

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

関連する問題