検索

第15章 Filter Expressions and Message Selectors

download PDF

The messaging-activemq subsystem in JBoss EAP provides a powerful filter language based on a subset of the SQL 92 expression syntax.

It is the same as the syntax used for JMS selectors, but the predefined identifiers are different. For documentation on JMS selector syntax, refer to the javax.jms.Message interface Javadoc.

The filter attribute can be found in several places within the configuration.

  • Predefined Queues. When pre-defining a queue, a filter expression can be defined for it. Only messages that match the filter expression will enter the queue. The configuration snippet below shows a queue definition that includes a filter:

    <subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">
      ...
      <queue
        name="myQueue"
        filter="FILTER_EXPRESSION"
        ...
      />
      ...
    </subsystem>

    To create queue with a selector in the management CLI you would use something like following command:

    jms-queue add --queue-address=QUEUE_ADDRESS --selector=FILTER_EXPRESSION
  • Core bridges can be defined with an optional filter expression, only matching messages will be bridged. Below is a snippet from a sample configuration file where the messaging-activemq subsystem includes a bridge with a filter.

    <subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">
      ...
      <bridge
        name="myBridge"
        filter="FILTER_EXPRESSION"
        ...
      />
      ...
    </subsystem>
  • Diverts can be defined with an optional filter expression, only matching messages will be diverted. See Diverts for more information. The example snippet below shows a Divert using a filter:

    <subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">
      ...
      <divert
        name="myDivert"
        filter="FILTER_EXPRESSION"
        ...
      />
      ...
    </subsystem>

There are some differences between JMS selector expressions and JBoss EAP messaging core filter expressions. Whereas JMS selector expressions operate on a JMS message, JBoss EAP messaging core filter expressions operate on a core message.

The following identifiers can be used in core filter expressions to refer to the attributes of a core message:

  • AMQPriority. To refer to the priority of a message. Message priorities are integers with valid values from 0 - 9. 0 is the lowest priority and 9 is the highest. For example, AMQPriority = 3 AND animal = 'aardvark'.
  • AMQExpiration. To refer to the expiration time of a message. The value is a long integer.
  • AMQDurable. To refer to whether a message is durable or not. The value is a string with valid values: DURABLE or NON_DURABLE.
  • AMQTimestamp. The timestamp of when the message was created. The value is a long integer.
  • AMQSize. The size of a message in bytes. The value is an integer.

Any other identifiers used in core filter expressions will be assumed to be properties of the message.

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.