18.8.6. JMS メッセージセレクター
メッセージングアプリケーションが受信するメッセージをフィルターする必要がある場合は、JMS API メッセージセレクターを使用して、メッセージコンシューマーが対象のメッセージを指定できるようになります。メッセージセレクターは、メッセージをアプリケーションではなく JMS プロバイダーにフィルタリングする作業を割り当てます。
メッセージセレクターは以下のように定義できます。
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
@MessageDriven(name = "MDBMessageSelectorExample", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"), @ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "color = 'RED'") }) @TransactionManagement(value= TransactionManagementType.CONTAINER) @TransactionAttribute(value= TransactionAttributeType.REQUIRED) public class MDBMessageSelectorExample implements MessageListener { public void onMessage(Message message).... }
@MessageDriven(name = "MDBMessageSelectorExample", activationConfig =
{
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/testQueue"),
@ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "color = 'RED'")
})
@TransactionManagement(value= TransactionManagementType.CONTAINER)
@TransactionAttribute(value= TransactionAttributeType.REQUIRED)
public class MDBMessageSelectorExample implements MessageListener
{
public void onMessage(Message message)....
}