You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mikael Andersson Wigander <mi...@pm.me.INVALID> on 2021/05/19 13:12:45 UTC

File filter bean not working in Camel 3

Hi
In Camel 2.x we have a file component with a filter bean and now migrating to Camel 3 the bean is not found and program crashes upon start.
The migration has been only with the route converting to use EndpointRoutebuilder, the config, bean and class is unchanged.

Config

@Bean

public static

HouseKeepingFileFilter

<

String

>

houseKeepingFileFilter

() {

return new

HouseKeepingFileFilter

<>()

;

}

Impl

@CommonsLog

public class

HouseKeepingFileFilter

<T>

implements

GenericFileFilter

<

String

> {

public boolean

accept

(

GenericFile

file) {

SimpleDateFormat

sdf

=

new

SimpleDateFormat

(

"yyyy-MM-dd HH:mm:ss"

)

;

final boolean

isValid

=

file

.

isDirectory

()

?

true

:

file

.

getLastModified

()

<

LocalDateTime

.

now

()

.

minusMonths

(1L)

.

atZone

(

ZoneId

.

systemDefault

())

.

toInstant

()

.

toEpochMilli

()

;

log

.

trace

(

MessageFormat

.

format

(

"File :{0}, with modification date: {1} is {2} for archive"

,

file

.

getFileName

()

,

sdf

.

format

(file

.

getLastModified

())

,

isValid

?

"valid"

:

"NOT valid"

))

;

return

isValid

;

}

}

Camel 3

@Override

public void

configure

()

throws

Exception

{

from

(

file

(

"mifir/"

)

.

antInclude

(

"{{housekeeping.files.include}}"

)

.

antExclude

(

"**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}"

)

.

recursive

(

true

)

.

filter

(

"#houseKeepingFileFilter"

)

.

scheduler

(

"quartz"

)

.

schedulerProperties

(

"cron"

,

"{{housekeeping.cron}}"

)

.

schedulerProperties

(

"triggerId"

,

"houseKeepingId"

)

.

schedulerProperties

(

"triggerGroup"

,

"houseKeepingGroup"

))

.

description

(

"HOUSEKEEPING-ROUTE"

,

"Archive files older than a month"

,

"en"

)

.

process

(s

->

{

long

houseKeepingSize

=

0L

;

final

Message

in

=

s

.

getIn

()

;

try

{

houseKeepingSize

=

in

.

getHeader

(

"HouseKeepingSize"

,

Long

.

class

)

;

}

catch

(

Exception

ignored) {

}

final

File

body

=

in

.

getBody

(

File

.

class

)

;

houseKeepingSize

+=

body

.

length

()

;

in

.

setHeader

(

"HouseKeepingSize"

,

houseKeepingSize

)

;

})

.

aggregate

(

constant

(

true

)

,

new

ZipAggregationStrategy

(

true

))

.

to

(

log

(

"HouseKeeping"

)

.

level

(

"INFO"

)

.

groupInterval

(5_000L)

.

groupActiveOnly

(

true

))

.

completionFromBatchConsumer

()

.

eagerCheckCompletion

()

.

to

(

file

(

"mifir/archive"

))

.

log

(

"Monthly housekeeping is done! Archived ${exchangeProperty.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes"

)

.

end

()

;

}

Camel 2

@Override

public void

configure

()

throws

Exception

{

from

(

"file:mifir/"

+

"?antInclude={{housekeeping.files.include}}"

+

"&antExclude=**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}"

+

"&recursive=true"

+

"&filter=#houseKeepingFileFilter"

+

"&scheduler=quartz2"

+

"&scheduler.cron={{housekeeping.cron}}"

+

"&scheduler.triggerId=houseKeepingId"

+

"&scheduler.triggerGroup=houseKeepingGroup"

)

.

description

(

"HOUSEKEEPING-ROUTE"

,

"Archive files older than a month"

,

"en"

)

.

process

(s

->

{

long

houseKeepingSize

=

0L

;

final

Message

in

=

s

.

getIn

()

;

try

{

houseKeepingSize

=

in

.

getHeader

(

"HouseKeepingSize"

,

Long

.

class

)

;

}

catch

(

Exception

ignored) {

}

final

File

body

=

in

.

getBody

(

File

.

class

)

;

houseKeepingSize

+=

body

.

length

()

;

in

.

setHeader

(

"HouseKeepingSize"

,

houseKeepingSize

)

;

})

.

aggregate

(

constant

(

true

)

,

new

ZipAggregationStrategy

(

true

))

.

to

(

"log:HouseKeeping?level=INFO&groupInterval=5000&groupActiveOnly=true"

)

.

completionFromBatchConsumer

()

.

eagerCheckCompletion

()

.

to

(

"file:mifir/archive"

)

.

log

(

"Monthly housekeeping is done! Archived ${property.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes"

)

.

end

()

;

}

Read the migration guide but not finding any clues…

From Camel 2.25.3 to 3.6.0

/M

Re: File filter bean not working in Camel 3

Posted by Mikael Andersson Wigander <mi...@pm.me.INVALID>.
Camel 3
====================
@Override
public void configure() throws Exception {
from(file("mifir/")
.antInclude("{{housekeeping.files.include}}")
.antExclude(
"**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}")
.recursive(true)
.filter("#houseKeepingFileFilter")
.scheduler("quartz")
.schedulerProperties("cron", "{{housekeeping.cron}}")
.schedulerProperties("triggerId", "houseKeepingId")
.schedulerProperties("triggerGroup", "houseKeepingGroup"))
.description("HOUSEKEEPING-ROUTE", "Archive files older than a month", "en")
.process(s -> {
long houseKeepingSize = 0L;
final Message in = s.getIn();
try {
houseKeepingSize = in.getHeader("HouseKeepingSize", Long.class);
} catch (Exception ignored) {
}
final File body = in.getBody(File.class);
houseKeepingSize += body.length();
in.setHeader("HouseKeepingSize", houseKeepingSize);
})
.aggregate(constant(true), new ZipAggregationStrategy(true))
.to(log("HouseKeeping").level("INFO").groupInterval(5_000L).groupActiveOnly(true))
.completionFromBatchConsumer()
.eagerCheckCompletion()
.to(file("mifir/archive"))
.log(
"Monthly housekeeping is done! Archived ${exchangeProperty.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes")
.end();
}

Config
====================
@Bean
public static HouseKeepingFileFilter<String> houseKeepingFileFilter() {
return new HouseKeepingFileFilter<>();
}

Impl
====================
@CommonsLog
public class HouseKeepingFileFilter<T> implements GenericFileFilter<String> {
public boolean accept(GenericFile file) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

final boolean isValid = file.isDirectory() ? true : file.getLastModified() < LocalDateTime.now()
.minusMonths(1L)
.atZone(ZoneId.systemDefault())
.toInstant()
.toEpochMilli();
log.trace(MessageFormat.format("File :{0}, with modification date: {1} is {2} for archive",
file.getFileName(),
sdf.format(file.getLastModified()),
isValid ? "valid" : "NOT valid"));

return isValid;
}
}

