camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAMEL-6025) NumberFormatException when using File over JMS
Date Fri, 01 Feb 2013 14:52:12 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-6025?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13568769#comment-13568769
] 

Claus Ibsen commented on CAMEL-6025:
------------------------------------

Chris, this is a good idea, to keep the modification date as just the long which we get from
the java file API.
                
> NumberFormatException when using File over JMS
> ----------------------------------------------
>
>                 Key: CAMEL-6025
>                 URL: https://issues.apache.org/jira/browse/CAMEL-6025
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.10.2
>            Reporter: Chris Watts
>            Assignee: Claus Ibsen
>
> When using the FileConsumer to send a file to a JMS queue which is then consumed by the
FileProducer I get the following error:
> {noformat}
> 11:03:22,778 DEBUG [Camel (camel) thread #1 - JmsConsumer[queue1]] (MarkerIgnoringBase.java:72)
- Failed delivery for (MessageId: queue_queue1_ID_xxxxxxxxx-1911-1359590595842-3_4_1_1_1 on
ExchangeId: ID-xxxxxxxxx-1910-1359590595467-0-10). On delivery attempt: 0 caught: org.apache.camel.TypeConversionException:
Error during type conversion from type: java.lang.String to the required type: java.lang.Long
with value Thu Jan 31 11:03:22 EST 2013 due java.lang.NumberFormatException: For input string:
"Thu Jan 31 11:03:22 EST 2013"{noformat}
> This is due to a Date being converted to a String when sending over JMS.
> Propose that the following line in Generic file be changed from:
> {code}            if (getLastModified() > 0) {
>                 message.setHeader(Exchange.FILE_LAST_MODIFIED, new Date(getLastModified()));
>             }{code}
> To:{code}            if (getLastModified() > 0) {
>                 message.setHeader(Exchange.FILE_LAST_MODIFIED, getLastModified());
>             }{code}
> As FileOperations can use it:
> {code}    private void keepLastModified(Exchange exchange, File file) {
>         if (endpoint.isKeepLastModified()) {
>             Long last;
>             Date date = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Date.class);
>             if (date != null) {
>                 last = date.getTime();
>             } else {
>                 // fallback and try a long
>                 last = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);
>             }
>             if (last != null) {
>                 boolean result = file.setLastModified(last);
>                 if (LOG.isTraceEnabled()) {
>                     LOG.trace("Keeping last modified timestamp: {} on file: {} with result:
{}", new Object[]{last, file, result});
>                 }
>             }
>         }
>     }{code}
> Sample route:
> {code:xml}
> <route>
> 	<from uri="file:/tmp/input/"/>
> 	<to uri="activemq:queue:test"/>
> </route>
> <route>
> 	<from uri="activemq:queue:test"/>
> 	<to uri="file:/tmp/output/?keepLastModified=true"/>
> </route>
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message