@ Override public boolean filterSource ( CloudTrailSource source ) throws CallbackException { source = ( SQSBasedSource ) source ; Map < String , String > sourceAttributes = source . getSourceAttributes ( ) ; String accountId = sourceAttributes . get ( SourceAttributeKeys . ACCOUNT_ID . getAttributeKey ( ) ) ; String receivedCount = sourceAttributes . get ( SourceAttributeKeys . APPROXIMATE_RECEIVE_COUNT . getAttributeKey ( ) ) ; int approximateReceivedCount = Integer . parseInt ( receivedCount ) ; return approximateReceivedCount <= MAX_RECEIVED_COUNT && accountIDs . contains ( accountId ) ; }
This Sample Source Filter filter out messages that have been received more than 3 times and accountIDs in a certain range .