I'm currently following the akka-camel integration example in http://doc.akka.io/docs/akka/snapshot/scala/camel.html.
As transport I'm using jetty:http, like
class Orders extends Actor with Producer {
def endpointUri = "jetty:http://localhost:8877/"
}
same for the endpoint
class MyEndpoint extends Consumer {
def endpointUri = "jetty:http://0.0.0.0:8877/"
def receive = {
case msg: CamelMessage => { println("here", msg ); sender ! "ok"}
case _ => { println("somewhere else") }
}
}
All works fine when sending simple text-messages like
val sys = ActorSystem("some-system")
val orders = sys.actorOf(Props[Orders])
val endp = sys.actorOf(Props[MyEndpoint])
orders ? "hello"
But things do not work when sending Case-Classes
case class B(id:String)
orders ? B("hello")
The output states an error with the TypeConversion
akka.camel.AkkaCamelException: No type converter available to convert from type: de.spring.cases.infrastructure.SerializationSpec.B to the required type: java.io.InputStream with value B(hello) ...
Caused by:
org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: de.spring.cases.infrastructure.SerializationSpec.B to the required type: java.io.InputStream with value B(hello) at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:169) at org.apache.camel.component.jetty.JettyHttpProducer.createHttpExchange(JettyHttpProducer.java:135) at org.apache.camel.component.jetty.JettyHttpProducer.process(JettyHttpProducer.java:75) at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73) at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:122) at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298) at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:117) at akka.camel.ProducerSupport$ProducerChild.produce(Producer.scala:137) at akka.camel.ProducerSupport$ProducerChild$$anonfun$receive$1.applyOrElse(Producer.scala:111) ... 9 more
When using an explicit (own) serialization/deserialization between the Object and Array[Byte], things go well.
I read about Camels TypeConversions and wonder, if there is an internal way how to transcode the messages from/to serializable objects. And seeing the recipient side, it would be great to use the messages directly using the 'normal' scala pattern matching in the receive function. Without any additional dispatching using additional fields and manual transcoding.
Any suggestions?