Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
scala 2.10,akka骆驼tcp套接字通信_Scala_Apache Camel_Akka - Fatal编程技术网

scala 2.10,akka骆驼tcp套接字通信

scala 2.10,akka骆驼tcp套接字通信,scala,apache-camel,akka,Scala,Apache Camel,Akka,我正在寻找一些简单而简短的示例,介绍如何使用tcp套接字进行连接和交互(两种方式)。换句话说,如何编写scala 2.10应用程序(使用akka camel或netty库)与tcp进程(套接字)通信 我在网上找到了很多文献,但都是旧的(寻找scala 2.10)和/或不推荐的 提前谢谢 我想你已经检查过Akka文档了吧 在Akka 2.1.0中,他们改进了Akka camel模块,使其完全更新(以前有点过时) 还有一个camel akka视频演示,介绍了一个真实的使用案例:嗯,我在找这样的东西:

我正在寻找一些简单而简短的示例,介绍如何使用tcp套接字进行连接和交互(两种方式)。换句话说,如何编写scala 2.10应用程序(使用akka camel或netty库)与tcp进程(套接字)通信

我在网上找到了很多文献,但都是旧的(寻找scala 2.10)和/或不推荐的


提前谢谢

我想你已经检查过Akka文档了吧

在Akka 2.1.0中,他们改进了Akka camel模块,使其完全更新(以前有点过时)


还有一个camel akka视频演示,介绍了一个真实的使用案例:

嗯,我在找这样的东西:

1。服务器:

import akka.actor._
import akka.camel.{ Consumer, CamelMessage }

class Ser extends Consumer {
  def endpointUri = "mina2:tcp://localhost:9002"
  def receive = {
    case message: CamelMessage => {
     //log
     println("looging, question:" + message)
     sender ! "server response to request: " + message.bodyAs[String] + ", is NO"
     }
   case _ => println("I got something else!??!!")
  }
}

object server extends App {

val system = ActorSystem("some")
val spust = system.actorOf(Props[Ser])
}
 import akka.actor._
 import akka.camel._
 import akka.pattern.ask
 import scala.concurrent.duration._
 import akka.util.Timeout
 import scala.concurrent.Await

 class Producer1 extends Actor with Producer {
   def endpointUri = "mina2:tcp://localhost:9002"
  }

 object Client extends App {

 implicit val timeout = Timeout(10 seconds)
 val system2 = ActorSystem("some-system")
 val producer = system2.actorOf(Props[Producer1])
 val future = producer.ask("Hello, can I go to cinema?")

 val result = Await.result(future, timeout.duration)
 println("Is future over?="+future.isCompleted+";;result="+result)

 println("Ende!!!")
 system2.shutdown
 println("system2 ended:"+system2.isTerminated)
2。客户:

import akka.actor._
import akka.camel.{ Consumer, CamelMessage }

class Ser extends Consumer {
  def endpointUri = "mina2:tcp://localhost:9002"
  def receive = {
    case message: CamelMessage => {
     //log
     println("looging, question:" + message)
     sender ! "server response to request: " + message.bodyAs[String] + ", is NO"
     }
   case _ => println("I got something else!??!!")
  }
}

object server extends App {

val system = ActorSystem("some")
val spust = system.actorOf(Props[Ser])
}
 import akka.actor._
 import akka.camel._
 import akka.pattern.ask
 import scala.concurrent.duration._
 import akka.util.Timeout
 import scala.concurrent.Await

 class Producer1 extends Actor with Producer {
   def endpointUri = "mina2:tcp://localhost:9002"
  }

 object Client extends App {

 implicit val timeout = Timeout(10 seconds)
 val system2 = ActorSystem("some-system")
 val producer = system2.actorOf(Props[Producer1])
 val future = producer.ask("Hello, can I go to cinema?")

 val result = Await.result(future, timeout.duration)
 println("Is future over?="+future.isCompleted+";;result="+result)

 println("Ende!!!")
 system2.shutdown
 println("system2 ended:"+system2.isTerminated)

我知道这一切都是用英语写的,描述得很好。但是,如果您是新手,您需要阅读所有内容并多次阅读,以便构建非常简单的客户机-服务器应用程序。我认为某种“激励榜样”会非常受欢迎。

你能澄清这个问题吗?您提到了akka camel,那么这是基于akka的应用程序吗?如果你想使用Netty,障碍是什么?Netty是基于Java的,所以它完全独立于Scala版本。我更喜欢基于骆驼的解决方案(但如果你知道netty的例子,我也可以)。@sourcedelica看看我对Claus回答的评论实际上,我有一个输入错误-这里是链接:。它是为Akka IO.yep设计的,我当然发现了,但它似乎也过时了(例如:组件mina在几年前被mina2替换了…),所以您需要很多时间来查找所有问题并将代码片段组合在一起。不过,您的第二个链接看起来很有用-谢谢!我看到你是骆驼队的投手,看看我的回答:,我们来添加一些简单的例子吧?你需要让Akka团队来做这件事。这是他们的项目和文件AAAA现在我明白了-你是为骆驼工作的,不是阿克卡来的。好的,我会写的。无论如何,谢谢你的时间!!!