Example usage for javax.jms JMSException JMSException

List of usage examples for javax.jms JMSException JMSException

Introduction

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

Prototype

public JMSException(String reason) 

Source Link

Document

Constructs a JMSException with the specified reason and with the error code defaulting to null.

Usage

From source file:org.frameworkset.mq.RequestDispatcher.java

public void send(Message message, Logger logger, JMSProperties properties) throws JMSException {

    if (this.destinationType == MQUtil.TYPE_ROUTER)
        throw new JMSException(
                "?,????.type=" + MQUtil.getTypeDesc(destinationType));
    // send(destinationType, this.persistent,4,0L,message, logger);
    send(destinationType, destination, persistent, message, logger, properties);
}

From source file:org.frameworkset.mq.RequestDispatcher.java

public void send(Message message, JMSProperties properties) throws JMSException {

    if (this.destinationType == MQUtil.TYPE_ROUTER)
        throw new JMSException(
                "?,????.type=" + MQUtil.getTypeDesc(destinationType));
    send(destinationType, this.destination, persistent, message, properties);
}

From source file:org.frameworkset.mq.RequestDispatcher.java

public void send(String msg, JMSProperties properties) throws JMSException {

    assertStarted();/*from w  ww.j a  v  a 2  s.  c  om*/
    MessageProducer producer = null;
    try {
        Destination destination = null;

        //         if (this.destinationType == MQUtil.TYPE_QUEUE)
        //         {
        //            destination = session.createQueue(this.destination);
        //         }
        //         else
        //         {
        //            destination = session.createTopic(this.destination);
        //         }

        LOG.debug("send message to " + this.destination + " build destination");
        destination = connection.createDestination(session, this.destination, destinationType);
        LOG.debug("send message to " + this.destination + " build destination end.");

        int deliveryMode = this.persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
        producer = session.createProducer(destination);
        Message message = createTextMessage(msg);
        if (properties != null)
            MQUtil.initMessage(message, properties);
        producer.send(message, deliveryMode, this.priovity, this.timetolive);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Sent! to destination: " + destination + " message: " + message);
        }
    } catch (JMSException e) {
        throw e;
    } catch (Exception e) {
        throw new JMSException(e.getMessage());
    } finally {
        if (producer != null)
            try {
                producer.close();
            } catch (Exception e) {

            }

    }

}

From source file:org.frameworkset.mq.RequestDispatcher.java

public void send(int destinationType, String destination_, Message message, boolean persistent, int priority,
        long timeToLive, JMSProperties properties) throws JMSException {

    assertStarted();//from w w w . jav a2 s.  co m
    MessageProducer producer = null;
    try {
        Destination destination = null;
        //         if (destinationType == MQUtil.TYPE_QUEUE)
        //         {
        //            destination = session.createQueue(destination_);
        //         }
        //         else
        //         {
        //            destination = session.createTopic(destination_);
        //         }

        LOG.debug("send message to " + destination_ + " build destination");
        destination = connection.createDestination(session, destination_, destinationType);
        LOG.debug("send message to " + destination_ + " build destination end.");

        int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
        producer = session.createProducer(destination);
        if (properties != null)
            MQUtil.initMessage(message, properties);
        producer.send(message, deliveryMode, priority, timeToLive);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Sent! to destination: " + destination + " message: " + message);
        }
        message = null;
    } catch (JMSException e) {
        throw e;
    } catch (Exception e) {
        throw new JMSException(e.getMessage());
    } finally {
        if (producer != null)
            try {
                producer.close();
            } catch (Exception e) {

            }

    }
}

From source file:org.frameworkset.mq.RequestDispatcher.java

public void send(InputStream in, JMSProperties properties, Logger log) throws JMSException {

    BytesMessage msg = createBytesMessage();

    byte[] send = null;

    /* ? *//* w ww. ja va2 s  .co m*/
    if (properties.isEncrypt()) {
        try {
            send = MQUtil.readTxtFileByte(in);
        } catch (Exception e) {
            throw new JMSException(e.getMessage());
        }
        //         if (send == null || send.length == 0)
        //            return;
        // String name = file.getName();

        if (send != null) {
            EncryptDecryptAlgo ed = new EncryptDecryptAlgo();
            send = ed.encrypt(send);
        }

        if (properties != null)
            MQUtil.initMessage(msg, properties);
        msg.writeBytes(send);
        send = null;
    } else {
        if (properties != null)
            MQUtil.initMessage(msg, properties);
        if (!MQUtil.readTxtFileByte(msg, in))
            //            return;
            ;

    }
    send(msg, (JMSProperties) null);
}

