2017-01-10 6 views
0

JMSキュー(ActiveMQ)の一部のメッセージをクリーンアップする必要があります。メッセージヘッダーの一部にアンダースコアが含まれています。CamelとBlueprintで1つのヘッダーにアンダースコアを含むメッセージのJMSセレクター

いくつかの例

Message 1: 
    header MyObject=urn:sap:order:ID1234 
    body = <some xml> 


Message 2: 
    header MyObject=urn:sap:order:ID9834_ABC 
    body = <some xml> 

私の目標は、元のキューMY_ORDERSから(Message 1のような)、アンダースコアなしMessage 2のように見えるだけのメッセージ(およびすべての同様のアンダースコアを含む)とないメッセージを移動することです。

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0" 
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0" 
    xsi:schemaLocation=" 
     http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd 
     http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd 
     http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd"> 

    <cm:property-placeholder persistent-id="com.mycompany.order-temp" update-strategy="reload"> 
     <cm:default-properties> 
      <cm:property name="amq.url" value="tcp://localhost:61616" /> 
      <cm:property name="queue.to.dump" value="activemq:queue:MY_ORDERS?selector=MyObject+LIKE+'urn:order:%&#95;%'" /> 
     </cm:default-properties> 
    </cm:property-placeholder> 
    <camelContext xmlns="http://camel.apache.org/schema/blueprint"> 
     <onException useOriginalMessage="true"> 
      <exception>java.lang.Exception</exception> 
      <handled> 
       <constant>true</constant> 
      </handled> 
      <to uri="activemq:queue:MY_ORDERS_DLQ?preserveMessageQos=true" /> 
     </onException> 
     <route id="route-orders-to-temp"> 
      <from uri="{{queue.to.dump}}" /> 
      <to uri="activemq:queue:MY_ORDERS_TEMP" /> 
     </route> 
    </camelContext> 
    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> 
     <property name="brokerURL" value="${amq.url}" /> 
    </bean> 
</blueprint> 
次の記事を使用することにより

とセレクタに関する公式ActiveMQ Documentationが言うので、それは使用していますSQL 92 syntax

私は、次のすべての組み合わせを試してみました

selector=MyObject+LIKE+'urn:sap:order:%&#95;%' 
selector=MyObject+LIKE+'urn:sap:order:%_%' 
selector=MyObject+LIKE+'urn:sap:order:%\_%' 
selector=MyObject+LIKE+'urn:sap:order:%[_]%' 
selector=MyObject+LIKE+'urn:sap:order:[a-Z0-9]*_[a-Z0-9]*' 

しかし、どれもうまくいかないようです。何かご意見は?

答えて

0

最後に私の問題の解決策を見つけました。エスケープ文字を定義する特別な構文があり、デフォルトでは設定されていないようです。

インターネットで見ると、最後にfollowing postが見つかりました。これはアンダースコアがはっきりとエスケープされていることを明確に示しています。

selector=MyObject+LIKE+'urn:sap:order:%&#95;%' ESCAPE '\' 
selector=MyObject+LIKE+'urn:sap:order:%\_%' ESCAPE '\' 

がちょうどセレクタの最後に追加ESCAPE '\'で正常に動作します:私は私の例に次の行を適用した場合\はその後ESCAPE '\'

とエスケープ文字を定義します。

関連する問題