Thursday, March 24, 2011

MDB message selector with @ActivationConfigProperty annotation

for the MDB:

@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName="messagingType", propertyValue="javax.jms.MessageListener"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/YOURQUEUENAME"),
@ActivationConfigProperty(propertyName = "messageSelector", propertyValue = "MESSAGE_TYPE = 'MESSAGE_TYPE_IMPORT_BLA'")
},
mappedName = "YOURMDBNAME")




and in your code when you produce the Message:

TextMessage message = session.createTextMessage();
message.setText(messageText);
message.setStringProperty("MESSAGE_TYPE", "MESSAGE_TYPE_IMPORT_BLA");


(you can use an enum for message types...)

No comments: