Search in sources :

Example 6 with MessageConversionException

use of org.springframework.jms.support.converter.MessageConversionException in project opennms by OpenNMS.

the class NrtBrokerJms method receiveMeasurementSets.

@Override
public List<MeasurementSet> receiveMeasurementSets(String nrtCollectionTaskId) {
    List<MeasurementSet> result = new ArrayList<MeasurementSet>();
    m_jmsTemplate.setReceiveTimeout(125);
    Message message = m_jmsTemplate.receive(nrtCollectionTaskId);
    while (message != null) {
        MeasurementSet measurementSet;
        try {
            measurementSet = (MeasurementSet) simpleMessageConverter.fromMessage(message);
            result.add(measurementSet);
        } catch (JMSException ex) {
            logger.error("Error receiving messages", ex);
            return result;
        } catch (MessageConversionException ex) {
            logger.error("Error converting messages", ex);
            return result;
        }
        message = m_jmsTemplate.receive(nrtCollectionTaskId);
    }
    return result;
}
Also used : MessageConversionException(org.springframework.jms.support.converter.MessageConversionException) Message(javax.jms.Message) ArrayList(java.util.ArrayList) JMSException(javax.jms.JMSException) MeasurementSet(org.opennms.nrtg.api.model.MeasurementSet)

Example 7 with MessageConversionException

use of org.springframework.jms.support.converter.MessageConversionException in project av-service by dvoraka.

the class JmsComponent method onMessage.

@Override
public void onMessage(Message message) {
    requireNonNull(message, "Message must not be null!");
    AvMessage avMessage;
    try {
        avMessage = (AvMessage) messageConverter.fromMessage(message);
        messageInfoService.save(avMessage, AvMessageSource.JMS_COMPONENT_IN, serviceId);
    } catch (JMSException | MessageConversionException e) {
        log.warn("Conversion error!", e);
        return;
    }
    notifyListeners(listeners, avMessage);
}
Also used : MessageConversionException(org.springframework.jms.support.converter.MessageConversionException) JMSException(javax.jms.JMSException) AvMessage(dvoraka.avservice.common.data.AvMessage)

Aggregations

MessageConversionException (org.springframework.jms.support.converter.MessageConversionException)7 JMSException (javax.jms.JMSException)3 Message (javax.jms.Message)3 Session (javax.jms.Session)3 Test (org.junit.Test)3 SimpleMessageConverter (org.springframework.jms.support.converter.SimpleMessageConverter)3 HashMap (java.util.HashMap)2 BytesMessage (javax.jms.BytesMessage)2 MapMessage (javax.jms.MapMessage)2 MeasurementSet (org.opennms.nrtg.api.model.MeasurementSet)2 AvMessage (dvoraka.avservice.common.data.AvMessage)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ObjectMessage (javax.jms.ObjectMessage)1 QueueSession (javax.jms.QueueSession)1 TextMessage (javax.jms.TextMessage)1 CollectionJob (org.opennms.nrtg.api.model.CollectionJob)1 LightweightMeasurementSet (org.opennms.nrtg.api.model.LightweightMeasurementSet)1 MessageConverter (org.springframework.jms.support.converter.MessageConverter)1 MessagingMessageConverter (org.springframework.jms.support.converter.MessagingMessageConverter)1