Camel 2
========================
@Override
public void configure() throws Exception {
from("file:mifir/" +
"?antInclude={{housekeeping.files.include}}" +
"&antExclude=**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}" +
"&recursive=true" +
"&filter=#houseKeepingFileFilter" +
"&scheduler=quartz2" +
"&scheduler.cron={{housekeeping.cron}}" +
"&scheduler.triggerId=houseKeepingId" +
"&scheduler.triggerGroup=houseKeepingGroup")
.description("HOUSEKEEPING-ROUTE", "Archive files older than a month", "en")
.process(s -> {
long houseKeepingSize = 0L;
final Message in = s.getIn();
try {
houseKeepingSize = in.getHeader("HouseKeepingSize", Long.class);
} catch (Exception ignored) {
}
final File body = in.getBody(File.class);
houseKeepingSize += body.length();
in.setHeader("HouseKeepingSize", houseKeepingSize);
})
.aggregate(constant(true), new ZipAggregationStrategy(true))
.to("log:HouseKeeping?level=INFO&groupInterval=5000&groupActiveOnly=true")
.completionFromBatchConsumer()
.eagerCheckCompletion()
.to("file:mifir/archive")
.log(
"Monthly housekeeping is done! Archived ${property.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes")
.end();
}

Missed information about JVM: 1.8 is used

also tried to upgrade to 3.7.0 but still same issue

/M

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, May 19th, 2021 at 15:14, Andrea Cosentino <an...@gmail.com> wrote:

> It's not possible to read the code.
>
> I would migrate to an LTS 3.7.x and not to 3.6.0, this is the first suggestion I have.
>
> Il giorno mer 19 mag 2021 alle ore 15:13 Mikael Andersson Wigander <mi...@pm.me.invalid> ha scritto:
>
>> Hi
>> In Camel 2.x we have a file component with a filter bean and now migrating to Camel 3 the bean is not found and program crashes upon start.
>> The migration has been only with the route converting to use EndpointRoutebuilder, the config, bean and class is unchanged.
>>
>> Config
>>
>> @Bean
>>
>> public static
>>
>> HouseKeepingFileFilter
>>
>> <
>>
>> String
>>
>>>
>>
>> houseKeepingFileFilter
>>
>> () {
>>
>> return new
>>
>> HouseKeepingFileFilter
>>
>> <>()
>>
>> ;
>>
>> }
>>
>> Impl
>>
>> @CommonsLog
>>
>> public class
>>
>> HouseKeepingFileFilter
>>
>> <T>
>>
>> implements
>>
>> GenericFileFilter
>>
>> <
>>
>> String
>>
>>> {
>>
>> public boolean
>>
>> accept
>>
>> (
>>
>> GenericFile
>>
>> file) {
>>
>> SimpleDateFormat
>>
>> sdf
>>
>> =
>>
>> new
>>
>> SimpleDateFormat
>>
>> (
>>
>> "yyyy-MM-dd HH:mm:ss"
>>
>> )
>>
>> ;
>>
>> final boolean
>>
>> isValid
>>
>> =
>>
>> file
>>
>> .
>>
>> isDirectory
>>
>> ()
>>
>> ?
>>
>> true
>>
>> :
>>
>> file
>>
>> .
>>
>> getLastModified
>>
>> ()
>>
>> <
>>
>> LocalDateTime
>>
>> .
>>
>> now
>>
>> ()
>>
>> .
>>
>> minusMonths
>>
>> (1L)
>>
>> .
>>
>> atZone
>>
>> (
>>
>> ZoneId
>>
>> .
>>
>> systemDefault
>>
>> ())
>>
>> .
>>
>> toInstant
>>
>> ()
>>
>> .
>>
>> toEpochMilli
>>
>> ()
>>
>> ;
>>
>> log
>>
>> .
>>
>> trace
>>
>> (
>>
>> MessageFormat
>>
>> .
>>
>> format
>>
>> (
>>
>> "File :{0}, with modification date: {1} is {2} for archive"
>>
>> ,
>>
>> file
>>
>> .
>>
>> getFileName
>>
>> ()
>>
>> ,
>>
>> sdf
>>
>> .
>>
>> format
>>
>> (file
>>
>> .
>>
>> getLastModified
>>
>> ())
>>
>> ,
>>
>> isValid
>>
>> ?
>>
>> "valid"
>>
>> :
>>
>> "NOT valid"
>>
>> ))
>>
>> ;
>>
>> return
>>
>> isValid
>>
>> ;
>>
>> }
>>
>> }
>>
>> Camel 3
>>
>> @Override
>>
>> public void
>>
>> configure
>>
>> ()
>>
>> throws
>>
>> Exception
>>
>> {
>>
>> from
>>
>> (
>>
>> file
>>
>> (
>>
>> "mifir/"
>>
>> )
>>
>> .
>>
>> antInclude
>>
>> (
>>
>> "{{housekeeping.files.include}}"
>>
>> )
>>
>> .
>>
>> antExclude
>>
>> (
>>
>> "**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}"
>>
>> )
>>
>> .
>>
>> recursive
>>
>> (
>>
>> true
>>
>> )
>>
>> .
>>
>> filter
>>
>> (
>>
>> "#houseKeepingFileFilter"
>>
>> )
>>
>> .
>>
>> scheduler
>>
>> (
>>
>> "quartz"
>>
>> )
>>
>> .
>>
>> schedulerProperties
>>
>> (
>>
>> "cron"
>>
>> ,
>>
>> "{{housekeeping.cron}}"
>>
>> )
>>
>> .
>>
>> schedulerProperties
>>
>> (
>>
>> "triggerId"
>>
>> ,
>>
>> "houseKeepingId"
>>
>> )
>>
>> .
>>
>> schedulerProperties
>>
>> (
>>
>> "triggerGroup"
>>
>> ,
>>
>> "houseKeepingGroup"
>>
>> ))
>>
>> .
>>
>> description
>>
>> (
>>
>> "HOUSEKEEPING-ROUTE"
>>
>> ,
>>
>> "Archive files older than a month"
>>
>> ,
>>
>> "en"
>>
>> )
>>
>> .
>>
>> process
>>
>> (s
>>
>> ->
>>
>> {
>>
>> long
>>
>> houseKeepingSize
>>
>> =
>>
>> 0L
>>
>> ;
>>
>> final
>>
>> Message
>>
>> in
>>
>> =
>>
>> s
>>
>> .
>>
>> getIn
>>
>> ()
>>
>> ;
>>
>> try
>>
>> {
>>
>> houseKeepingSize
>>
>> =
>>
>> in
>>
>> .
>>
>> getHeader
>>
>> (
>>
>> "HouseKeepingSize"
>>
>> ,
>>
>> Long
>>
>> .
>>
>> class
>>
>> )
>>
>> ;
>>
>> }
>>
>> catch
>>
>> (
>>
>> Exception
>>
>> ignored) {
>>
>> }
>>
>> final
>>
>> File
>>
>> body
>>
>> =
>>
>> in
>>
>> .
>>
>> getBody
>>
>> (
>>
>> File
>>
>> .
>>
>> class
>>
>> )
>>
>> ;
>>
>> houseKeepingSize
>>
>> +=
>>
>> body
>>
>> .
>>
>> length
>>
>> ()
>>
>> ;
>>
>> in
>>
>> .
>>
>> setHeader
>>
>> (
>>
>> "HouseKeepingSize"
>>
>> ,
>>
>> houseKeepingSize
>>
>> )
>>
>> ;
>>
>> })
>>
>> .
>>
>> aggregate
>>
>> (
>>
>> constant
>>
>> (
>>
>> true
>>
>> )
>>
>> ,
>>
>> new
>>
>> ZipAggregationStrategy
>>
>> (
>>
>> true
>>
>> ))
>>
>> .
>>
>> to
>>
>> (
>>
>> log
>>
>> (
>>
>> "HouseKeeping"
>>
>> )
>>
>> .
>>
>> level
>>
>> (
>>
>> "INFO"
>>
>> )
>>
>> .
>>
>> groupInterval
>>
>> (5_000L)
>>
>> .
>>
>> groupActiveOnly
>>
>> (
>>
>> true
>>
>> ))
>>
>> .
>>
>> completionFromBatchConsumer
>>
>> ()
>>
>> .
>>
>> eagerCheckCompletion
>>
>> ()
>>
>> .
>>
>> to
>>
>> (
>>
>> file
>>
>> (
>>
>> "mifir/archive"
>>
>> ))
>>
>> .
>>
>> log
>>
>> (
>>
>> "Monthly housekeeping is done! Archived ${exchangeProperty.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes"
>>
>> )
>>
>> .
>>
>> end
>>
>> ()
>>
>> ;
>>
>> }
>>
>> Camel 2
>>
>> @Override
>>
>> public void
>>
>> configure
>>
>> ()
>>
>> throws
>>
>> Exception
>>
>> {
>>
>> from
>>
>> (
>>
>> "file:mifir/"
>>
>> +
>>
>> "?antInclude={{housekeeping.files.include}}"
>>
>> +
>>
>> "&antExclude=**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}"
>>
>> +
>>
>> "&recursive=true"
>>
>> +
>>
>> "&filter=#houseKeepingFileFilter"
>>
>> +
>>
>> "&scheduler=quartz2"
>>
>> +
>>
>> "&scheduler.cron={{housekeeping.cron}}"
>>
>> +
>>
>> "&scheduler.triggerId=houseKeepingId"
>>
>> +
>>
>> "&scheduler.triggerGroup=houseKeepingGroup"
>>
>> )
>>
>> .
>>
>> description
>>
>> (
>>
>> "HOUSEKEEPING-ROUTE"
>>
>> ,
>>
>> "Archive files older than a month"
>>
>> ,
>>
>> "en"
>>
>> )
>>
>> .
>>
>> process
>>
>> (s
>>
>> ->
>>
>> {
>>
>> long
>>
>> houseKeepingSize
>>
>> =
>>
>> 0L
>>
>> ;
>>
>> final
>>
>> Message
>>
>> in
>>
>> =
>>
>> s
>>
>> .
>>
>> getIn
>>
>> ()
>>
>> ;
>>
>> try
>>
>> {
>>
>> houseKeepingSize
>>
>> =
>>
>> in
>>
>> .
>>
>> getHeader
>>
>> (
>>
>> "HouseKeepingSize"
>>
>> ,
>>
>> Long
>>
>> .
>>
>> class
>>
>> )
>>
>> ;
>>
>> }
>>
>> catch
>>
>> (
>>
>> Exception
>>
>> ignored) {
>>
>> }
>>
>> final
>>
>> File
>>
>> body
>>
>> =
>>
>> in
>>
>> .
>>
>> getBody
>>
>> (
>>
>> File
>>
>> .
>>
>> class
>>
>> )
>>
>> ;
>>
>> houseKeepingSize
>>
>> +=
>>
>> body
>>
>> .
>>
>> length
>>
>> ()
>>
>> ;
>>
>> in
>>
>> .
>>
>> setHeader
>>
>> (
>>
>> "HouseKeepingSize"
>>
>> ,
>>
>> houseKeepingSize
>>
>> )
>>
>> ;
>>
>> })
>>
>> .
>>
>> aggregate
>>
>> (
>>
>> constant
>>
>> (
>>
>> true
>>
>> )
>>
>> ,
>>
>> new
>>
>> ZipAggregationStrategy
>>
>> (
>>
>> true
>>
>> ))
>>
>> .
>>
>> to
>>
>> (
>>
>> "log:HouseKeeping?level=INFO&groupInterval=5000&groupActiveOnly=true"
>>
>> )
>>
>> .
>>
>> completionFromBatchConsumer
>>
>> ()
>>
>> .
>>
>> eagerCheckCompletion
>>
>> ()
>>
>> .
>>
>> to
>>
>> (
>>
>> "file:mifir/archive"
>>
>> )
>>
>> .
>>
>> log
>>
>> (
>>
>> "Monthly housekeeping is done! Archived ${property.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes"
>>
>> )
>>
>> .
>>
>> end
>>
>> ()
>>
>> ;
>>
>> }
>>
>> Read the migration guide but not finding any clues…
>>
>> From Camel 2.25.3 to 3.6.0
>>
>> /M

