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

The following are Jave code examples for showing how to use getJMSReplyTo() 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: xsharing-services-router   File: AbstractSharingListener.java   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) {
        getLogger().warn(
                "Failed to read JMSCorrelationID/JMSReplyTo. " +
                "Will not process request. Exception message = {}", e.getMessage());
        return false;
    }

    return true;
}
 
Example 2
Project: amqp-kafka-demo   File: Server.java   Source Code and License Vote up 4 votes
@Override
public void onMessage(Message request) {

  try {
    LOG.info("Received '{}' request on '{}'", ((TextMessage) request).getText(), request.getJMSDestination());

    // get the replyTo from the request as response destination
    Destination replyDestination = request.getJMSReplyTo();

    // create and send response
    TextMessage replyMessage = session.createTextMessage("MyResponse");

    replyProducer.send(replyDestination, replyMessage, this);

  } catch (JMSException e) {
    e.printStackTrace();
  }

}