[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to browse / search message in topic by consumertemplate

Hey All,

I need to use consumertemplate to search message

i did something like below. but i have two concerns

1) it could not search particular message based on messageid

2) i just want to search or browse message, i dont want to digest it

any suggestions or hints are more than welcome!

public void process(Exchange exchange) throws Exception {
Result result = new Result();
try {
result.setMessageBody("MESSAGE NOT FOUND");
if (exchange != null && exchange.getIn() != null) {
String operationName =
exchange.getIn().getHeader(CxfConstants.OPERATION_NAME, String.class);
MessageContentsList msgList = (MessageContentsList)
if (operationName.equalsIgnoreCase("getMessageFromTopic")) {
String topic = (String) msgList.get(0);
String messagid = (String) msgList.get(1);
     Exchange ex = consumerTemplate.receive("activemq:topic:"+topic);
     String messageid=  (String)ex.getIn().getHeader("JMSMessageID");
     String messageBody=ex.getIn().getBody(String.class);
} catch (Exception e) {
LOG.error("erorr happened ", e);
throw e;