Java Code Examples for javax.jms.Message.getJMSCorrelationID()

The following are Jave code examples for showing how to use getJMSCorrelationID() of the javax.jms.Message class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: servicebuilder   File:   Source Code and License Vote up 6 votes
private void handleMessage(MessageHandler handler, Message message, Session session) {
    if (! (message instanceof TextMessage)) {
    TextMessage textMessage = (TextMessage) message;
    String text = null;
    String requestId = UUID.randomUUID().toString();
    try {
        text = textMessage.getText();
        if (StringUtils.isNotEmpty(message.getJMSCorrelationID())) {
            requestId = message.getJMSCorrelationID();

        MDC.put(X_OBOS_REQUEST_ID, requestId);"Received message '{}'", text);

        handler.handle(new ObjectMapper().readTree(text));
    } catch (Exception e) {
        log.error("Failed to process message", e);
        try {
            TextMessage errorMessage = session.createTextMessage(text);

            Queue queue = session.createQueue(queueError);
            MessageProducer errorProducer = session.createProducer(queue);
        } catch (JMSException jmse) {
            log.error("Failed to create error message", jmse);
    } finally {
Example 2
Project: xsharing-services-router   File:   Source Code and License Vote up 6 votes
 * Since we use a request/response communication style with the client,
 * we must ensure that tha appropriate fields are set.
private boolean isValidRequestResponse(Message incoming) {
    try {
        if (incoming.getJMSCorrelationID() == null) {
            getLogger().warn("JMSCorrelationID is not set! Will not process request");
            return false;

        if (incoming.getJMSReplyTo() == null) {
            getLogger().warn("JMSReplyTo is not set! Will not process request");
            return false;
    } catch (JMSException e) {
                "Failed to read JMSCorrelationID/JMSReplyTo. " +
                "Will not process request. Exception message = {}", e.getMessage());
        return false;

    return true;