Re: File filter bean not working in Camel 3

Posted by Andrea Cosentino <an...@gmail.com>.
It's not possible to read the code.

I would migrate to an LTS 3.7.x and not to 3.6.0, this is the first
suggestion I have.

Il giorno mer 19 mag 2021 alle ore 15:13 Mikael Andersson Wigander
<mi...@pm.me.invalid> ha scritto:

> Hi
> In Camel 2.x we have a file component with a filter bean and now migrating
> to Camel 3 the bean is not found and program crashes upon start.
> The migration has been only with the route converting to use
> EndpointRoutebuilder, the config, bean and class is unchanged.
>
> Config
>
> @Bean
>
> public static
>
> HouseKeepingFileFilter
>
> <
>
> String
>
> >
>
> houseKeepingFileFilter
>
> () {
>
> return new
>
> HouseKeepingFileFilter
>
> <>()
>
> ;
>
> }
>
> Impl
>
> @CommonsLog
>
> public class
>
> HouseKeepingFileFilter
>
> <T>
>
> implements
>
> GenericFileFilter
>
> <
>
> String
>
> > {
>
> public boolean
>
> accept
>
> (
>
> GenericFile
>
> file) {
>
> SimpleDateFormat
>
> sdf
>
> =
>
> new
>
> SimpleDateFormat
>
> (
>
> "yyyy-MM-dd HH:mm:ss"
>
> )
>
> ;
>
> final boolean
>
> isValid
>
> =
>
> file
>
> .
>
> isDirectory
>
> ()
>
> ?
>
> true
>
> :
>
> file
>
> .
>
> getLastModified
>
> ()
>
> <
>
> LocalDateTime
>
> .
>
> now
>
> ()
>
> .
>
> minusMonths
>
> (1L)
>
> .
>
> atZone
>
> (
>
> ZoneId
>
> .
>
> systemDefault
>
> ())
>
> .
>
> toInstant
>
> ()
>
> .
>
> toEpochMilli
>
> ()
>
> ;
>
> log
>
> .
>
> trace
>
> (
>
> MessageFormat
>
> .
>
> format
>
> (
>
> "File :{0}, with modification date: {1} is {2} for archive"
>
> ,
>
> file
>
> .
>
> getFileName
>
> ()
>
> ,
>
> sdf
>
> .
>
> format
>
> (file
>
> .
>
> getLastModified
>
> ())
>
> ,
>
> isValid
>
> ?
>
> "valid"
>
> :
>
> "NOT valid"
>
> ))
>
> ;
>
> return
>
> isValid
>
> ;
>
> }
>
> }
>
> Camel 3
>
> @Override
>
> public void
>
> configure
>
> ()
>
> throws
>
> Exception
>
> {
>
> from
>
> (
>
> file
>
> (
>
> "mifir/"
>
> )
>
> .
>
> antInclude
>
> (
>
> "{{housekeeping.files.include}}"
>
> )
>
> .
>
> antExclude
>
> (
>
>
> "**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}"
>
> )
>
> .
>
> recursive
>
> (
>
> true
>
> )
>
> .
>
> filter
>
> (
>
> "#houseKeepingFileFilter"
>
> )
>
> .
>
> scheduler
>
> (
>
> "quartz"
>
> )
>
> .
>
> schedulerProperties
>
> (
>
> "cron"
>
> ,
>
> "{{housekeeping.cron}}"
>
> )
>
> .
>
> schedulerProperties
>
> (
>
> "triggerId"
>
> ,
>
> "houseKeepingId"
>
> )
>
> .
>
> schedulerProperties
>
> (
>
> "triggerGroup"
>
> ,
>
> "houseKeepingGroup"
>
> ))
>
> .
>
> description
>
> (
>
> "HOUSEKEEPING-ROUTE"
>
> ,
>
> "Archive files older than a month"
>
> ,
>
> "en"
>
> )
>
> .
>
> process
>
> (s
>
> ->
>
> {
>
> long
>
> houseKeepingSize
>
> =
>
> 0L
>
> ;
>
> final
>
> Message
>
> in
>
> =
>
> s
>
> .
>
> getIn
>
> ()
>
> ;
>
> try
>
> {
>
> houseKeepingSize
>
> =
>
> in
>
> .
>
> getHeader
>
> (
>
> "HouseKeepingSize"
>
> ,
>
> Long
>
> .
>
> class
>
> )
>
> ;
>
> }
>
> catch
>
> (
>
> Exception
>
> ignored) {
>
> }
>
> final
>
> File
>
> body
>
> =
>
> in
>
> .
>
> getBody
>
> (
>
> File
>
> .
>
> class
>
> )
>
> ;
>
> houseKeepingSize
>
> +=
>
> body
>
> .
>
> length
>
> ()
>
> ;
>
> in
>
> .
>
> setHeader
>
> (
>
> "HouseKeepingSize"
>
> ,
>
> houseKeepingSize
>
> )
>
> ;
>
> })
>
> .
>
> aggregate
>
> (
>
> constant
>
> (
>
> true
>
> )
>
> ,
>
> new
>
> ZipAggregationStrategy
>
> (
>
> true
>
> ))
>
> .
>
> to
>
> (
>
> log
>
> (
>
> "HouseKeeping"
>
> )
>
> .
>
> level
>
> (
>
> "INFO"
>
> )
>
> .
>
> groupInterval
>
> (5_000L)
>
> .
>
> groupActiveOnly
>
> (
>
> true
>
> ))
>
> .
>
> completionFromBatchConsumer
>
> ()
>
> .
>
> eagerCheckCompletion
>
> ()
>
> .
>
> to
>
> (
>
> file
>
> (
>
> "mifir/archive"
>
> ))
>
> .
>
> log
>
> (
>
> "Monthly housekeeping is done! Archived
> ${exchangeProperty.CamelAggregatedSize} files and saved
> ${header.HouseKeepingSize} bytes"
>
> )
>
> .
>
> end
>
> ()
>
> ;
>
> }
>
> Camel 2
>
> @Override
>
> public void
>
> configure
>
> ()
>
> throws
>
> Exception
>
> {
>
> from
>
> (
>
> "file:mifir/"
>
> +
>
> "?antInclude={{housekeeping.files.include}}"
>
> +
>
>
> "&antExclude=**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}"
>
> +
>
> "&recursive=true"
>
> +
>
> "&filter=#houseKeepingFileFilter"
>
> +
>
> "&scheduler=quartz2"
>
> +
>
> "&scheduler.cron={{housekeeping.cron}}"
>
> +
>
> "&scheduler.triggerId=houseKeepingId"
>
> +
>
> "&scheduler.triggerGroup=houseKeepingGroup"
>
> )
>
> .
>
> description
>
> (
>
> "HOUSEKEEPING-ROUTE"
>
> ,
>
> "Archive files older than a month"
>
> ,
>
> "en"
>
> )
>
> .
>
> process
>
> (s
>
> ->
>
> {
>
> long
>
> houseKeepingSize
>
> =
>
> 0L
>
> ;
>
> final
>
> Message
>
> in
>
> =
>
> s
>
> .
>
> getIn
>
> ()
>
> ;
>
> try
>
> {
>
> houseKeepingSize
>
> =
>
> in
>
> .
>
> getHeader
>
> (
>
> "HouseKeepingSize"
>
> ,
>
> Long
>
> .
>
> class
>
> )
>
> ;
>
> }
>
> catch
>
> (
>
> Exception
>
> ignored) {
>
> }
>
> final
>
> File
>
> body
>
> =
>
> in
>
> .
>
> getBody
>
> (
>
> File
>
> .
>
> class
>
> )
>
> ;
>
> houseKeepingSize
>
> +=
>
> body
>
> .
>
> length
>
> ()
>
> ;
>
> in
>
> .
>
> setHeader
>
> (
>
> "HouseKeepingSize"
>
> ,
>
> houseKeepingSize
>
> )
>
> ;
>
> })
>
> .
>
> aggregate
>
> (
>
> constant
>
> (
>
> true
>
> )
>
> ,
>
> new
>
> ZipAggregationStrategy
>
> (
>
> true
>
> ))
>
> .
>
> to
>
> (
>
> "log:HouseKeeping?level=INFO&groupInterval=5000&groupActiveOnly=true"
>
> )
>
> .
>
> completionFromBatchConsumer
>
> ()
>
> .
>
> eagerCheckCompletion
>
> ()
>
> .
>
> to
>
> (
>
> "file:mifir/archive"
>
> )
>
> .
>
> log
>
> (
>
> "Monthly housekeeping is done! Archived ${property.CamelAggregatedSize}
> files and saved ${header.HouseKeepingSize} bytes"
>
> )
>
> .
>
> end
>
> ()
>
> ;
>
> }
>
> Read the migration guide but not finding any clues…
>
> From Camel 2.25.3 to 3.6.0
>
> /M

