【mq读书笔记】消息过滤机制

mq支持表达式过滤和类过滤两种模式,其中表达式又分为TAG和SQL92.类过滤模式允许提交一个过滤类到FilterServer,消息消费者从FilterServer拉取消息,消息经过FilterServer时会执行过滤逻辑。SQL92以消息属性过滤上下文,而TAG模式就是简单为消息定义标签。

public interface MessageFilter {
    /**
     * match by tags code or filter bit map which is calculated when message received
     * and stored in consume queue ext.
     *
     * @param tagsCode tagsCode
     * @param cqExtUnit extend unit of consume queue
     */
    boolean isMatchedByConsumeQueue(final Long tagsCode,
        final ConsumeQueueExt.CqExtUnit cqExtUnit);     //根据ConsumeQueue判断消息是否匹配

    /**
     * match by message content which are stored in commit log.
     * <br>{@code msgBuffer} and {@code properties} are not all null.If invoked in store,
     * {@code properties} is null;If invoked in {@code PullRequestHoldService}, {@code msgBuffer} is null.
     *
     * @param msgBuffer message buffer in commit log, may be null if not invoked in store.
     * @param properties message properties, should decode from buffer if null by yourself.
     */
    boolean isMatchedByCommitLog(final ByteBuffer msgBuffer,//根据存储在commitlog文件中的内容判断消息是否匹配
        final Map<String, String> properties);
}

 ConsumeQueue的消息中有存储长度为8字节的tag的hashcode 在消息拉取时会首先判断这里的hashcode,到了客户端会再具体的判断tag的字符串内容是否xiang fu相符

猜你喜欢

转载自www.cnblogs.com/lccsblog/p/12289479.html