From source file:org.fusesource.jms.pool.ConnectionPool.java

public Session createSession(boolean transacted, int ackMode) throws JMSException {
    SessionKey key = new SessionKey(transacted, ackMode);
    SessionPool pool = null;//from  www. j  a v  a2  s  .  c  om
    pool = cache.get(key);
    if (pool == null) {
        SessionPool newPool = createSessionPool(key);
        SessionPool prevPool = cache.putIfAbsent(key, newPool);
        if (prevPool != null && prevPool != newPool) {
            // newPool was not the first one to be associated with this
            // key... close created session pool
            try {
                newPool.close();
            } catch (Exception e) {
                throw new JMSException(e.getMessage());
            }
        }
        pool = cache.get(key); // this will return a non-null value...
    }
    PooledSession session = pool.borrowSession();
    this.loanedSessions.add(session);
    return session;
}

From source file:org.fusesource.jms.pool.ConnectionPool.java

public Session createXaSession(boolean transacted, int ackMode) throws JMSException {
    SessionKey key = new SessionKey(transacted, ackMode);
    SessionPool pool = null;//from w  ww. j  a  v  a2s.co  m
    pool = cache.get(key);
    if (pool == null) {
        SessionPool newPool = createSessionPool(key);
        SessionPool prevPool = cache.putIfAbsent(key, newPool);
        if (prevPool != null && prevPool != newPool) {
            // newPool was not the first one to be associated with this
            // key... close created session pool
            try {
                newPool.close();
            } catch (Exception e) {
                throw new JMSException(e.getMessage());
            }
        }
        pool = cache.get(key); // this will return a non-null value...
    }
    PooledSession session = pool.borrowSession();
    this.loanedSessions.add(session);
    return session;
}

From source file:org.fusesource.jms.pool.SessionPool.java

protected ObjectPool getSessionPool() throws JMSException {
    if (sessionPool == null) {
        throw new JMSException("Already closed");
    }/* ww  w .  j a v a  2  s .c  o  m*/
    return sessionPool;
}

From source file:org.fusesource.jms.pool.XaConnectionPool.java

public Session createSession(boolean transacted, int ackMode) throws JMSException {
    PooledSession session = null;/*from   w  w w.j  a  va2 s.  c  o  m*/
    try {
        boolean isXa = (transactionManager != null
                && transactionManager.getStatus() != Status.STATUS_NO_TRANSACTION);
        if (isXa) {
            transacted = true;
            ackMode = Session.SESSION_TRANSACTED;
            session = (PooledSession) super.createXaSession(transacted, ackMode);
            session.setIgnoreClose(true);
            session.setIsXa(true);
            transactionManager.getTransaction().registerSynchronization(new Synchronization(session));
            incrementReferenceCount();
            transactionManager.getTransaction().enlistResource(createXaResource(session));
        } else {
            session = (PooledSession) super.createSession(transacted, ackMode);
            session.setIgnoreClose(false);
        }
        return session;
    } catch (RollbackException e) {
        final JMSException jmsException = new JMSException("Rollback Exception");
        jmsException.initCause(e);
        throw jmsException;
    } catch (SystemException e) {
        final JMSException jmsException = new JMSException("System Exception");
        jmsException.initCause(e);
        throw jmsException;
    }
}

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

private static Destination getDestination(MessageConsumer messageConsumer) throws JMSException {
    if (messageConsumer instanceof QueueReceiver) {
        QueueReceiver queueReceiver = (QueueReceiver) messageConsumer;
        return queueReceiver.getQueue();
    }/*from w ww.  j  a  v a 2s .  c  om*/
    if (messageConsumer instanceof TopicSubscriber) {
        TopicSubscriber topicSubscriber = (TopicSubscriber) messageConsumer;
        return topicSubscriber.getTopic();
    }
    throw new JMSException("unknown message consumer type: " + messageConsumer.getClass());
}