Example usage for javax.jms ObjectMessage getJMSReplyTo

List of usage examples for javax.jms ObjectMessage getJMSReplyTo

Introduction

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

Prototype


Destination getJMSReplyTo() throws JMSException;

Source Link

Document

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

Usage

From source file:com.alliander.osgp.signing.server.infra.messaging.SigningServerRequestMessageListener.java

@Override
public void onMessage(final Message message) {
    try {//from  w ww  . j av  a 2 s  .  com
        final ObjectMessage objectMessage = (ObjectMessage) message;
        final Destination replyToQueue = objectMessage.getJMSReplyTo();
        final RequestMessage requestMessage = (RequestMessage) objectMessage.getObject();
        final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = (UnsignedOslpEnvelopeDto) requestMessage
                .getRequest();
        final String correlationUid = objectMessage.getJMSCorrelationID();
        final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);

        LOGGER.info("Received message of type: {}, for device: {} with correlationId: {} and replyToQueue: {}",
                objectMessage.getJMSType(), deviceIdentification, correlationUid, replyToQueue.toString());

        LOGGER.debug("-----------------------------------------------------------------------------");
        LOGGER.debug("unsignedOslpEnvelopeDto.getCorrelationUid() : {}",
                unsignedOslpEnvelopeDto.getCorrelationUid());
        LOGGER.debug("unsignedOslpEnvelopeDto.getDeviceId() : {}", unsignedOslpEnvelopeDto.getDeviceId());
        LOGGER.debug("unsignedOslpEnvelopeDto.getDomain() : {}", unsignedOslpEnvelopeDto.getDomain());
        LOGGER.debug("unsignedOslpEnvelopeDto.getDomainVersion() : {}",
                unsignedOslpEnvelopeDto.getDomainVersion());
        LOGGER.debug("unsignedOslpEnvelopeDto.getIpAddress() : {}", unsignedOslpEnvelopeDto.getIpAddress());
        LOGGER.debug("unsignedOslpEnvelopeDto.getMessageType() : {}", unsignedOslpEnvelopeDto.getMessageType());
        LOGGER.debug("unsignedOslpEnvelopeDto.getOrganisationIdentification() : {}",
                unsignedOslpEnvelopeDto.getOrganisationIdentification());
        LOGGER.debug("unsignedOslpEnvelopeDto.getPayloadMessage() : {}",
                unsignedOslpEnvelopeDto.getPayloadMessage().toString());
        LOGGER.debug("unsignedOslpEnvelopeDto.getRetryCount() : {}", unsignedOslpEnvelopeDto.getRetryCount());
        LOGGER.debug("unsignedOslpEnvelopeDto.getSequenceNumber() : {}",
                unsignedOslpEnvelopeDto.getSequenceNumber());
        LOGGER.debug("unsignedOslpEnvelopeDto.isScheduled() : {}", unsignedOslpEnvelopeDto.isScheduled());
        LOGGER.debug("-----------------------------------------------------------------------------");

        this.signingService.sign(unsignedOslpEnvelopeDto, correlationUid, deviceIdentification, replyToQueue);

    } catch (final JMSException ex) {
        LOGGER.error("Exception: {} ", ex.getMessage(), ex);
    }
}

From source file:org.jbpm.bpel.integration.jms.RequestListener.java

public void onMessage(Message message) {
    if (!(message instanceof ObjectMessage)) {
        log.error("received non-object message: " + message);
        return;//from  w  w  w .  j a  va 2  s .  c o  m
    }
    try {
        ObjectMessage request = (ObjectMessage) message;
        log.debug("delivering request: " + RequestListener.messageToString(request));
        /*
         * LEAK WARNING. This listener must be removed from the integration control before passing
         * control to the inbound message activity, because loop structures could execute the same
         * activity again and overwrite the entry in the integration control with a new listener. If
         * removeRequestListener() was invoked after passing control to the activity, the new listener
         * would get removed instead of this, leaving the listener open but unreachable from
         * application code. CODE ORDER NOTE. Removing this listener early in the process prevents any
         * other thread from closing it. This effect is desirable because the orderly shutdown
         * mechanism of JMS never stops a running listener anyway. Furthermore, the mechanism is
         * specified to *block* the other thread until this listener returns.
         */
        if (oneShot)
            integrationControl.removeRequestListener(this);

        deliverRequest((Map) request.getObject(), request.getJMSReplyTo(), request.getJMSMessageID());
        request.acknowledge();

        if (oneShot)
            close();
    } catch (JMSException e) {
        log.error("request delivery failed due to jms exception, giving up", e);
    } catch (RuntimeException e) {
        if (isRecoverable(e)) {
            log.warn("request delivery failed due to recoverable exception, attempting recovery");
            try {
                // recover the session manually
                jmsSession.recover();
            } catch (JMSException je) {
                log.error("request recovery failed, giving up", je);
            }
        } else
            log.error("request delivery failed due to non-recoverable exception, giving up", e);
    }
}