Re: File filter bean not working in Camel 3

Posted by Mikael Andersson Wigander <mi...@pm.me.INVALID>.
However if doing this it works
  .filter(new HouseKeepingFileFilter<>())


/M

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Friday, May 21st, 2021 at 13:19, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> Look at the Camel Spring Boo Examples you can find from the camel
>
> website a link to the github repo.
>
> They show how to use SB with Camel 3. That can possible help you to
>
> find the solution.
>
> On Fri, May 21, 2021 at 11:47 AM Mikael Andersson Wigander
>
> mikael.andersson.wigander@pm.me.invalid wrote:
>
> > OK, interesting thought.
> >
> > All my classes are within the same base.
> >
> > @Configuration is in Config.class
> >
> > If this structure no longer works with Spring Boot, what to do then?
> >
> > Should I put all my @Configuration in my Main class instead?
> >
> > /M
> >
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> >
> > On Friday, May 21st, 2021 at 11:20, Claus Ibsen claus.ibsen@gmail.com wrote:
> >
> > > Hi
> > >
> > > It's a Spring Boot issue with that @Bean is not discovered and registered.
> > >
> > > Mind about spring boots annotation scanner only checks by default the
> > >
> > > package from the main class, and its sub packages.
> > >
> > > So it matter where you put this class.
>
> --
>
> Claus Ibsen
> -----------
>
> http://davsclaus.com @davsclaus
>
> Camel in Action 2: https://www.manning.com/ibsen2

Sv: Re: File filter bean not working in Camel 3

Posted by Mikael Andersson Wigander <mi...@pm.me.INVALID>.
Ok thanks.

  

I tried and reverted my SB to 2.2.0 which is the same version when running
camel 2  and it still doesn’t work.

  

  

  

  

/M  

  

  

På fre, maj 21, 2021 vid 13:19, Claus Ibsen
<[claus.ibsen@gmail.com](mailto:claus.ibsen@gmail.com)> skrev:

