Example usage for javax.jms ObjectMessage setJMSReplyTo

List of usage examples for javax.jms ObjectMessage setJMSReplyTo

Introduction

In this page you can find the example usage for javax.jms ObjectMessage setJMSReplyTo.

Prototype


void setJMSReplyTo(Destination replyTo) throws JMSException;

Source Link

Document

Sets the Destination object to which a reply to this message should be sent.

Usage

From source file:biz.fstechnology.micro.common.jms.RequestMessageCreator.java

/**
 * @see org.springframework.jms.core.MessageCreator#createMessage(javax.jms.Session)
 */// w ww.  j a  va2  s.c  o m
@Override
public Message createMessage(Session session) throws JMSException {
    ObjectMessage message = session.createObjectMessage();
    message.setObject(getContents());
    message.setJMSReplyTo(getReplyTo());
    if (getRequestId() == null) {
        setRequestId(Double.toHexString(Math.random()));
    }
    message.setJMSCorrelationID(getRequestId());

    return message;
}

From source file:com.alliander.osgp.adapter.protocol.oslp.elster.infra.messaging.SigningServerRequestMessageSender.java

public void send(final RequestMessage requestMessage, final String messageType) {
    LOGGER.info("Sending request message to signing server, with reply-to-queue: {}.",
            this.replyToQueue.toString());

    this.signingServerRequestsJmsTemplate.send(new MessageCreator() {

        @Override/* w  w w  .j ava2  s .  co  m*/
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage(requestMessage);
            objectMessage.setJMSType(messageType);
            objectMessage.setJMSReplyTo(SigningServerRequestMessageSender.this.replyToQueue);
            objectMessage.setJMSCorrelationID(requestMessage.getCorrelationUid());
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION,
                    requestMessage.getOrganisationIdentification());
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION,
                    requestMessage.getDeviceIdentification());

            return objectMessage;
        }

    });
}

From source file:org.jbpm.bpel.integration.server.SoapHandler.java

protected ObjectMessage sendRequest(SOAPMessage soapMessage, Session jmsSession, JbpmContext jbpmContext)
        throws SOAPException, JMSException {
    // create a jms message to deliver the incoming content
    ObjectMessage jmsRequest = jmsSession.createObjectMessage();

    // put the partner link identified by handle in a jms property
    PartnerLinkEntry partnerLinkEntry = integrationControl.getPartnerLinkEntry(portTypeName, serviceName,
            portName);//from w  w w.  ja  va 2 s. co m
    long partnerLinkId = partnerLinkEntry.getId();
    jmsRequest.setLongProperty(IntegrationConstants.PARTNER_LINK_ID_PROP, partnerLinkId);

    Operation operation = determineOperation(soapMessage);
    if (operation == null)
        throw new SOAPException("could not determine operation to perform");

    // put the operation name in a jms property
    String operationName = operation.getName();
    jmsRequest.setStringProperty(IntegrationConstants.OPERATION_NAME_PROP, operationName);

    log.debug("received request: partnerLink=" + partnerLinkId + ", operation=" + operationName);

    // extract message content
    HashMap requestParts = new HashMap();
    formatter.readMessage(operationName, soapMessage, requestParts, MessageDirection.INPUT);
    jmsRequest.setObject(requestParts);

    // fill message properties
    BpelProcessDefinition process = integrationControl.getDeploymentDescriptor()
            .findProcessDefinition(jbpmContext);
    MessageType requestType = process.getImportDefinition()
            .getMessageType(operation.getInput().getMessage().getQName());
    fillCorrelationProperties(requestParts, jmsRequest, requestType.getPropertyAliases());

    // set up producer
    MessageProducer producer = jmsSession.createProducer(partnerLinkEntry.getDestination());
    try {
        // is the exchange pattern request/response?
        if (operation.getOutput() != null) {
            Destination replyTo = integrationControl.getIntegrationServiceFactory().getResponseDestination();
            jmsRequest.setJMSReplyTo(replyTo);

            // have jms discard request message if response timeout expires
            Number responseTimeout = getResponseTimeout(jbpmContext);
            if (responseTimeout != null)
                producer.setTimeToLive(responseTimeout.longValue());
        } else {
            // have jms discard message if one-way timeout expires
            Number oneWayTimeout = getOneWayTimeout(jbpmContext);
            if (oneWayTimeout != null)
                producer.setTimeToLive(oneWayTimeout.longValue());
        }

        // send request message
        producer.send(jmsRequest);
        log.debug("sent request: " + RequestListener.messageToString(jmsRequest));

        return jmsRequest;
    } finally {
        // release producer resources
        producer.close();
    }
}

From source file:org.oxymores.chronix.engine.Runner.java

public void sendRunDescription(RunDescription rd, Place p, PipelineJob pj) throws JMSException {
    // Always send to the node, not its hosting node.
    String qName = String.format(Constants.Q_RUNNER, p.getNode().getBrokerName());
    log.info(String.format("A command will be sent for execution on queue %s (%s)", qName, rd.getCommand()));
    Destination destination = jmsSession.createQueue(qName);

    ObjectMessage m = jmsSession.createObjectMessage(rd);
    m.setJMSReplyTo(destEndJob);
    m.setJMSCorrelationID(pj.getId());//w w w . j  a v  a  2s  . c  o  m
    producerRunDescription.send(destination, m);
    jmsSession.commit();
}

From source file:org.oxymores.chronix.engine.Runner.java

public void getParameterValue(RunDescription rd, PipelineJob pj, UUID paramId) throws JMSException {
    // Always send to the node, not its hosting node.
    Place p = pj.getPlace(ctx);//from   ww  w .j av  a 2 s  .  c  om
    String qName = String.format(Constants.Q_RUNNER, p.getNode().getBrokerName());
    log.info(String.format("A command for parameter resolution will be sent for execution on queue %s (%s)",
            qName, rd.getCommand()));
    Destination destination = jmsSession.createQueue(qName);

    ObjectMessage m = jmsSession.createObjectMessage(rd);
    m.setJMSReplyTo(destEndJob);
    m.setJMSCorrelationID(pj.getId() + "|" + paramId);
    producerRunDescription.send(destination, m);
    jmsSession.commit();
}