Examples of JMSBindingContext


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

     * @return the post processed message
   */
  public Message postProcessRequest(Message tuscanyMsg) {
        // Close of JMS session
    try {
      JMSBindingContext context = tuscanyMsg.getBindingContext();
          context.closeJmsSession();
          if (jmsResourceFactory.isConnectionClosedAfterUse()) {
              jmsResourceFactory.closeConnection();
          } // end if
    } catch (JMSException ex) {
      throw new JMSBindingException(ex);
View Full Code Here

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

        // create the tuscany message
        org.apache.tuscany.sca.invocation.Message tuscanyMsg = messageFactory.createMessage();
       
        // populate the message context with JMS binding information
        JMSBindingContext context = new JMSBindingContext();
        tuscanyMsg.setBindingContext(context);
       
        context.setJmsMsg(requestJMSMsg);
        context.setJmsResourceFactory(jmsResourceFactory);
        context.setReplyToDestination(requestJMSMsg.getJMSReplyTo());
       
        // set the message body
        tuscanyMsg.setBody(requestJMSMsg);
       
        // call the runtime wire - the response is handled by the
View Full Code Here

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

    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

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

//            throw new JMSBindingException(e);
//        }
    }
   
    public Message invokeResponse(Message msg) {
        JMSBindingContext context = msg.getBindingContext();
        try {

            //if operation is oneway, return back.
            Operation operation = msg.getOperation();
            if (operation != null && operation.isNonBlocking()) {
                return msg;
            }

            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;
            }

            if ((msg.getOperation() != null)) {
                String operationName = msg.getOperation().getName();
                if (jmsBinding.getEffectiveJMSPriority(operationName) != null) {
                    responseJMSMsg.setJMSPriority(jmsBinding.getEffectiveJMSPriority(operationName));
                }
       
                if ( jmsBinding.getEffectiveJMSType(operationName) != null) {
                    responseJMSMsg.setJMSType(jmsBinding.getEffectiveJMSType(operationName));
                }
               
                if ((jmsBinding.getEffectiveJMSDeliveryMode(operationName) != null)) {
                    responseJMSMsg.setJMSDeliveryMode(jmsBinding.getEffectiveJMSDeliveryMode(operationName) ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);                  
                }
               
                if ((jmsBinding.getEffectiveJMSTimeToLive(operationName) != null)) {
                  responseJMSMsg.setJMSExpiration(jmsBinding.getEffectiveJMSTimeToLive(operationName).longValue());
                }
            }
   
            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);
            long timeToLive = requestJMSMsg.getJMSExpiration();
            producer.setTimeToLive(timeToLive);
   
            producer.send((javax.jms.Message)msg.getBody());
   
            producer.close();
           
            return msg;
   
        } catch (JMSException e) {
            throw new JMSBindingException(e);
        } finally {
            context.closeJmsResponseSession();
        }
    }   
View Full Code Here

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

        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

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

    }
   
    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

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

   
    public Message invoke(Message msg) {
        Message responseMsg = invokeRequest(msg);
       
        // get the jms context
        JMSBindingContext context = msg.getBindingContext();
       
        // [rfeng] For oneway operation as part of the bi-directional interface, the JMSReplyTo is present
        if (context.getReplyToDestination() == null || msg.getOperation().isNonBlocking()) {
            responseMsg.setBody(null);
        } else {
            responseMsg = invokeResponse(msg);
        }
       
View Full Code Here

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();
           
            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

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();
           
            MessageProducer producer = session.createProducer(context.getRequestDestination());
   
            // Set JMS header attributes in producer, not message.
            String opName = msg.getOperation().getName();
            if (jmsBinding.getEffectiveJMSTimeToLive(opName) != null) {
                producer.setTimeToLive(jmsBinding.getEffectiveJMSTimeToLive(msg.getOperation().getName()).longValue());
View Full Code Here

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

            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 = null;
            String correlationScheme = jmsBinding.getCorrelationScheme();
            if (correlationScheme == null || JMSBindingConstants.CORRELATE_MSG_ID.equalsIgnoreCase(correlationScheme)) {
                msgSelector = "JMSCorrelationID = '" + requestMessage.getJMSMessageID() + "'";
            } else if (JMSBindingConstants.CORRELATE_CORRELATION_ID.equalsIgnoreCase(correlationScheme)) {
                msgSelector = "JMSCorrelationID = '" + requestMessage.getJMSCorrelationID() + "'";
            }               

            MessageConsumer consumer;
            if (msgSelector != null) {
                consumer = session.createConsumer(context.getReplyToDestination(), msgSelector)
            } else {
                consumer = session.createConsumer(context.getReplyToDestination())
            }
           
            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
TOP
Copyright © 2018 www.massapi.com. 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.