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

Examples of org.apache.tuscany.sca.binding.jms.JMSBindingException


        String qCreateMode = jmsBinding.getDestinationCreate();
        if (qCreateMode.equals(JMSBindingConstants.CREATE_ALWAYS)) {
            // In this mode, the queue must not already exist as we are creating it
            if (destination != null) {
                throw new JMSBindingException("JMS Destination " + queueName
                    + " already exists but has create mode of \""
                    + qCreateMode
                    + "\" while registering service "
                    + serviceName
                    + " listener");
            } // end if

            // Create the queue
            destination = jmsResourceFactory.createDestination(queueName);

        } else if (qCreateMode.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
            // In this mode, the queue may nor may not exist. It will be created if it does not exist
            // but don't create when using jms:jndi uri format
            if (destination == null && !"jndi".equals(jmsBinding.getDestinationType())) {
                destination = jmsResourceFactory.createDestination(queueName);
            } // end if

        } else if (qCreateMode.equals(JMSBindingConstants.CREATE_NEVER)) {
            // In this mode, the queue must have already been created.
            if (destination == null) {
                throw new JMSBindingException("JMS Destination " + queueName
                    + " not found but create mode of \""
                    + qCreateMode
                    + "\" while registering service "
                    + serviceName
                    + " listener");
            } // end if
        } // end if

        // Make sure we ended up with a queue
        if (destination == null) {
            throw new JMSBindingException("JMS Destination " + queueName
                + " not found with create mode of \""
                + qCreateMode
                + "\" while registering service "
                + serviceName
                + " listener");
        } // end if

        // Make sure its the expected type (queue or topic)
        String type = (destination instanceof Queue) ? JMSBindingConstants.DESTINATION_TYPE_QUEUE : JMSBindingConstants.DESTINATION_TYPE_TOPIC;
        if ("jndi".equals(jmsBinding.getDestinationType())) {
            jmsBinding.setDestinationType(type);           
        } else {
            if (!type.equals(jmsBinding.getDestinationType())) {
                throw new JMSBindingException("JMS Destination " + queueName
                                              + " expecting type of "
                                              + jmsBinding.getDestinationType()
                                              + " but found "
                                              + type
                                              + " while registering service "
View Full Code Here


                return ((Topic)destination).getTopicName();
            } else {
                return null;
            }
        } catch (JMSException e) {
            throw new JMSBindingException(e);
        }
    } // end method getDestinationName
View Full Code Here

            // statically-configured destination unless a message is received that does not have
            // the necessary properties. 
            bindingRequestDest = lookupDestination();
            bindingReplyDest = lookupResponseDestination();
        } catch (NamingException e) {
            throw new JMSBindingException(e);
        } // end try
    } // end constructor
View Full Code Here

        Destination dest = jmsResourceFactory.lookupDestination(queueName);

        if (qCreateMode.equals(JMSBindingConstants.CREATE_ALWAYS)) {
            // In this mode, the queue must not already exist as we are creating it
            if (dest != null) {
                throw new JMSBindingException(queueType + queueName
                    + " already exists but has create mode of \""
                    + qCreateMode
                    + "\" while registering binding "
                    + jmsBinding.getName()
                    + " invoker");
            }
            // Create the queue
            dest = jmsResourceFactory.createDestination(queueName);

        } else if (qCreateMode.equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) {
            // In this mode, the queue may nor may not exist. It will be created if it does not exist
            // but don't create when using jms:jndi uri format
            if (dest == null && !"jndi".equals(jmsBinding.getDestinationType())) {
                dest = jmsResourceFactory.createDestination(queueName);
            }

        } else if (qCreateMode.equals(JMSBindingConstants.CREATE_NEVER)) {
            // In this mode, the queue must have already been created.
            if (dest == null) {
                throw new JMSBindingException(queueType + queueName
                    + " not found but create mode of \""
                    + qCreateMode
                    + "\" while registering binding "
                    + jmsBinding.getName()
                    + " invoker");
            }
        }

        // Make sure we ended up with a queue
        if (dest == null) {
            throw new JMSBindingException(queueType + queueName
                + " not found with create mode of \""
                + qCreateMode
                + "\" while registering binding "
                + jmsBinding.getName()
                + " invoker");
View Full Code Here

                }
            }
           
            return tuscanyMsg;
        } catch (Exception e) {
            throw new JMSBindingException(e);
        }  
    }
View Full Code Here

            context.setRequestDestination(getRequestDestination(tuscanyMsg, session));
            context.setReplyToDestination(getReplyToDestination(session));
           
            return tuscanyMsg;
        } catch (Exception e) {
            throw new JMSBindingException(e);
        } // end try  
  } // end method processRequest
View Full Code Here

          context.closeJmsSession();
          if (jmsResourceFactory.isConnectionClosedAfterUse()) {
              jmsResourceFactory.closeConnection();
          } // end if
    } catch (JMSException ex) {
      throw new JMSBindingException(ex);
    } // end try
    return tuscanyMsg;
  } // end method postProcessRequest
View Full Code Here

           
            requestMsg.setJMSReplyTo(context.getReplyToDestination());
           
            return msg;
        } catch (JMSException e) {
            throw new JMSBindingException(e);
        }
    }
View Full Code Here

            String callbackdestName = jmsMsg.getStringProperty(JMSBindingConstants.CALLBACK_Q_PROPERTY);
        
            if (callbackdestName != null) {
              // If present, strip any leading "jms:jndi:" string
                if (!callbackdestName.startsWith("jms:jndi:")) {
                    throw new JMSBindingException("message property " + JMSBindingConstants.CALLBACK_Q_PROPERTY + " does not start with 'jms:jndi:' found: " + callbackdestName);
                } else {
                    callbackdestName = "jms:queue:" + callbackdestName.substring(9);
                }
            } else {
              // If there is no Callback destination name header present, but the service is a callback, use the JMS ReplyTo header
                // as per the spec this will override anything specified by the user in SCDL
                if (service.getInterfaceContract().getCallbackInterface() != null) {
                    if ( ( jmsMsg.getJMSReplyTo() != null ) && msg.getOperation().isNonBlocking() ) {
                      Destination replyTo = jmsMsg.getJMSReplyTo();
                      if (replyTo != null) {
                          if (replyTo instanceof Queue){
                              callbackdestName = "jms:queue:" + ((Queue) replyTo).getQueueName();
                          } else {
                              callbackdestName = "jms:topic:" + ((Topic) replyTo).getTopicName();
                          }
                          }
                    } // end if
                } // end if
            } // end if
               
            // Place the Callback destination name into the Callback EPRs for the service endpoint
            if (callbackdestName != null) {
                msg.getHeaders().put(Constants.CALLBACK, new CallbackHandler(callbackdestName));            
            } // end if 

// Callback ID not used at present           
//            String callbackID = jmsMsg.getStringProperty(JMSBindingConstants.CALLBACK_ID_PROPERTY);
//            if (callbackID != null) {
//                parameters.setCallbackID(callbackID);
//            }

        } catch (JMSException e) {
            throw new JMSBindingException(e);
        } // end try
       
        return msg;
    } // end method invokeRequest
View Full Code Here

    public synchronized Session getJmsSession() {
        if (jmsSession == null) {
            try {
                jmsSession = getJmsResourceFactory().createSession();
            } catch (Exception e) {
                throw new JMSBindingException(e);
            }
        }
        return jmsSession;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.binding.jms.JMSBindingException

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.