> Hi  
>  
> Look at the Camel Spring Boo Examples you can find from the camel  
> website a link to the github repo.  
> They show how to use SB with Camel 3. That can possible help you to  
> find the solution.  
>  
> On Fri, May 21, 2021 at 11:47 AM Mikael Andersson Wigander  
> <mi...@pm.me.invalid> wrote:  
> >  
> > OK, interesting thought.  
> >  
> > All my classes are within the same base.  
> > @Configuration is in Config.class  
> >  
> > If this structure no longer works with Spring Boot, what to do then?  
> > Should I put all my @Configuration in my Main class instead?  
> >  
> > /M  
> >  
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐  
> >  
> > On Friday, May 21st, 2021 at 11:20, Claus Ibsen <cl...@gmail.com>
wrote:  
> >  
> > > Hi  
> > >  
> > > It's a Spring Boot issue with that @Bean is not discovered and
registered.  
> > >  
> > > Mind about spring boots annotation scanner only checks by default the  
> > >  
> > > package from the main class, and its sub packages.  
> > >  
> > > So it matter where you put this class.  
>  
>  
>  
> \--  
> Claus Ibsen  
> \-----------------  
> http://davsclaus.com @davsclaus  
> Camel in Action 2: https://www.manning.com/ibsen2  
>

  

  


Re: File filter bean not working in Camel 3

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Look at the Camel Spring Boo Examples you can find from the camel
website a link to the github repo.
They show how to use SB with Camel 3. That can possible help you to
find the solution.

On Fri, May 21, 2021 at 11:47 AM Mikael Andersson Wigander
<mi...@pm.me.invalid> wrote:
>
> OK, interesting thought.
>
> All my classes are within the same base.
> @Configuration is in Config.class
>
> If this structure no longer works with Spring Boot, what to do then?
> Should I put all my @Configuration in my Main class instead?
>
> /M
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> On Friday, May 21st, 2021 at 11:20, Claus Ibsen <cl...@gmail.com> wrote:
>
> > Hi
> >
> > It's a Spring Boot issue with that @Bean is not discovered and registered.
> >
> > Mind about spring boots annotation scanner only checks by default the
> >
> > package from the main class, and its sub packages.
> >
> > So it matter where you put this class.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: File filter bean not working in Camel 3

Posted by Mikael Andersson Wigander <mi...@pm.me.INVALID>.
OK, interesting thought.

All my classes are within the same base.
@Configuration is in Config.class

If this structure no longer works with Spring Boot, what to do then?
Should I put all my @Configuration in my Main class instead?

/M

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Friday, May 21st, 2021 at 11:20, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> It's a Spring Boot issue with that @Bean is not discovered and registered.
>
> Mind about spring boots annotation scanner only checks by default the
>
> package from the main class, and its sub packages.
>
> So it matter where you put this class.

Re: File filter bean not working in Camel 3

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

It's a Spring Boot issue with that @Bean is not discovered and registered.

Mind about spring boots annotation scanner only checks by default the
package from the main class, and its sub packages.
So it matter where you put this class.

Re: File filter bean not working in Camel 3

Posted by Mikael Andersson Wigander <mi...@pm.me.INVALID>.
2021-05-21 10:42:25.655 ERROR 10663 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.apache.camel.FailedToCreateRouteException: Failed to create route HOUSEKEEPING-ROUTE: Route(HOUSEKEEPING-ROUTE)[From[file://mifir/?antExclude=**%2... because of Failed to resolve endpoint: file://mifir/?antExclude=**%2Farchive%2F**%2C**%2Fdata%2F**%2C**%2FLegalReportingModuleTransporterBridge%2F**%2C**%2FMAPPING%2F**%2C**%2F*.dat%2C+**%2Flog%2F**%2C+**%2FCORE%2F**%2C+**%2Ferror%2F**&antInclude=**%2F*.zip%2C**%2F*.xml%2C**%2F*.csv%2C**%2F*.txt%2C**%2F*.XML_ZIP%2C**%2F*.json&filter=%23houseKeepingFileFilter&recursive=true&scheduler=quartz&scheduler.cron=0%2B0%2F1%2B*%2B%3F%2B*%2BMON-FRI&scheduler.triggerGroup=houseKeepingGroup&scheduler.triggerId=houseKeepingId due to: Error binding property (filter=#houseKeepingFileFilter) with name: filter on bean: file://mifir/?antExclude=**%2Farchive%2F**%2C**%2Fdata%2F**%2C**%2FLegalReportingModuleTransporterBridge%2F**%2C**%2FMAPPING%2F**%2C**%2F*.dat%2C+**%2Flog%2F**%2C+**%2FCORE%2F**%2C+**%2Ferror%2F**&antInclude=**%2F*.zip%2C**%2F*.xml%2C**%2F*.csv%2C**%2F*.txt%2C**%2F*.XML_ZIP%2C**%2F*.json&filter=%23houseKeepingFileFilter&recursive=true&scheduler=quartz&scheduler.cron=0%2B0%2F1%2B*%2B%3F%2B*%2BMON-FRI&scheduler.triggerGroup=houseKeepingGroup&scheduler.triggerId=houseKeepingId with value: #houseKeepingFileFilter
	at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:117)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:431)
	at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:393)
	at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2606)
	at org.apache.camel.support.service.BaseService.init(BaseService.java:83)
	at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2378)
	at org.apache.camel.support.service.BaseService.start(BaseService.java:111)
	at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2395)
	at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:130)
	at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:167)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140)
	at se.tradechannel.mifid.MainApplication.main(MainApplication.java:84)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: file://mifir/?antExclude=**%2Farchive%2F**%2C**%2Fdata%2F**%2C**%2FLegalReportingModuleTransporterBridge%2F**%2C**%2FMAPPING%2F**%2C**%2F*.dat%2C+**%2Flog%2F**%2C+**%2FCORE%2F**%2C+**%2Ferror%2F**&antInclude=**%2F*.zip%2C**%2F*.xml%2C**%2F*.csv%2C**%2F*.txt%2C**%2F*.XML_ZIP%2C**%2F*.json&filter=%23houseKeepingFileFilter&recursive=true&scheduler=quartz&scheduler.cron=0%2B0%2F1%2B*%2B%3F%2B*%2BMON-FRI&scheduler.triggerGroup=houseKeepingGroup&scheduler.triggerId=houseKeepingId due to: Error binding property (filter=#houseKeepingFileFilter) with name: filter on bean: file://mifir/?antExclude=**%2Farchive%2F**%2C**%2Fdata%2F**%2C**%2FLegalReportingModuleTransporterBridge%2F**%2C**%2FMAPPING%2F**%2C**%2F*.dat%2C+**%2Flog%2F**%2C+**%2FCORE%2F**%2C+**%2Ferror%2F**&antInclude=**%2F*.zip%2C**%2F*.xml%2C**%2F*.csv%2C**%2F*.txt%2C**%2F*.XML_ZIP%2C**%2F*.json&filter=%23houseKeepingFileFilter&recursive=true&scheduler=quartz&scheduler.cron=0%2B0%2F1%2B*%2B%3F%2B*%2BMON-FRI&scheduler.triggerGroup=houseKeepingGroup&scheduler.triggerId=houseKeepingId with value: #houseKeepingFileFilter
	at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:896)
	at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:802)
	at org.apache.camel.builder.endpoint.AbstractEndpointBuilder.resolve(AbstractEndpointBuilder.java:58)
	at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:247)
	at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:111)
	... 28 common frames omitted
