Search in sources :

Example 6 with MQMessageFormatRuntimeException

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

the class JMSProducerImpl method checkAndSetProperty.

private void checkAndSetProperty(String name, Object value) {
    // Verify that the specified property name is not null and is not empty
    MessageImpl.checkPropertyNameSet(name);
    // Verify that the specified value is a valid message property value
    try {
        MessageImpl.checkValidPropertyValue(name, value);
    } catch (MessageFormatException e) {
        throw new MQMessageFormatRuntimeException(e);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
    // Verify that the specified property name is allowed
    try {
        MessageImpl.checkValidPropertyName(name);
    } catch (JMSException e) {
        throw new MQRuntimeException(e);
    }
    // all OK, now set the property
    properties.put(name, value);
}
Also used : MessageFormatException(jakarta.jms.MessageFormatException) MQMessageFormatRuntimeException(com.sun.messaging.jms.MQMessageFormatRuntimeException) JMSException(jakarta.jms.JMSException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 7 with MQMessageFormatRuntimeException

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

the class JMSProducerImpl method send.

@Override
public JMSProducer send(Destination destination, Serializable payload) {
    contextImpl.checkNotClosed();
    configureMessageProducer();
    ObjectMessage objectMessage = contextImpl.createObjectMessage(payload);
    configureMessage(objectMessage);
    try {
        if (completionListener == null) {
            contextImpl.getMessageProducer().send(destination, objectMessage);
        } else {
            contextImpl.getMessageProducer().send(destination, objectMessage, 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) ObjectMessage(jakarta.jms.ObjectMessage) MQInvalidDestinationRuntimeException(com.sun.messaging.jms.MQInvalidDestinationRuntimeException) InvalidDestinationException(jakarta.jms.InvalidDestinationException) JMSException(jakarta.jms.JMSException) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 8 with MQMessageFormatRuntimeException

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

the class JMSProducerImpl method getByteProperty.

@Override
public byte getByteProperty(String name) {
    contextImpl.checkNotClosed();
    MessageImpl.checkPropertyNameSet(name);
    try {
        return ValueConvert.toByte(properties.get(name));
    } catch (MessageFormatException e) {
        throw new MQMessageFormatRuntimeException(e);
    }
}
Also used : MessageFormatException(jakarta.jms.MessageFormatException) MQMessageFormatRuntimeException(com.sun.messaging.jms.MQMessageFormatRuntimeException)

Example 9 with MQMessageFormatRuntimeException

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

the class JMSProducerImpl method send.

@Override
public JMSProducer send(Destination destination, String payload) {
    contextImpl.checkNotClosed();
    configureMessageProducer();
    TextMessage textMessage;
    if (payload == null) {
        textMessage = contextImpl.createTextMessage();
    } else {
        textMessage = contextImpl.createTextMessage(payload);
    }
    configureMessage(textMessage);
    try {
        if (completionListener == null) {
            contextImpl.getMessageProducer().send(destination, textMessage);
        } else {
            contextImpl.getMessageProducer().send(destination, textMessage, 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) MQInvalidDestinationRuntimeException(com.sun.messaging.jms.MQInvalidDestinationRuntimeException) InvalidDestinationException(jakarta.jms.InvalidDestinationException) JMSException(jakarta.jms.JMSException) TextMessage(jakarta.jms.TextMessage) MQRuntimeException(com.sun.messaging.jms.MQRuntimeException)

Example 10 with MQMessageFormatRuntimeException

use of com.sun.messaging.jms.MQMessageFormatRuntimeException 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

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