From source file:org.jbpm.bpel.integration.jms.StartListener.java

public void onMessage(Message message) {
    if (!(message instanceof ObjectMessage)) {
        log.error("received non-object jms message: " + message);
        return;// w w w  .j  a va 2s . c om
    }

    try {
        ObjectMessage request = (ObjectMessage) message;
        log.debug("delivering request: " + RequestListener.messageToString(request));

        /*
         * CODE ORDER NOTE. Removing this listener early in the process prevents any other thread from
         * closing it. This effect is desirable because the orderly shutdown mechanism of JMS never
         * stops a running listener anyway. Furthermore, the mechanism is specified to *block* the
         * other thread until this listener returns.
         */
        integrationControl.removeStartListener(this);

        // BPEL-282 create new start listener to improve concurrency
        StartListener startListener = new StartListener(this);
        startListener.open();

        deliverRequest((Map) request.getObject(), request.getJMSReplyTo(), request.getJMSMessageID());
        request.acknowledge();

        close();
    } catch (JMSException e) {
        log.error("request delivery failed due to jms exception, giving up", e);
    } catch (RuntimeException e) {
        if (RequestListener.isRecoverable(e)) {
            log.warn("request delivery failed due to recoverable exception, attempting recovery");
            try {
                // recover the session manually
                jmsSession.recover();
            } catch (JMSException je) {
                log.error("request recovery failed, giving up", je);
            }
        } else
            log.error("request delivery failed due to non-recoverable exception, giving up", e);
    }
}

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

public boolean handleRequest(MessageContext messageContext) throws JAXRPCException, SOAPFaultException {
    /*//from w w w  . ja v a 2  s . c  o m
     * WSEE 1.1 section 6.2.2.1: If Handler instances are pooled, they must be pooled by Port
     * component. This is because Handlers may retain non-client specific state across method calls
     * that are specific to the Port component.
     */
    if (integrationControl == null) {
        /*
         * COMPLIANCE NOTE: the state initialized in this call is port-component specific, but
         * non-client specific
         */
        lookupEndpointMetadata(messageContext);
    }

    JbpmContext jbpmContext = integrationControl.getIntegrationServiceFactory().getJbpmConfiguration()
            .createJbpmContext();
    try {
        Session jmsSession = integrationControl.createJmsSession();
        try {
            SOAPMessage soapMessage = ((SOAPMessageContext) messageContext).getMessage();
            ObjectMessage jmsRequest = sendRequest(soapMessage, jmsSession, jbpmContext);

            Destination replyTo = jmsRequest.getJMSReplyTo();
            if (replyTo != null) {
                ObjectMessage jmsResponse = receiveResponse(jmsSession, replyTo, jmsRequest.getJMSMessageID(),
                        jbpmContext);

                // remember operation name and message parts for handling response
                messageContext.setProperty(OPERATION_NAME_PROP,
                        jmsRequest.getStringProperty(IntegrationConstants.OPERATION_NAME_PROP));
                messageContext.setProperty(MESSAGE_PARTS_PROP, jmsResponse.getObject());

                // is response a fault?
                String faultName = jmsResponse.getStringProperty(IntegrationConstants.FAULT_NAME_PROP);
                if (faultName != null) {
                    // remember fault name for handling fault
                    messageContext.setProperty(FAULT_NAME_PROP, faultName);
                    throw new SOAPFaultException(SoapBindConstants.CLIENT_FAULTCODE,
                            SoapBindConstants.BUSINESS_FAULTSTRING, null, null);
                }
            }
        } finally {
            jmsSession.close();
        }
    }
    /*
     * NO need to set jbpm context as rollback only for any exception, since operations in try-block
     * only read definitions from database
     */
    catch (SOAPFaultException e) {
        log.debug("request caused a fault", e);
        messageContext.setProperty(FAULT_EXCEPTION_PROP, e);
    } catch (SOAPException e) {
        /*
         * BP 1.2 R2724: If an INSTANCE receives an envelope that is inconsistent with its WSDL
         * description, it SHOULD generate a soap:Fault with a faultcode of "Client", unless a
         * "MustUnderstand" or "VersionMismatch" fault is generated.
         */
        log.debug("incoming soap message carries invalid content", e);
        messageContext.setProperty(FAULT_EXCEPTION_PROP,
                new SOAPFaultException(SoapBindConstants.CLIENT_FAULTCODE, e.getMessage(), null, null));
    } catch (JMSException e) {
        throw new JAXRPCException("message delivery failed", e);
    } finally {
        jbpmContext.close();
    }
    return true;
}