Caused by: org.apache.camel.PropertyBindingException: Error binding property (filter=#houseKeepingFileFilter) with name: filter on bean: file://mifir/?antExclude=**%2Farchive%2F**%2C**%2Fdata%2F**%2C**%2FLegalReportingModuleTransporterBridge%2F**%2C**%2FMAPPING%2F**%2C**%2F*.dat%2C+**%2Flog%2F**%2C+**%2FCORE%2F**%2C+**%2Ferror%2F**&antInclude=**%2F*.zip%2C**%2F*.xml%2C**%2F*.csv%2C**%2F*.txt%2C**%2F*.XML_ZIP%2C**%2F*.json&filter=%23houseKeepingFileFilter&recursive=true&scheduler=quartz&scheduler.cron=0%2B0%2F1%2B*%2B%3F%2B*%2BMON-FRI&scheduler.triggerGroup=houseKeepingGroup&scheduler.triggerId=houseKeepingId with value: #houseKeepingFileFilter
	at org.apache.camel.support.PropertyBindingSupport.setSimplePropertyViaConfigurer(PropertyBindingSupport.java:849)
	at org.apache.camel.support.PropertyBindingSupport.doSetPropertyValue(PropertyBindingSupport.java:609)
	at org.apache.camel.support.PropertyBindingSupport.doBuildPropertyOgnlPath(PropertyBindingSupport.java:481)
	at org.apache.camel.support.PropertyBindingSupport.doBindProperties(PropertyBindingSupport.java:376)
	at org.apache.camel.support.PropertyBindingSupport.access$100(PropertyBindingSupport.java:87)
	at org.apache.camel.support.PropertyBindingSupport$Builder.bind(PropertyBindingSupport.java:1877)
	at org.apache.camel.support.DefaultEndpoint.setProperties(DefaultEndpoint.java:435)
	at org.apache.camel.support.DefaultEndpoint.configureProperties(DefaultEndpoint.java:403)
	at org.apache.camel.support.ScheduledPollEndpoint.configureProperties(ScheduledPollEndpoint.java:115)
	at org.apache.camel.support.DefaultComponent.setProperties(DefaultComponent.java:387)
	at org.apache.camel.component.file.GenericFileComponent.createEndpoint(GenericFileComponent.java:69)
	at org.apache.camel.component.file.GenericFileComponent.createEndpoint(GenericFileComponent.java:38)
	at org.apache.camel.support.DefaultComponent.createEndpoint(DefaultComponent.java:156)
	at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:862)
	... 32 common frames omitted
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: houseKeepingFileFilter of type: org.apache.camel.component.file.GenericFileFilter
	at org.apache.camel.support.CamelContextHelper.mandatoryLookupAndConvert(CamelContextHelper.java:253)
	at org.apache.camel.support.EndpointHelper.resolveReferenceParameter(EndpointHelper.java:290)
	at org.apache.camel.support.EndpointHelper.resolveReferenceParameter(EndpointHelper.java:250)
	at org.apache.camel.support.component.PropertyConfigurerSupport.property(PropertyConfigurerSupport.java:53)
	at org.apache.camel.component.file.FileEndpointConfigurer.configure(FileEndpointConfigurer.java:174)
	at org.apache.camel.support.PropertyBindingSupport.setSimplePropertyViaConfigurer(PropertyBindingSupport.java:847)
	... 45 common frames omitted

