Hello,

I am trying to use a simple Akka Camel Producer that sends some gzip data 
to the Camel File Component, however I am finding an exception because 
internally it is also trying to produce a BoxedUnit to the component and 
the component does not know how to handle an object of type BoxedUnit. I 
have some code to replicate the issue. Maybe the issue is with my code and 
there is a bug. Any help would be appreciated. Here is the code:

import java.io.ByteArrayOutputStream
import java.util.zip.GZIPOutputStream

import akka.actor.{ActorSystem, Props}
import akka.camel.{CamelMessage, Producer}
import org.scalatest.{Matchers, WordSpecLike}

/**
  * Created by hecortiz on 7/25/16.
  */
class ProducerTest extends WordSpecLike with Matchers {

  "Producer" should {
    "produce" in {
      val system = ActorSystem("Test")
      val producer = 
system.actorOf(CamelMessageProducer.props("file:./output"), "producer")

      val data = "This is some test data"

      val obj = new ByteArrayOutputStream()
      val gzip = new GZIPOutputStream(obj)
      gzip.write(data.getBytes("UTF-8"))
      gzip.close()

      val gzipBytes = obj.toByteArray
      obj.close()

      val camelMessage = CamelMessage(gzipBytes, Map())

      producer ! camelMessage

      Thread.sleep(1000)
    }
  }

}

object CamelMessageProducer {
  def props(uri: String) = Props(new CamelMessageProducer(uri))
}

class CamelMessageProducer(uri: String) extends Producer {
  def endpointUri = uri

  override def transformOutgoingMessage(msg: Any) = {
    println(s"${msg.getClass}")
  }
}

And here is the exception I am getting:

Testing started at 1:24 PM ...
class akka.camel.CamelMessage
13:24:34.933 [Test-akka.actor.default-dispatcher-3] ERROR 
akka.actor.OneForOneStrategy - Cannot store file: 
./output/ID-61111-1469471074666-0-1
akka.camel.AkkaCamelException: Cannot store file: 
./output/ID-61111-1469471074666-0-1
at 
akka.camel.ProducerSupport$$anonfun$produce$1.applyOrElse(Producer.scala:73) 
~[akka-camel_2.11-2.4.7.jar:?]
at akka.actor.Actor$class.aroundReceive(Actor.scala:484) 
~[akka-actor_2.11-2.4.7.jar:?]
at some.package.CamelMessageProducer.aroundReceive(ProducerTest.scala:44) 
~[test-classes/:?]
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526) 
[akka-actor_2.11-2.4.7.jar:?]
at akka.actor.ActorCell.invoke(ActorCell.scala:495) 
[akka-actor_2.11-2.4.7.jar:?]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257) 
[akka-actor_2.11-2.4.7.jar:?]
at akka.dispatch.Mailbox.run(Mailbox.scala:224) 
[akka-actor_2.11-2.4.7.jar:?]
at akka.dispatch.Mailbox.exec(Mailbox.scala:234) 
[akka-actor_2.11-2.4.7.jar:?]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) 
[scala-library-2.11.7.jar:?]
at 
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
 
[scala-library-2.11.7.jar:?]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) 
[scala-library-2.11.7.jar:?]
at 
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
 
[scala-library-2.11.7.jar:?]
Caused by: 
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot 
store file: ./output/ID-61111-1469471074666-0-1
at 
org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:346)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:277)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:165)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:79)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
 
~[camel-core-2.17.1.jar:2.17.1]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) 
~[camel-core-2.17.1.jar:2.17.1]
at akka.camel.ProducerSupport$ProducerChild.produce(Producer.scala:137) 
~[akka-camel_2.11-2.4.7.jar:?]
at 
akka.camel.ProducerSupport$ProducerChild$$anonfun$receive$1.applyOrElse(Producer.scala:111)
 
~[akka-camel_2.11-2.4.7.jar:?]
at akka.actor.Actor$class.aroundReceive(Actor.scala:484) 
~[akka-actor_2.11-2.4.7.jar:?]
at 
akka.camel.ProducerSupport$ProducerChild.aroundReceive(Producer.scala:108) 
~[akka-camel_2.11-2.4.7.jar:?]
... 9 more
Caused by: org.apache.camel.InvalidPayloadException: No body available of 
type: java.io.InputStream but has value: () of type: 
scala.runtime.BoxedUnit on: Message[ID-61111-1469471074666-0-1]. Caused by: 
No type converter available to convert from type: scala.runtime.BoxedUnit 
to the required type: java.io.InputStream with value (). Exchange[]. Caused 
by: [org.apache.camel.NoTypeConversionAvailableException - No type 
converter available to convert from type: scala.runtime.BoxedUnit to the 
required type: java.io.InputStream with value ()]
at 
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:107) 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:325)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:277)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:165)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:79)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
 
~[camel-core-2.17.1.jar:2.17.1]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) 
~[camel-core-2.17.1.jar:2.17.1]
at akka.camel.ProducerSupport$ProducerChild.produce(Producer.scala:137) 
~[akka-camel_2.11-2.4.7.jar:?]
at 
akka.camel.ProducerSupport$ProducerChild$$anonfun$receive$1.applyOrElse(Producer.scala:111)
 
~[akka-camel_2.11-2.4.7.jar:?]
at akka.actor.Actor$class.aroundReceive(Actor.scala:484) 
~[akka-actor_2.11-2.4.7.jar:?]
at 
akka.camel.ProducerSupport$ProducerChild.aroundReceive(Producer.scala:108) 
~[akka-camel_2.11-2.4.7.jar:?]
... 9 more
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type 
converter available to convert from type: scala.runtime.BoxedUnit to the 
required type: java.io.InputStream with value ()
at 
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:198)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:105) 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:325)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:277)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:165)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:79)
 
~[camel-core-2.17.1.jar:2.17.1]
at 
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
 
~[camel-core-2.17.1.jar:2.17.1]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145) 
~[camel-core-2.17.1.jar:2.17.1]
at akka.camel.ProducerSupport$ProducerChild.produce(Producer.scala:137) 
~[akka-camel_2.11-2.4.7.jar:?]
at 
akka.camel.ProducerSupport$ProducerChild$$anonfun$receive$1.applyOrElse(Producer.scala:111)
 
~[akka-camel_2.11-2.4.7.jar:?]
at akka.actor.Actor$class.aroundReceive(Actor.scala:484) 
~[akka-actor_2.11-2.4.7.jar:?]
at 
akka.camel.ProducerSupport$ProducerChild.aroundReceive(Producer.scala:108) 
~[akka-camel_2.11-2.4.7.jar:?]
... 9 more

Thanks!

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to