Dynamically change jmsSelector

2019-08-17 17:59发布

问题:

Is there a way to use a property read from a config file to fill propertyValue in JMS selector? As an example I have:

@ActivationConfigProperty(propertyName = "messageSelector", propertyValue = 
JMSSelector.ITEM_SELECTOR)

Where JMSSelector.ITEM_SELECTOR is a String defined as:

public static final String ITEM_SELECTOR = "type = 'S_TYPE' OR type  = 'M_TYPE'"

Let's say that I have another new type other than "S_TYPE" and "M_TYPE", and I have it in a config file

MYTYPES = S_TYPE,M_TYPE,G_TYPE

Is there a way to load it dynamically without modifying my code and redeploy it?

回答1:

I'll answer my own question, I didn't find a way to dinamically read from a config file because jmsselector String is static. Otherwise I found this https://timjansen.github.io/jarfiller/guide/jms/selectors.xhtml and my solution is

public static final String ITEM_SELECTOR = "'tipe LIKE '%_TYPE'"

hope someone will be pleased



标签: java jms