/M

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Friday, May 21st, 2021 at 07:18, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> Crashes at startup. Can you tell what kind of crash, and do you see
>
> any exceptions or something?
>
> On Wed, May 19, 2021 at 3:13 PM Mikael Andersson Wigander
>
> mikael.andersson.wigander@pm.me.invalid wrote:
>
> > Hi
> >
> > In Camel 2.x we have a file component with a filter bean and now migrating to Camel 3 the bean is not found and program crashes upon start.
> >
> > The migration has been only with the route converting to use EndpointRoutebuilder, the config, bean and class is unchanged.
> >
> > Config
> >
> > @Bean
> >
> > public static
> >
> > HouseKeepingFileFilter
> >
> > <
> >
> > String
> >
> > houseKeepingFileFilter
> >
> > () {
> >
> > return new
> >
> > HouseKeepingFileFilter
> >
> > <>()
> >
> > ;
> >
> > }
> >
> > Impl
> >
> > @CommonsLog
> >
> > public class
> >
> > HouseKeepingFileFilter
> >
> > <T>
> >
> > implements
> >
> > GenericFileFilter
> >
> > <
> >
> > String
> >
> > > {
> >
> > public boolean
> >
> > accept
> >
> > (
> >
> > GenericFile
> >
> > file) {
> >
> > SimpleDateFormat
> >
> > sdf
> >
> > =
> >
> > new
> >
> > SimpleDateFormat
> >
> > (
> >
> > "yyyy-MM-dd HH:mm:ss"
> >
> > )
> >
> > ;
> >
> > final boolean
> >
> > isValid
> >
> > =
> >
> > file
> >
> > .
> >
> > isDirectory
> >
> > ()
> >
> > ?
> >
> > true
> >
> > :
> >
> > file
> >
> > .
> >
> > getLastModified
> >
> > ()
> >
> > <
> >
> > LocalDateTime
> >
> > .
> >
> > now
> >
> > ()
> >
> > .
> >
> > minusMonths
> >
> > (1L)
> >
> > .
> >
> > atZone
> >
> > (
> >
> > ZoneId
> >
> > .
> >
> > systemDefault
> >
> > ())
> >
> > .
> >
> > toInstant
> >
> > ()
> >
> > .
> >
> > toEpochMilli
> >
> > ()
> >
> > ;
> >
> > log
> >
> > .
> >
> > trace
> >
> > (
> >
> > MessageFormat
> >
> > .
> >
> > format
> >
> > (
> >
> > "File :{0}, with modification date: {1} is {2} for archive"
> >
> > ,
> >
> > file
> >
> > .
> >
> > getFileName
> >
> > ()
> >
> > ,
> >
> > sdf
> >
> > .
> >
> > format
> >
> > (file
> >
> > .
> >
> > getLastModified
> >
> > ())
> >
> > ,
> >
> > isValid
> >
> > ?
> >
> > "valid"
> >
> > :
> >
> > "NOT valid"
> >
> > ))
> >
> > ;
> >
> > return
> >
> > isValid
> >
> > ;
> >
> > }
> >
> > }
> >
> > Camel 3
> >
> > @Override
> >
> > public void
> >
> > configure
> >
> > ()
> >
> > throws
> >
> > Exception
> >
> > {
> >
> > from
> >
> > (
> >
> > file
> >
> > (
> >
> > "mifir/"
> >
> > )
> >
> > .
> >
> > antInclude
> >
> > (
> >
> > "{{housekeeping.files.include}}"
> >
> > )
> >
> > .
> >
> > antExclude
> >
> > (
> >
> > "/archive/,/data/,/LegalReportingModuleTransporterBridge/,
> >
> > /M
> >
> > APPING/,{{housekeeping.files.exclude}}"
> >
> > )
> >
> > .
> >
> > recursive
> >
> > (
> >
> > true
> >
> > )
> >
> > .
> >
> > filter
> >
> > (
> >
> > "#houseKeepingFileFilter"
> >
> > )
> >
> > .
> >
> > scheduler
> >
> > (
> >
> > "quartz"
> >
> > )
> >
> > .
> >
> > schedulerProperties
> >
> > (
> >
> > "cron"
> >
> > ,
> >
> > "{{housekeeping.cron}}"
> >
> > )
> >
> > .
> >
> > schedulerProperties
> >
> > (
> >
> > "triggerId"
> >
> > ,
> >
> > "houseKeepingId"
> >
> > )
> >
> > .
> >
> > schedulerProperties
> >
> > (
> >
> > "triggerGroup"
> >
> > ,
> >
> > "houseKeepingGroup"
> >
> > ))
> >
> > .
> >
> > description
> >
> > (
> >
> > "HOUSEKEEPING-ROUTE"
> >
> > ,
> >
> > "Archive files older than a month"
> >
> > ,
> >
> > "en"
> >
> > )
> >
> > .
> >
> > process
> >
> > (s
> >
> > ->
> >
> > {
> >
> > long
> >
> > houseKeepingSize
> >
> > =
> >
> > 0L
> >
> > ;
> >
> > final
> >
> > Message
> >
> > in
> >
> > =
> >
> > s
> >
> > .
> >
> > getIn
> >
> > ()
> >
> > ;
> >
> > try
> >
> > {
> >
> > houseKeepingSize
> >
> > =
> >
> > in
> >
> > .
> >
> > getHeader
> >
> > (
> >
> > "HouseKeepingSize"
> >
> > ,
> >
> > Long
> >
> > .
> >
> > class
> >
> > )
> >
> > ;
> >
> > }
> >
> > catch
> >
> > (
> >
> > Exception
> >
> > ignored) {
> >
> > }
> >
> > final
> >
> > File
> >
> > body
> >
> > =
> >
> > in
> >
> > .
> >
> > getBody
> >
> > (
> >
> > File
> >
> > .
> >
> > class
> >
> > )
> >
> > ;
> >
> > houseKeepingSize
> >
> > +=
> >
> > body
> >
> > .
> >
> > length
> >
> > ()
> >
> > ;
> >
> > in
> >
> > .
> >
> > setHeader
> >
> > (
> >
> > "HouseKeepingSize"
> >
> > ,
> >
> > houseKeepingSize
> >
> > )
> >
> > ;
> >
> > })
> >
> > .
> >
> > aggregate
> >
> > (
> >
> > constant
> >
> > (
> >
> > true
> >
> > )
> >
> > ,
> >
> > new
> >
> > ZipAggregationStrategy
> >
> > (
> >
> > true
> >
> > ))
> >
> > .
> >
> > to
> >
> > (
> >
> > log
> >
> > (
> >
> > "HouseKeeping"
> >
> > )
> >
> > .
> >
> > level
> >
> > (
> >
> > "INFO"
> >
> > )
> >
> > .
> >
> > groupInterval
> >
> > (5_000L)
> >
> > .
> >
> > groupActiveOnly
> >
> > (
> >
> > true
> >
> > ))
> >
> > .
> >
> > completionFromBatchConsumer
> >
> > ()
> >
> > .
> >
> > eagerCheckCompletion
> >
> > ()
> >
> > .
> >
> > to
> >
> > (
> >
> > file
> >
> > (
> >
> > "mifir/archive"
> >
> > ))
> >
> > .
> >
> > log
> >
> > (
> >
> > "Monthly housekeeping is done! Archived ${exchangeProperty.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes"
> >
> > )
> >
> > .
> >
> > end
> >
> > ()
> >
> > ;
> >
> > }
> >
> > Camel 2
> >
> > @Override
> >
> > public void
> >
> > configure
> >
> > ()
> >
> > throws
> >
> > Exception
> >
> > {
> >
> > from
> >
> > (
> >
> > "file:mifir/"
> >
> > "?antInclude={{housekeeping.files.include}}"
> >
> > "&antExclude=/archive/,/data/,/LegalReportingModuleTransporterBridge/,/MAPPING/,{{housekeeping.files.exclude}}"
> >
> > "&recursive=true"
> >
> > "&filter=#houseKeepingFileFilter"
> >
> > "&scheduler=quartz2"
> >
> > "&scheduler.cron={{housekeeping.cron}}"
> >
> > "&scheduler.triggerId=houseKeepingId"
> >
> > "&scheduler.triggerGroup=houseKeepingGroup"
> >
> > )
> >
> > .
> >
> > description
> >
> > (
> >
> > "HOUSEKEEPING-ROUTE"
> >
> > ,
> >
> > "Archive files older than a month"
> >
> > ,
> >
> > "en"
> >
> > )
> >
> > .
> >
> > process
> >
> > (s
> >
> > ->
> >
> > {
> >
> > long
> >
> > houseKeepingSize
> >
> > =
> >
> > 0L
> >
> > ;
> >
> > final
> >
> > Message
> >
> > in
> >
> > =
> >
> > s
> >
> > .
> >
> > getIn
> >
> > ()
> >
> > ;
> >
> > try
> >
> > {
> >
> > houseKeepingSize
> >
> > =
> >
> > in
> >
> > .
> >
> > getHeader
> >
> > (
> >
> > "HouseKeepingSize"
> >
> > ,
> >
> > Long
> >
> > .
> >
> > class
> >
> > )
> >
> > ;
> >
> > }
> >
> > catch
> >
> > (
> >
> > Exception
> >
> > ignored) {
> >
> > }
> >
> > final
> >
> > File
> >
> > body
> >
> > =
> >
> > in
> >
> > .
> >
> > getBody
> >
> > (
> >
> > File
> >
> > .
> >
> > class
> >
> > )
> >
> > ;
> >
> > houseKeepingSize
> >
> > +=
> >
> > body
> >
> > .
> >
> > length
> >
> > ()
> >
> > ;
> >
> > in
> >
> > .
> >
> > setHeader
> >
> > (
> >
> > "HouseKeepingSize"
> >
> > ,
> >
> > houseKeepingSize
> >
> > )
> >
> > ;
> >
> > })
> >
> > .
> >
> > aggregate
> >
> > (
> >
> > constant
> >
> > (
> >
> > true
> >
> > )
> >
> > ,
> >
> > new
> >
> > ZipAggregationStrategy
> >
> > (
> >
> > true
> >
> > ))
> >
> > .
> >
> > to
> >
> > (
> >
> > "log:HouseKeeping?level=INFO&groupInterval=5000&groupActiveOnly=true"
> >
> > )
> >
> > .
> >
> > completionFromBatchConsumer
> >
> > ()
> >
> > .
> >
> > eagerCheckCompletion
> >
> > ()
> >
> > .
> >
> > to
> >
> > (
> >
> > "file:mifir/archive"
> >
> > )
> >
> > .
> >
> > log
> >
> > (
> >
> > "Monthly housekeeping is done! Archived ${property.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes"
> >
> > )
> >
> > .
> >
> > end
> >
> > ()
> >
> > ;
> >
> > }
> >
> > Read the migration guide but not finding any clues…
> >
> > From Camel 2.25.3 to 3.6.0
> >
> > /M
>
> --
>
> Claus Ibsen
> -----------
>
> http://davsclaus.com @davsclaus
>
> Camel in Action 2: https://www.manning.com/ibsen2

Re: File filter bean not working in Camel 3

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Crashes at startup. Can you tell what kind of crash, and do you see
any exceptions or something?

