private boolean hasMessages ( String shardName ) throws MessageQueueException { UUID currentTime = TimeUUIDUtils . getUniqueTimeUUIDinMicros ( ) ; try { ColumnList < MessageQueueEntry > result = keyspace . prepareQuery ( queueColumnFamily ) . setConsistencyLevel ( consistencyLevel ) . getKey ( shardName ) . withColumnRange ( new RangeBuilder ( ) . setLimit ( 1 ) // Read extra messages because of the lock column . setStart ( entrySerializer . makeEndpoint ( ( byte ) MessageQueueEntryType . Message . ordinal ( ) , Equality . EQUAL ) . toBytes ( ) ) . setEnd ( entrySerializer . makeEndpoint ( ( byte ) MessageQueueEntryType . Message . ordinal ( ) , Equality . EQUAL ) . append ( ( byte ) 0 , Equality . EQUAL ) . append ( currentTime , Equality . LESS_THAN_EQUALS ) . toBytes ( ) ) . build ( ) ) . execute ( ) . getResult ( ) ; return ! result . isEmpty ( ) ; } catch ( ConnectionException e ) { throw new MessageQueueException ( "Error checking shard for messages. " + shardName , e ) ; } }
Fast check to see if a shard has messages to process