use of uk.gov.justice.services.messaging.jms.exception.JmsEnvelopeSenderException in project microservice_framework by CJSCommonPlatform.
the class DefaultJmsEnvelopeSender method send.
/**
* Sends envelope to the destination via JMS.
*
* @param envelope envelope to be sent.
* @param destination JMS destination for the envelope.
*/
@Override
public void send(final JsonEnvelope envelope, final Destination destination) {
traceLogger.trace(LOGGER, () -> format("Sending JMS message: %s to %s", envelope, destination.toString()));
try (Connection connection = connectionFactory.createConnection();
Session session = connection.createSession(false, AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination)) {
producer.send(envelopeConverter.toMessage(envelope, session));
} catch (JMSException e) {
throw new JmsEnvelopeSenderException(format("Exception while sending envelope with name %s", envelope.metadata().name()), e);
}
traceLogger.trace(LOGGER, () -> format("Sent JMS message: %s to %s", envelope, destination.toString()));
}
use of uk.gov.justice.services.messaging.jms.exception.JmsEnvelopeSenderException in project microservice_framework by CJSCommonPlatform.
the class DefaultJmsEnvelopeSender method send.
/**
* Sends envelope to the destination via JMS.
*
* @param envelope envelope to be sent.
* @param destinationName JNDI name of the JMS destination.
*/
@Override
public void send(final JsonEnvelope envelope, final String destinationName) {
try {
final Destination destination = (Destination) namingContext.lookup(destinationName);
send(envelope, destination);
} catch (NamingException e) {
throw new JmsEnvelopeSenderException(format("Exception while looking up JMS destination name %s", destinationName), e);
}
}
Aggregations