Is there a specific way to accomplish this? I tried to find a solution on here but couldn't find what I need. I have a Spring Boot application that will be accepting multiple arguments from the command line. The argument in question is the queue name (i.e. the destination). It can be one of several of our many queues. The JmsListener
is in the form
@JmsListener(destination="dest_goes_here")
public void processOrder(Message message){. . .}
I have a class that basically looks like this
public class Arguments {
private static queue
private static antoherArg
:
:
getters and setters
}
And what I would like to say is destination = Arguments.getQueue()
, but it seems destination
can only be a static final
variable? I assume this because the error presents a little tooltip that alludes to that.
I also tested it, as I have yet another class called Constants
, that obvioulsy contains constants, and if I hard code the queue name as public static final String QUEUE = "MyQ";
then say destination = Constants.QUEUE
it is ok with that.
So then I assumed I could do something like this in my listener class private static final String QUEUE = Arguments.getQueue();
But it doesn't like that either. Alas, I am stumped.
So really two questions here if anyone is willing to knowledge share. Why is the @JmsListener
ok with having destination
set to my second solution, but not the first and the last?
And then the main question (that I'd prefer you answer over the first) is, what strategies can I make use of to set destination to a variable that originates from the command line (i.e. be dynamic)?
Edit: To clarify, I cannot keep the value in my Constants
class, as the value will be coming from the command line and needs to be passed to the JmsListener class to be used as the destination
.