@RequestMapping("/process/{userInput}")
public Integer purgeMessage(@PathVariable string queueName) {
if(StringUtils.isNotEmpty(queueName) && queueName.length <=10)
Integer count = service.publishMessage(queueName);
else
throw new RuntimeException("not valid");
}
public Integer publishMessage(String queueName) {
Integer preCount = 0;
// return number of count in a queue
preCount = jmsTemplate.browse(queueName);// not full code written
Integer count = null != preCount ? preCount : 0;
while (count > 0) {
jmsTemplate.receive(queueName);
count--;
}
Integer postCount = jmsTemplate.browse(queueName);// not full code written
return postCount;
}
I tried validating input string and set maximum limit in while also but still I am facing this issue