Package org.apache.tuscany.sca.binding.jms.context

Examples of org.apache.tuscany.sca.binding.jms.context.JMSBindingContext


    }
   
    public Message invokeRequest(Message msg) {
        try {
            // get the jms context
            JMSBindingContext context = msg.getBindingContext();
            Session session = context.getJmsSession();
           
            javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
           
            msg.setBody(requestMsg);
           
            requestMsg.setJMSReplyTo(context.getReplyToDestination());
           
            return msg;
        } catch (JMSException e) {
            throw new JMSBindingException(e);
        }
View Full Code Here


    public Message invoke(Message msg) {
        try {
            return invokeResponse(next.invoke(invokeRequest(msg)));
        } catch (Throwable e) {
            logger.log(Level.SEVERE, "Exception invoking service '" + service.getName(), e);
            JMSBindingContext context = msg.getBindingContext();
            javax.jms.Message replyJMSMsg = responseMessageProcessor.createFaultMessage(context.getJmsResponseSession(),
                                                                                        (Throwable)e);
            msg.setBody(replyJMSMsg);
            invokeResponse(msg);
            return msg;
        } finally {
View Full Code Here

        }
    }   
   
    public Message invokeRequest(Message msg) {
        try {
            JMSBindingContext context = msg.getBindingContext();
            javax.jms.Message requestJMSMsg = context.getJmsMsg();
           
            EndpointReference from = new EndpointReferenceImpl(null);
            msg.setFrom(from);
            from.setCallbackEndpoint(new EndpointReferenceImpl("/")); // TODO: whats this for?
            ReferenceParameters parameters = from.getReferenceParameters();
View Full Code Here

            Operation operation = msg.getOperation();
            if (operation != null && operation.isNonBlocking()) {
                return msg;
            }

            JMSBindingContext context = msg.getBindingContext();
            Session session = context.getJmsResponseSession();
            javax.jms.Message requestJMSMsg = context.getJmsMsg();
            javax.jms.Message responseJMSMsg = msg.getBody();
           
            Destination replyDest = requestJMSMsg.getJMSReplyTo();
            if (replyDest == null) {
                if (jmsBinding.getResponseDestinationName() != null) {
                    try {
                        replyDest = jmsResourceFactory.lookupDestination(jmsBinding.getResponseDestinationName());
                    } catch (NamingException e) {
                        throw new JMSBindingException("Exception lookingup response destination", e);
                    }
                }
            }

            if (replyDest == null) {
                // assume no reply is expected
                if (msg.getBody() != null) {
                    logger.log(Level.FINE, "JMS service '" + service.getName() + "' dropped response as request has no replyTo");
                }
                return msg;
            }
           
            responseJMSMsg.setJMSDeliveryMode(requestJMSMsg.getJMSDeliveryMode());
            responseJMSMsg.setJMSPriority(requestJMSMsg.getJMSPriority());
   
            if (correlationScheme == null ||
                JMSBindingConstants.CORRELATE_MSG_ID.equalsIgnoreCase(correlationScheme)) {
                responseJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSMessageID());
            } else if (JMSBindingConstants.CORRELATE_CORRELATION_ID.equalsIgnoreCase(correlationScheme)) {
                responseJMSMsg.setJMSCorrelationID(requestJMSMsg.getJMSCorrelationID());
            }               
                      
            MessageProducer producer = session.createProducer(replyDest);
           
            // Set jms header attributes in producer, not message.
            int deliveryMode = requestJMSMsg.getJMSDeliveryMode();
            producer.setDeliveryMode(deliveryMode);
            int deliveryPriority = requestJMSMsg.getJMSPriority();
            producer.setPriority(deliveryPriority);
   
            producer.send((javax.jms.Message)msg.getBody());
   
            producer.close();
            context.closeJmsResponseSession();
           
            return msg;
   
        } catch (JMSException e) {
            throw new JMSBindingException(e);
View Full Code Here

   
    public Message invoke(Message msg) {
        Message responseMsg = invokeRequest(msg);
       
        // get the jms context
        JMSBindingContext context = msg.getBindingContext();
       
        if (context.getReplyToDestination() == null) {
            responseMsg.setBody(null);
        } else {
            responseMsg = invokeResponse(msg);
        }
       
View Full Code Here

    }
   
    public Message invokeRequest(Message msg) {
        try {       
            // get the jms context
            JMSBindingContext context = msg.getBindingContext();
            Session session = context.getJmsSession();
           
            MessageProducer producer = session.createProducer(context.getRequestDestination());
   
            // Set JMS header attributes in producer, not message.
            String opName = msg.getOperation().getName();
            if (jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName()) != null) {
                producer.setTimeToLive(jmsBinding.getOperationJMSTimeToLive(msg.getOperation().getName()));
View Full Code Here

            throw new JMSBindingException(e);
        }
    }
   
    public Message invokeResponse(Message msg) {
        JMSBindingContext context = msg.getBindingContext();
        try {
            Session session = context.getJmsResponseSession();
           
            javax.jms.Message requestMessage = (javax.jms.Message)msg.getBody();
                     
            String msgSelector = "JMSCorrelationID = '" +
                                 requestMessage.getJMSMessageID() +
                                 "'";
            MessageConsumer consumer = session.createConsumer(context.getReplyToDestination(), msgSelector)
           
            javax.jms.Message replyMsg;
            try {
                context.getJmsResourceFactory().startConnection();
                //jmsResourceFactory.startConnection();
                replyMsg = consumer.receive(context.getTimeToLive());
            } finally {
                consumer.close();
            }
            if (replyMsg == null) {
                throw new JMSBindingException("No reply message received on " +
                                              context.getReplyToDestination() +
                                              " for message id " +
                                              requestMessage.getJMSMessageID());
            }
           
            msg.setBody(replyMsg);
            return msg;
        } catch (JMSException e) {
            throw new JMSBindingException(e);
        } catch (NamingException e) {
            throw new JMSBindingException(e);
        } finally {
            try {
                context.closeJmsResponseSession();
                if (jmsResourceFactory.isConnectionClosedAfterUse())
                    jmsResourceFactory.closeResponseConnection();
            } catch (JMSException e) {
            }
        }
View Full Code Here

        return msg;
    }
   
    public Message invokeRequest(Message msg) {
        // get the jms context
        JMSBindingContext context = msg.getBindingContext();
        javax.jms.Message jmsMsg = context.getJmsMsg();

        Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
        msg.setBody(new Object[]{requestPayload});
                
        return msg;
View Full Code Here

        return msg;
    }
   
    public Message invokeResponse(Message msg) {
        // get the jms context
        JMSBindingContext context = msg.getBindingContext();
        Session session = context.getJmsResponseSession();

        javax.jms.Message responseJMSMsg;
        if (msg.isFault()) {
            responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
        } else {
View Full Code Here

    }
   
    public Message invokeRequest(Message msg) {
        try {
            // get the jms context
            JMSBindingContext context = msg.getBindingContext();
            Session session = context.getJmsSession();
           
            Object[] requestParams = msg.getBody();
            javax.jms.Message requestMsg = null;
            if (requestParams != null && requestParams.length > 0 ){
                requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, requestParams[0]);
            } else {
              requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, null);
            }
            msg.setBody(requestMsg);
           
            requestMsg.setJMSReplyTo(context.getReplyToDestination());
           
            return msg;
        } catch (JMSException e) {
            throw new JMSBindingException(e);
        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.binding.jms.context.JMSBindingContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.