0

Is there any way to put interceptor in jms listener..requirement is to store the request and response while reading and writing to message queue

@JmsListener(destination = "${ibm.mq.queueName}", containerFactory = "containerFactory")
    public void readAndProcessMessage(Message<?> message) throws Exception {
        UnProcessedEvent unProcessedEvent;
        String eventMessage = message.getPayload().toString();
        log.info("Received an event: " + eventMessage);
        try {
            String iban = getIban(eventMessage);
            // Identifying Topic
            for (Mandate mandate : configProperties.getMandates()) {
                for (Topic topic : mandate.getTopic()) {
                    if (topic.getAccountNumber().equals(iban)) {
                        publisherService.publishEvent(iban, eventMessage);
                        return;
                    }
                }
            }
            unProcessedEvent = UnProcessedEvent.builder().incomingReqPayload((eventMessage)).reason("No Topic Found")
                    .reasonCode(HttpStatus.BAD_REQUEST.toString()).build();
            unprocessedEventRepository.save(unProcessedEvent);
        } catch (JAXBException e) {
            log.info("Exception while parsing the event message: " + e.getMessage());
            unProcessedEvent = UnProcessedEvent.builder().incomingReqPayload((eventMessage)).reason("Bad Request")
                    .reasonCode(HttpStatus.BAD_REQUEST.toString()).build();
            unprocessedEventRepository.save(unProcessedEvent);
        }
    }
hello1693
  • 99
  • 3
  • 12
  • Can you edit the title/subject and the body/content of your question ? Title should contain regarding what you are asking. And the body should contain the question (or the requirement). Also you haven't specified what is the issue in the program or what problem you are facing in it. Are you getting any exception/error or logical issue in any line/method something like that. Please specify – smilyface Feb 15 '19 at 04:51
  • Do you missed any code with interceptor ? I couldn't find any interceptor to which you want to attach the jmsListener – smilyface Feb 15 '19 at 04:55
  • @smilyface, I don't know if interceptor can be put in jmslistener.. I will be using zalando Logbook as an interceptor to store the message in database – hello1693 Feb 15 '19 at 05:06

0 Answers0