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

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


        return next.invoke(invokeRequest(msg));
    }   
   
    public Message invokeRequest(Message msg) {
            // get the jms context
            JMSBindingContext context = msg.getBindingContext();
            javax.jms.Message jmsMsg = context.getJmsMsg();
           
            String operationName = requestMessageProcessor.getOperationName(jmsMsg);
            Operation operation = getTargetOperation(operationName, jmsMsg);
            msg.setOperation(operation);
View Full Code Here


    }

    public Message invokeRequest(Message msg) {
        try {
            // get the jms context
            JMSBindingContext context = msg.getBindingContext();
            Session session = context.getJmsSession();

            javax.jms.Message requestMsg;

            if (((WireFormatJMSDefault) jmsBinding.getRequestWireFormat()).isUseBytesMessage()) {
                requestMsg = requestMessageProcessor.insertPayloadIntoJMSBytesMessage(session, msg.getBody(), this.inputWrapperMap.get(msg.getOperation().getName()));
            } else {
                requestMsg = requestMessageProcessor.insertPayloadIntoJMSTextMessage(session, msg.getBody(), this.inputWrapperMap.get(msg.getOperation().getName()));
            }

            msg.setBody(requestMsg);

            requestMsg.setJMSReplyTo(context.getReplyToDestination());

            return msg;
        } catch (JMSException e) {
            throw new JMSBindingException(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();

        Operation op = msg.getOperation();
        List<DataType> inputDataTypes = op.getInputType().getLogical();

        Class<?> inputType = null;
        if (inputDataTypes.size() == 1) {
            inputType = inputDataTypes.get(0).getPhysical();
        }
        if (inputType != null && javax.jms.Message.class.isAssignableFrom(inputType)) {
            msg.setBody(new Object[] { jmsMsg });
           
            if (jmsMsg instanceof BytesMessage) {
                context.setUseBytesForWFJMSDefaultResponse(true);
            } else {
                context.setUseBytesForWFJMSDefaultResponse(false);
            }
        } else {

            // If there is only one arg we must add a wrapper if the operation is wrapper style
            Node wrapper = this.inputWrapperMap.get(msg.getOperation().getName());

            Object requestPayload;
            if (jmsMsg instanceof BytesMessage) {
                requestPayload = responseMessageProcessor.extractPayloadFromJMSBytesMessage(jmsMsg, wrapper);
                context.setUseBytesForWFJMSDefaultResponse(true);
            } else {
                requestPayload = responseMessageProcessor.extractPayloadFromJMSTextMessage(jmsMsg, wrapper );
                context.setUseBytesForWFJMSDefaultResponse(false);
            }

            msg.setBody(new Object[] { requestPayload });
        }
View Full Code Here

    }

    public Message invokeRequest(Message msg) {
        try {
            // get the jms context
            JMSBindingContext context = msg.getBindingContext();
            javax.jms.Message jmsMsg = context.getJmsMsg();            
        
          
            if (service.getInterfaceContract().getCallbackInterface() != null) {

                String callbackdestName = jmsMsg.getStringProperty(JMSBindingConstants.CALLBACK_Q_PROPERTY);
View Full Code Here

    }

    public Message invokeResponse(Message msg) {

        // get the jms context
        JMSBindingContext context = msg.getBindingContext();
        Session session = context.getJmsResponseSession();

        javax.jms.Message responseJMSMsg;
       
        boolean respondBytesMessage = context.isUseBytesForWFJMSDefaultResponse();
       
        if (msg.isFault()) {
            if (respondBytesMessage == true) {
                responseJMSMsg = requestMessageProcessor.createFaultJMSBytesMessage(session, (Throwable) msg.getBody());
            } else {
View Full Code Here

    }

    public org.apache.tuscany.sca.invocation.Message invoke(org.apache.tuscany.sca.invocation.Message tuscanyMsg) {
        try {
            // populate the message context with JMS binding information
            JMSBindingContext context = new JMSBindingContext();
            context.setJmsResourceFactory(jmsResourceFactory);
            tuscanyMsg.setBindingContext(context);
           
            // get a jms session to cover the creation and sending of the message
            Session session = context.getJmsSession();

            context.setRequestDestination(getRequestDestination(tuscanyMsg, session));
            context.setReplyToDestination(getReplyToDestination(session));
           
            try {
                tuscanyMsg = endpointReference.getBindingInvocationChain().getHeadInvoker().invoke(tuscanyMsg);
            } catch (ServiceRuntimeException e) {
                if (e.getCause() instanceof InvocationTargetException) {
                    if ((e.getCause().getCause() instanceof RuntimeException)) {
                        tuscanyMsg.setFaultBody(e.getCause());
                    } else {
                        tuscanyMsg.setFaultBody(((InvocationTargetException)e.getCause()).getTargetException());
                    }
                } else if (e.getCause() instanceof FaultException) {
                    tuscanyMsg.setFaultBody(e.getCause());
                } else {
                    tuscanyMsg.setFaultBody(e);
                }
            } catch (IllegalStateException e) {
                tuscanyMsg.setFaultBody(e);
            } catch (Throwable e) {
                tuscanyMsg.setFaultBody(e);
            } finally {
                context.closeJmsSession();
                if (jmsResourceFactory.isConnectionClosedAfterUse()) {
                    jmsResourceFactory.closeConnection();
                }
            }
           
View Full Code Here

    }
   
    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

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.