I have to implement a method in which there will be a listener which will read a messages from queue and then it will send those messages into table. Now my concern is that there can be 1 message or 10 messages. I have to read them one by one and dump those messages into table; I have implemented it but I doubt that the conditions I have put are not in correct order. Can you guys please advise is it the correct condition below.
@Transactional(rollbackFor = { Throwable.class })
public String dumpMesagesFromabcQueue() {
String tibcoQueueName = configuration.getSpecificConfiguration(Constants.DFR_QUEUE);
jmsTemplate.setDefaultDestinationName(tibcoQueueName);
jmsTemplate.setPubSubDomain(false);
try {
while (tibcoUtility.getQueueMessagePendingCount(tibcoQueueName) != 0) {
Message message = jmsTemplate.receive();
String messageType = null;
String cashFlowMesg = null;
if (message instanceof ObjectMessage) {
try {
ObjectMessage objMessage = (ObjectMessage) message;
String[] messageArray = (String[]) objMessage.getObject();
cashFlowMesg = messageArray[0];
messageType = messageArray[1];
abcHelper.ttt(rrr, null, ddd, eee, rrrrrr, trw, tyi, new Throwable(ero));
} catch (JMSException e) {
logger.error(" Error retriving messages from error queue to ttt queu ", e);
throw new RuntimeException(e);
}
}
}
} catch (TibjmsAdminException exp) {
String err = "<font color=red><b>Error encountered while processing queue ";
err += exp.toString();
err += "</b></font>";
return err;
}
return "<font color=blue><b>Messages consumed successfully </b></font>";
}