Search in sources :

Example 1 with MQMessageNotWriteableRuntimeException

use of com.sun.messaging.jms.MQMessageNotWriteableRuntimeException in project openmq by eclipse-ee4j.

the class JMSProducerImpl method send.

@Override
public JMSProducer send(Destination destination, Map<String, Object> payload) {
    contextImpl.checkNotClosed();
    configureMessageProducer();
    MapMessage mapMessage = contextImpl.createMapMessage();
    configureMessage(mapMessage);
    if (payload != null) {
        try {
            for (Iterator<Entry<String, Object>> entryIter = payload.entrySet().iterator(); entryIter.hasNext(); ) {
                Entry<String, Object> thisEntry = entryIter.next();
                mapMessage.setObject(thisEntry.getKey(), thisEntry.getValue());
            }
        } catch (MessageNotWriteableException e) {
            throw new MQMessageNotWriteableRuntimeException(e);
        } catch (MessageFormatException e) {
            throw new MQMessageFormatRuntimeException(e);
        } catch (JMSException e) {
            throw new MQRuntimeException(e);
        }
    }
    try {
        if (completionListener == null) {
            contextImpl.getMessageProducer().send(destination, mapMessage);
        } else {
            contextImpl.getMessageProducer().send(destination, mapMessage, completionListener);
        }
    } catch (InvalidDestinationException e) {
        throw new MQInvalidDestinationRuntimeException(e);
    } catch (MessageFormatException e) {
        throw new MQMessageFormatRuntimeException(e);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
    return this;
}
Also used : MessageFormatException(jakarta.jms.MessageFormatException) MQMessageFormatRuntimeException(com.sun.messaging.jms.MQMessageFormatRuntimeException) MapMessage(jakarta.jms.MapMessage) MQInvalidDestinationRuntimeException(com.sun.messaging.jms.MQInvalidDestinationRuntimeException) InvalidDestinationException(jakarta.jms.InvalidDestinationException) JMSException(jakarta.jms.JMSException) MessageNotWriteableException(jakarta.jms.MessageNotWriteableException) Entry(java.util.Map.Entry) MQMessageNotWriteableRuntimeException(com.sun.messaging.jms.MQMessageNotWriteableRuntimeException) AdministeredObject(com.sun.messaging.AdministeredObject) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 2 with MQMessageNotWriteableRuntimeException

use of com.sun.messaging.jms.MQMessageNotWriteableRuntimeException in project openmq by eclipse-ee4j.

the class JMSProducerImpl method send.

@Override
public JMSProducer send(Destination destination, byte[] payload) {
    contextImpl.checkNotClosed();
    configureMessageProducer();
    BytesMessage bytesMessage = contextImpl.createBytesMessage();
    configureMessage(bytesMessage);
    if (payload != null) {
        try {
            bytesMessage.writeBytes(payload);
        } catch (MessageNotWriteableException e) {
            throw new MQMessageNotWriteableRuntimeException(e);
        } catch (JMSException e) {
            throw new MQRuntimeException(e);
        }
    }
    try {
        if (completionListener == null) {
            contextImpl.getMessageProducer().send(destination, bytesMessage);
        } else {
            contextImpl.getMessageProducer().send(destination, bytesMessage, completionListener);
        }
    } catch (InvalidDestinationException e) {
        throw new MQInvalidDestinationRuntimeException(e);
    } catch (MessageFormatException e) {
        throw new MQMessageFormatRuntimeException(e);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
    return this;
}
Also used : MessageFormatException(jakarta.jms.MessageFormatException) MQMessageNotWriteableRuntimeException(com.sun.messaging.jms.MQMessageNotWriteableRuntimeException) MQMessageFormatRuntimeException(com.sun.messaging.jms.MQMessageFormatRuntimeException) MQInvalidDestinationRuntimeException(com.sun.messaging.jms.MQInvalidDestinationRuntimeException) InvalidDestinationException(jakarta.jms.InvalidDestinationException) BytesMessage(jakarta.jms.BytesMessage) JMSException(jakarta.jms.JMSException) MessageNotWriteableException(jakarta.jms.MessageNotWriteableException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Aggregations

MQInvalidDestinationRuntimeException (com.sun.messaging.jms.MQInvalidDestinationRuntimeException)2 MQMessageFormatRuntimeException (com.sun.messaging.jms.MQMessageFormatRuntimeException)2 MQMessageNotWriteableRuntimeException (com.sun.messaging.jms.MQMessageNotWriteableRuntimeException)2 MQRuntimeException (com.sun.messaging.jms.MQRuntimeException)2 InvalidDestinationException (jakarta.jms.InvalidDestinationException)2 JMSException (jakarta.jms.JMSException)2 MessageFormatException (jakarta.jms.MessageFormatException)2 MessageNotWriteableException (jakarta.jms.MessageNotWriteableException)2 AdministeredObject (com.sun.messaging.AdministeredObject)1 BytesMessage (jakarta.jms.BytesMessage)1 MapMessage (jakarta.jms.MapMessage)1 Entry (java.util.Map.Entry)1