On Wed, May 19, 2021 at 3:13 PM Mikael Andersson Wigander
<mi...@pm.me.invalid> wrote:
>
> Hi
> In Camel 2.x we have a file component with a filter bean and now migrating to Camel 3 the bean is not found and program crashes upon start.
> The migration has been only with the route converting to use EndpointRoutebuilder, the config, bean and class is unchanged.
>
> Config
>
> @Bean
>
> public static
>
> HouseKeepingFileFilter
>
> <
>
> String
>
> >
>
> houseKeepingFileFilter
>
> () {
>
> return new
>
> HouseKeepingFileFilter
>
> <>()
>
> ;
>
> }
>
> Impl
>
> @CommonsLog
>
> public class
>
> HouseKeepingFileFilter
>
> <T>
>
> implements
>
> GenericFileFilter
>
> <
>
> String
>
> > {
>
> public boolean
>
> accept
>
> (
>
> GenericFile
>
> file) {
>
> SimpleDateFormat
>
> sdf
>
> =
>
> new
>
> SimpleDateFormat
>
> (
>
> "yyyy-MM-dd HH:mm:ss"
>
> )
>
> ;
>
> final boolean
>
> isValid
>
> =
>
> file
>
> .
>
> isDirectory
>
> ()
>
> ?
>
> true
>
> :
>
> file
>
> .
>
> getLastModified
>
> ()
>
> <
>
> LocalDateTime
>
> .
>
> now
>
> ()
>
> .
>
> minusMonths
>
> (1L)
>
> .
>
> atZone
>
> (
>
> ZoneId
>
> .
>
> systemDefault
>
> ())
>
> .
>
> toInstant
>
> ()
>
> .
>
> toEpochMilli
>
> ()
>
> ;
>
> log
>
> .
>
> trace
>
> (
>
> MessageFormat
>
> .
>
> format
>
> (
>
> "File :{0}, with modification date: {1} is {2} for archive"
>
> ,
>
> file
>
> .
>
> getFileName
>
> ()
>
> ,
>
> sdf
>
> .
>
> format
>
> (file
>
> .
>
> getLastModified
>
> ())
>
> ,
>
> isValid
>
> ?
>
> "valid"
>
> :
>
> "NOT valid"
>
> ))
>
> ;
>
> return
>
> isValid
>
> ;
>
> }
>
> }
>
> Camel 3
>
> @Override
>
> public void
>
> configure
>
> ()
>
> throws
>
> Exception
>
> {
>
> from
>
> (
>
> file
>
> (
>
> "mifir/"
>
> )
>
> .
>
> antInclude
>
> (
>
> "{{housekeeping.files.include}}"
>
> )
>
> .
>
> antExclude
>
> (
>
> "**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}"
>
> )
>
> .
>
> recursive
>
> (
>
> true
>
> )
>
> .
>
> filter
>
> (
>
> "#houseKeepingFileFilter"
>
> )
>
> .
>
> scheduler
>
> (
>
> "quartz"
>
> )
>
> .
>
> schedulerProperties
>
> (
>
> "cron"
>
> ,
>
> "{{housekeeping.cron}}"
>
> )
>
> .
>
> schedulerProperties
>
> (
>
> "triggerId"
>
> ,
>
> "houseKeepingId"
>
> )
>
> .
>
> schedulerProperties
>
> (
>
> "triggerGroup"
>
> ,
>
> "houseKeepingGroup"
>
> ))
>
> .
>
> description
>
> (
>
> "HOUSEKEEPING-ROUTE"
>
> ,
>
> "Archive files older than a month"
>
> ,
>
> "en"
>
> )
>
> .
>
> process
>
> (s
>
> ->
>
> {
>
> long
>
> houseKeepingSize
>
> =
>
> 0L
>
> ;
>
> final
>
> Message
>
> in
>
> =
>
> s
>
> .
>
> getIn
>
> ()
>
> ;
>
> try
>
> {
>
> houseKeepingSize
>
> =
>
> in
>
> .
>
> getHeader
>
> (
>
> "HouseKeepingSize"
>
> ,
>
> Long
>
> .
>
> class
>
> )
>
> ;
>
> }
>
> catch
>
> (
>
> Exception
>
> ignored) {
>
> }
>
> final
>
> File
>
> body
>
> =
>
> in
>
> .
>
> getBody
>
> (
>
> File
>
> .
>
> class
>
> )
>
> ;
>
> houseKeepingSize
>
> +=
>
> body
>
> .
>
> length
>
> ()
>
> ;
>
> in
>
> .
>
> setHeader
>
> (
>
> "HouseKeepingSize"
>
> ,
>
> houseKeepingSize
>
> )
>
> ;
>
> })
>
> .
>
> aggregate
>
> (
>
> constant
>
> (
>
> true
>
> )
>
> ,
>
> new
>
> ZipAggregationStrategy
>
> (
>
> true
>
> ))
>
> .
>
> to
>
> (
>
> log
>
> (
>
> "HouseKeeping"
>
> )
>
> .
>
> level
>
> (
>
> "INFO"
>
> )
>
> .
>
> groupInterval
>
> (5_000L)
>
> .
>
> groupActiveOnly
>
> (
>
> true
>
> ))
>
> .
>
> completionFromBatchConsumer
>
> ()
>
> .
>
> eagerCheckCompletion
>
> ()
>
> .
>
> to
>
> (
>
> file
>
> (
>
> "mifir/archive"
>
> ))
>
> .
>
> log
>
> (
>
> "Monthly housekeeping is done! Archived ${exchangeProperty.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes"
>
> )
>
> .
>
> end
>
> ()
>
> ;
>
> }
>
> Camel 2
>
> @Override
>
> public void
>
> configure
>
> ()
>
> throws
>
> Exception
>
> {
>
> from
>
> (
>
> "file:mifir/"
>
> +
>
> "?antInclude={{housekeeping.files.include}}"
>
> +
>
> "&antExclude=**/archive/**,**/data/**,**/LegalReportingModuleTransporterBridge/**,**/MAPPING/**,{{housekeeping.files.exclude}}"
>
> +
>
> "&recursive=true"
>
> +
>
> "&filter=#houseKeepingFileFilter"
>
> +
>
> "&scheduler=quartz2"
>
> +
>
> "&scheduler.cron={{housekeeping.cron}}"
>
> +
>
> "&scheduler.triggerId=houseKeepingId"
>
> +
>
> "&scheduler.triggerGroup=houseKeepingGroup"
>
> )
>
> .
>
> description
>
> (
>
> "HOUSEKEEPING-ROUTE"
>
> ,
>
> "Archive files older than a month"
>
> ,
>
> "en"
>
> )
>
> .
>
> process
>
> (s
>
> ->
>
> {
>
> long
>
> houseKeepingSize
>
> =
>
> 0L
>
> ;
>
> final
>
> Message
>
> in
>
> =
>
> s
>
> .
>
> getIn
>
> ()
>
> ;
>
> try
>
> {
>
> houseKeepingSize
>
> =
>
> in
>
> .
>
> getHeader
>
> (
>
> "HouseKeepingSize"
>
> ,
>
> Long
>
> .
>
> class
>
> )
>
> ;
>
> }
>
> catch
>
> (
>
> Exception
>
> ignored) {
>
> }
>
> final
>
> File
>
> body
>
> =
>
> in
>
> .
>
> getBody
>
> (
>
> File
>
> .
>
> class
>
> )
>
> ;
>
> houseKeepingSize
>
> +=
>
> body
>
> .
>
> length
>
> ()
>
> ;
>
> in
>
> .
>
> setHeader
>
> (
>
> "HouseKeepingSize"
>
> ,
>
> houseKeepingSize
>
> )
>
> ;
>
> })
>
> .
>
> aggregate
>
> (
>
> constant
>
> (
>
> true
>
> )
>
> ,
>
> new
>
> ZipAggregationStrategy
>
> (
>
> true
>
> ))
>
> .
>
> to
>
> (
>
> "log:HouseKeeping?level=INFO&groupInterval=5000&groupActiveOnly=true"
>
> )
>
> .
>
> completionFromBatchConsumer
>
> ()
>
> .
>
> eagerCheckCompletion
>
> ()
>
> .
>
> to
>
> (
>
> "file:mifir/archive"
>
> )
>
> .
>
> log
>
> (
>
> "Monthly housekeeping is done! Archived ${property.CamelAggregatedSize} files and saved ${header.HouseKeepingSize} bytes"
>
> )
>
> .
>
> end
>
> ()
>
> ;
>
> }
>
> Read the migration guide but not finding any clues…
>
> From Camel 2.25.3 to 3.6.0
>
> /M



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2