Package javax.jms

Examples of javax.jms.IllegalStateException


    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG,
                 "ReliableTcpClient[" + identity + ',' + key + "].connect(" + reconnect + ')');

    if (status != INIT)
      throw new IllegalStateException("Connect: state error");

    long startTime = System.currentTimeMillis();
    long endTime = startTime;
    if (addresses.size() > 1) {
      // infinite retry in case of HA.
      endTime = Long.MAX_VALUE;
    } else {
      if (reconnect) {
        endTime += reconnectTimeout;
      } else {
        endTime += params.connectingTimer * 1000L;
      }
    }

    int attemptsC = 0;
    long nextSleep = 100;
    while (true) {
      if (status == CLOSE)
        throw new IllegalStateException("Closed connection");
      attemptsC++;
      for (int i = 0; i < addresses.size(); i++) {
        ServerAddress sa = (ServerAddress)addresses.elementAt(i);
        try {
          doConnect(sa.hostName, sa.port);
          setStatus(CONNECT);
          return;
        } catch (JMSSecurityException exc) {
          throw exc;
        } catch (UnknownHostException uhe) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "ReliableTcpClient.connect", uhe);
          IllegalStateException jmsExc = new IllegalStateException("Server's host is unknown: " + sa.hostName);
          jmsExc.setLinkedException(uhe);
          throw jmsExc;
        } catch (IOException ioe) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "ReliableTcpClient.connect", ioe);
          // continue
        } catch (JMSException jmse) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "ReliableTcpClient.connect", jmse);
          // continue
        } catch (Exception e) {
          if (logger.isLoggable(BasicLevel.DEBUG))
            logger.log(BasicLevel.DEBUG, "ReliableTcpClient.connect", e);
          // continue
        }
      }
      long currentTime = System.currentTimeMillis();

      if (logger.isLoggable(BasicLevel.DEBUG))
        logger.log(BasicLevel.DEBUG,
                   " -> currentTime = " + currentTime + ",endTime = " + endTime);

      // Keep on trying as long as timer is ok:
      if (currentTime < endTime) {
        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG,
                     " -> retry connection " + identity + ',' + key);

        if (currentTime + nextSleep > endTime) {
          nextSleep = endTime - currentTime;   
        }     

        // Sleeping for a while:
        try {
          wait(nextSleep);
        } catch (InterruptedException intExc) {
          throw new IllegalStateException("Could not open the connection with " + addresses + ": interrupted");
        }         

        // Trying again!
        nextSleep = nextSleep * 2;
      } else {
        if (logger.isLoggable(BasicLevel.DEBUG))
          logger.log(BasicLevel.DEBUG,
                     " -> close connection " + identity + ',' + key);

        // If timer is over, throwing an IllegalStateException:
        long attemptsT = (System.currentTimeMillis() - startTime) / 1000;
        IllegalStateException jmsExc = new IllegalStateException("Could not connect to JMS server with "
            + addresses + " after " + attemptsC + " attempts during " + attemptsT
            + " secs: server is not listening or server protocol version is not compatible with client.");
        throw jmsExc;
      }
    }
View Full Code Here


      return (javax.jms.TopicConnection) o;
    } catch (javax.resource.spi.SecurityException exc) {
      throw new JMSSecurityException("Invalid user identification: " + exc);
    } catch (javax.resource.spi.CommException exc) {
      throw new IllegalStateException("Could not connect to the JORAM server: "
                                      + exc);
    } catch (javax.resource.ResourceException exc) {
      throw new JMSException("Could not create connection: " + exc);
    }
  }
View Full Code Here

      createConnectionConsumer(Topic topic,
                               String messageSelector,
                               ServerSessionPool sessionPool,
                               int maxMessages)
    throws JMSException {
    throw new IllegalStateException("Forbidden call on a component's "
                                    + "connection.");
  }
View Full Code Here

   */
  public void setMessageListener(javax.jms.MessageListener messageListener)
              throws JMSException
  {
    checkValidity();
    throw new IllegalStateException("Forbidden call on a component's session.");
  }
View Full Code Here

   * <code>IllegalStateException</code> instance.
   */
  public javax.jms.MessageListener getMessageListener() throws JMSException
  {
    checkValidity();
    throw new IllegalStateException("Forbidden call on a component's session.");
  }
View Full Code Here

   * <code>IllegalStateException</code> instance.
   */
  public void commit() throws JMSException
  {
    checkValidity();
    throw new IllegalStateException("Forbidden call on a component's session.");
  }
View Full Code Here

   * <code>IllegalStateException</code> instance.
   */
  public void rollback() throws JMSException
  {
    checkValidity();
    throw new IllegalStateException("Forbidden call on a component's session.");
  }
View Full Code Here

      validity = false;
    else
      validity = cnx.valid;

   if (! validity)
     throw new IllegalStateException("Invalid state: session is closed.");
  }
View Full Code Here

  protected void checkValidity() throws IllegalStateException
  {
    session.checkValidity();

    if (! valid)
      throw new IllegalStateException("Invalid call on a closed producer.");
  }
View Full Code Here

   *
   * @exception IllegalStateException  If the publisher is closed.
   */
  public javax.jms.Topic getTopic() throws JMSException {
    if (closed)
      throw new IllegalStateException("Forbidden call on a closed publisher.");

    return (javax.jms.Topic) super.dest;
  }
View Full Code Here

TOP

Related Classes of javax.jms.IllegalStateException

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.