You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Scarpacci <mi...@gmail.com> on 2015/04/28 05:47:00 UTC

TypeConversion Error

Hi All,

I am using akka-camel to process files. My initial tests were working great,
however when I started passing in actual xml files it is puking with type
conversions.

Here is my consumer (very simple, but puking at msg.bodyAs[String]

class FileConsumer extends Consumer {
  def endpointUri = "file:/data/input/actor"

  val processor = context.actorOf(Props[Processor], "processor")

  def receive = {
    case msg: CamelMessage => {
      println("Parent...received %s" format msg)
      processor ! msg.bodyAs[String]
    }
  }
}

*[ERROR*] [04/27/2015 12:10:48.617]
[ArdisSystem-akka.actor.default-dispatcher-5] [akka://ArdisSystem/user/$a]
Error during type conversion from type:
org.apache.camel.converter.stream.FileInputStreamCache to the required type:
java.lang.String with value
org.apache.camel.converter.stream.FileInputStreamCache@4611b35a due
java.io.FileNotFoundException:
/var/folders/dh/zfqvn9gn7cl6h63d3400y4zxp3xtzf/T/camel-tmp-807558/cos2920459202139947606.tmp
(No such file or directory)
org.apache.camel.TypeConversionException: Error during type conversion from
type: org.apache.camel.converter.stream.FileInputStreamCache to the required
type: java.lang.String with value
org.apache.camel.converter.stream.FileInputStreamCache@4611b35a due
java.io.FileNotFoundException:
/var/folders/dh/zfqvn9gn7cl6h63d3400y4zxp3xtzf/T/camel-tmp-807558/cos2920459202139947606.tmp
(No such file or directory)


I am wondering if it has something to do with the actual contents of the
xml. They are not big at all (roughly 70kb). I doubt I will be able to
provide an actual example of the XML itself. Just baffled as to why
something so small and being converted to a string is having issues. Other
dummy example xml files have worked fine.




--
View this message in context: http://camel.465427.n5.nabble.com/TypeConversion-Error-tp5766411.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: TypeConversion Error

Posted by Scarpacci <mi...@gmail.com>.
Hi Willem,

Finally figured it out.  I had to set the CachedOuptutStream.Threshold to
greater than the default.  

  camel.context.getProperties.put(CachedOutputStream.THRESHOLD, "750000");

It was not clear at all that this was the case because of the conversion
error...thanks for all your help!

S



--
View this message in context: http://camel.465427.n5.nabble.com/TypeConversion-Error-tp5766411p5766529.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: TypeConversion Error

Posted by Willem Jiang <wi...@gmail.com>.
Can you try to disable the stream cache and try again?

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On April 28, 2015 at 9:23:51 PM, Scarpacci (mike.giardinelli@gmail.com) wrote:
> Hi Willem,
>  
> Thanks for your response. I can tell that it is using the StreamCache and
> even applied the setting in the context, but it is still failing. I added
> more of the debug output to hopefully shed some more light on the problem.
> I am a camel newbie, so there is a good chance that this is user error.
>  
> *Additional Debug Logs:*
>  
> 06:18:46.315 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG o.a.c.component.file.FileConsumer  
> - About to process file:
> GenericFile[/Users/dev/data/input/actor/BackgroundFull.txt] using exchange:  
> Exchange[BackgroundFull.txt]
> 06:18:46.324 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG o.a.c.c.file.GenericFileConverter  
> - Read file /Users/dev/data/input/actor/BackgroundFull.txt (no charset)
> 06:18:46.335 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG o.a.camel.processor.SendProcessor  
> - >>>>
> Endpoint[akka://ArdisSystem/user/$a?autoAck=true&replyTimeout=60000+milliseconds]  
> Exchange[Message: [Body is instance of org.apache.camel.StreamCache]]
> 06:18:46.341 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -  
> Retrying attempt 0 to delete file:
> /var/folders/dh/zfqvn9gn7cl6h63d3400y4zxp3xtzf/T/camel-tmp-214819/cos1926967760124850497.tmp  
> 06:18:46.341 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -  
> Tried 1 to delete file:
> /var/folders/dh/zfqvn9gn7cl6h63d3400y4zxp3xtzf/T/camel-tmp-214819/cos1926967760124850497.tmp  
> with result: true
> 06:18:46.343 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG
> o.a.c.c.file.GenericFileOnCompletion - Done processing file:
> GenericFile[/Users/dev/data/input/actor/BackgroundFull.txt] using exchange:  
> Exchange[Message: [Body is instance of org.apache.camel.StreamCache]]
> 06:18:46.343 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -  
> Retrying attempt 0 to delete file:
> /Users/dev/data/input/actor/BackgroundFull.txt.camelLock
> 06:18:46.343 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -  
> Tried 1 to delete file:
> /Users/dev/data/input/actor/BackgroundFull.txt.camelLock with result: true  
> 06:18:46.344 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -  
> Retrying attempt 0 to delete file:
> /Users/dev/data/input/actor/.camel/BackgroundFull.txt
> 06:18:46.344 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -  
> Tried 1 to delete file:
> /Users/dev/data/input/actor/.camel/BackgroundFull.txt with result: true
> 06:18:46.344 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG
> o.a.c.c.f.s.GenericFileRenameProcessStrategy - Renaming file:
> GenericFile[/Users/dev/data/input/actor/BackgroundFull.txt] to:
> GenericFile[/Users/dev/data/input/actor/.camel/BackgroundFull.txt]
> 06:18:46.344 [Camel (ArdisSystem) thread #0 -
> file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -  
> Tried 1 to rename file: /Users/dev/data/input/actor/BackgroundFull.txt to:
> /Users/dev/data/input/actor/.camel/BackgroundFull.txt with result: true
> [ERROR] [04/28/2015 06:18:46.349]
> [ArdisSystem-akka.actor.default-dispatcher-3] [akka://ArdisSystem/user/$a]  
> Error during type conversion from type:
> org.apache.camel.converter.stream.FileInputStreamCache to the required type:  
> java.lang.String with value
> org.apache.camel.converter.stream.FileInputStreamCache@39d38328 due
> java.io.IOException: Stream closed
> org.apache.camel.TypeConversionException: Error during type conversion from
> type: org.apache.camel.converter.stream.FileInputStreamCache to the required  
> type: java.lang.String with value
> org.apache.camel.converter.stream.FileInputStreamCache@39d38328 due
> java.io.IOException: Stream closed
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/TypeConversion-Error-tp5766411p5766427.html  
> Sent from the Camel - Users mailing list archive at Nabble.com.
>  


Re: TypeConversion Error

Posted by Scarpacci <mi...@gmail.com>.
Hi Willem,

Thanks for your response.  I can tell that it is using the StreamCache and
even applied the setting in the context, but it is still failing.  I added
more of the debug output to hopefully shed some more light on the problem. 
I am a camel newbie, so there is a good chance that this is user error. 

*Additional Debug Logs:*

06:18:46.315 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG o.a.c.component.file.FileConsumer
- About to process file:
GenericFile[/Users/dev/data/input/actor/BackgroundFull.txt] using exchange:
Exchange[BackgroundFull.txt]
06:18:46.324 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG o.a.c.c.file.GenericFileConverter
- Read file /Users/dev/data/input/actor/BackgroundFull.txt (no charset)
06:18:46.335 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG o.a.camel.processor.SendProcessor
- >>>>
Endpoint[akka://ArdisSystem/user/$a?autoAck=true&replyTimeout=60000+milliseconds]
Exchange[Message: [Body is instance of org.apache.camel.StreamCache]]
06:18:46.341 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -
Retrying attempt 0 to delete file:
/var/folders/dh/zfqvn9gn7cl6h63d3400y4zxp3xtzf/T/camel-tmp-214819/cos1926967760124850497.tmp
06:18:46.341 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -
Tried 1 to delete file:
/var/folders/dh/zfqvn9gn7cl6h63d3400y4zxp3xtzf/T/camel-tmp-214819/cos1926967760124850497.tmp
with result: true
06:18:46.343 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG
o.a.c.c.file.GenericFileOnCompletion - Done processing file:
GenericFile[/Users/dev/data/input/actor/BackgroundFull.txt] using exchange:
Exchange[Message: [Body is instance of org.apache.camel.StreamCache]]
06:18:46.343 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -
Retrying attempt 0 to delete file:
/Users/dev/data/input/actor/BackgroundFull.txt.camelLock
06:18:46.343 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -
Tried 1 to delete file:
/Users/dev/data/input/actor/BackgroundFull.txt.camelLock with result: true
06:18:46.344 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -
Retrying attempt 0 to delete file:
/Users/dev/data/input/actor/.camel/BackgroundFull.txt
06:18:46.344 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -
Tried 1 to delete file:
/Users/dev/data/input/actor/.camel/BackgroundFull.txt with result: true
06:18:46.344 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG
o.a.c.c.f.s.GenericFileRenameProcessStrategy - Renaming file:
GenericFile[/Users/dev/data/input/actor/BackgroundFull.txt] to:
GenericFile[/Users/dev/data/input/actor/.camel/BackgroundFull.txt]
06:18:46.344 [Camel (ArdisSystem) thread #0 -
file:///Users/dev/data/input/actor] DEBUG org.apache.camel.util.FileUtil -
Tried 1 to rename file: /Users/dev/data/input/actor/BackgroundFull.txt to:
/Users/dev/data/input/actor/.camel/BackgroundFull.txt with result: true
[ERROR] [04/28/2015 06:18:46.349]
[ArdisSystem-akka.actor.default-dispatcher-3] [akka://ArdisSystem/user/$a]
Error during type conversion from type:
org.apache.camel.converter.stream.FileInputStreamCache to the required type:
java.lang.String with value
org.apache.camel.converter.stream.FileInputStreamCache@39d38328 due
java.io.IOException: Stream closed
org.apache.camel.TypeConversionException: Error during type conversion from
type: org.apache.camel.converter.stream.FileInputStreamCache to the required
type: java.lang.String with value
org.apache.camel.converter.stream.FileInputStreamCache@39d38328 due
java.io.IOException: Stream closed



--
View this message in context: http://camel.465427.n5.nabble.com/TypeConversion-Error-tp5766411p5766427.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: TypeConversion Error

Posted by Willem Jiang <wi...@gmail.com>.
It looks like camel just remove the temp cached file when you want to send the message to the other processor.

You can setup the camel property to change the CamelCachedOutputStreamThreshold property[1] of camel context to a big value.
  
[1]http://camel.apache.org/stream-caching.html

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On April 28, 2015 at 12:37:22 PM, Scarpacci (mike.giardinelli@gmail.com) wrote:
> Hi All,
>  
> I am using akka-camel to process files. My initial tests were working great,
> however when I started passing in actual xml files it is puking with type
> conversions.
>  
> Here is my consumer (very simple, but puking at msg.bodyAs[String]
>  
> class FileConsumer extends Consumer {
> def endpointUri = "file:/data/input/actor"
>  
> val processor = context.actorOf(Props[Processor], "processor")
>  
> def receive = {
> case msg: CamelMessage => {
> println("Parent...received %s" format msg)
> processor ! msg.bodyAs[String]
> }
> }
> }
>  
> *[ERROR*] [04/27/2015 12:10:48.617]
> [ArdisSystem-akka.actor.default-dispatcher-5] [akka://ArdisSystem/user/$a]  
> Error during type conversion from type:
> org.apache.camel.converter.stream.FileInputStreamCache to the required type:  
> java.lang.String with value
> org.apache.camel.converter.stream.FileInputStreamCache@4611b35a due
> java.io.FileNotFoundException:
> /var/folders/dh/zfqvn9gn7cl6h63d3400y4zxp3xtzf/T/camel-tmp-807558/cos2920459202139947606.tmp  
> (No such file or directory)
> org.apache.camel.TypeConversionException: Error during type conversion from
> type: org.apache.camel.converter.stream.FileInputStreamCache to the required  
> type: java.lang.String with value
> org.apache.camel.converter.stream.FileInputStreamCache@4611b35a due
> java.io.FileNotFoundException:
> /var/folders/dh/zfqvn9gn7cl6h63d3400y4zxp3xtzf/T/camel-tmp-807558/cos2920459202139947606.tmp  
> (No such file or directory)
>  
>  
> I am wondering if it has something to do with the actual contents of the
> xml. They are not big at all (roughly 70kb). I doubt I will be able to
> provide an actual example of the XML itself. Just baffled as to why
> something so small and being converted to a string is having issues. Other
> dummy example xml files have worked fine.
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/TypeConversion-Error-tp5766411.html  
> Sent from the Camel - Users mailing list archive at Nabble.com.
>