Package com.sun.messaging.jmq.jmsserver.util

Examples of com.sun.messaging.jmq.jmsserver.util.BrokerException


                    if (defaultHandler != null)
                        defaultHandler.sendError(con, ex, msg);
                } catch (Exception ex) {
                    if (defaultHandler != null) {
                    defaultHandler.sendError(con,
      new BrokerException(
                            Globals.getBrokerResources().getKString(
                            BrokerResources.X_INTERNAL_EXCEPTION,
                           "Unexpected Error processing message"), ex), msg);
                    }
                }
            } catch (BrokerException ex) {
                if (defaultHandler != null)
                        defaultHandler.sendError(con, msg, ex.getMessage(), ex.getStatusCode());
            } catch (Exception ex) {
                if (defaultHandler != null) {
                defaultHandler.sendError(con,
                    new BrokerException(
                       Globals.getBrokerResources().getKString(
                       BrokerResources.X_INTERNAL_EXCEPTION,
                       "Unexpected Error processing message"), ex), msg);
                }
            }
View Full Code Here


            if (!d.isPaused()) {
                String msg = rb.getString(rb.E_DESTINATION_NOT_PAUSED);
                String errMsg = rb.getString(rb.X_COMPACT_DST_EXCEPTION,
                            getName(), msg);

    throw (new BrokerException(errMsg));
            }

            d.compact();
  } catch (Exception e)  {
      handleOperationException(DestinationOperations.COMPACT, e);
View Full Code Here

            long maxwaitsec = Globals.getConfig().getLongProperty(Globals.IMQ +
                               ".cluster.ha.takeoverWaitTimeout", 300);
            long maxwait = maxwaitsec*1000L;
            if (maxwait == 0) {
                throw new BrokerException(Globals.getBrokerResources().getKString(
                                          BrokerResources.W_WAIT_FOR_BEEN_TAKENOVER_TIMEOUT,
                                          String.valueOf(maxwaitsec)));
            }
            long waitinterval = 10*1000L;
            long currtime = System.currentTimeMillis();
            long precurrtime = currtime;
            long totalwaited = 0L;
            long waittime = (maxwait < 0 || maxwait > waitinterval ? waitinterval : maxwait);

            do  {
                logger.log(Logger.INFO, BrokerResources.I_STARTUP_PAUSE);
                try {
                    Thread.currentThread().sleep(waittime);
                    precurrtime = currtime;
                    currtime = System.currentTimeMillis();
                    totalwaited += ((currtime - precurrtime) > waittime ?
                                    (currtime - precurrtime):waittime);
                } catch (InterruptedException ex) {
                    throw new BrokerException(
                    "Waiting for taking over of this broker to complete is interrupted: "+ex.getMessage());
                }

                cb.updateHeartbeat(true);
                state = cb.getState();

                waittime = (maxwait < 0 ? waitinterval :(maxwait - totalwaited));
                if (waittime > waitinterval) waittime = waitinterval;

            } while ((state == BrokerState.FAILOVER_STARTED ||
                      state == BrokerState.FAILOVER_PENDING) && waittime > 0);

            if (waittime <= 0 &&
                (state == BrokerState.FAILOVER_STARTED ||
                 state == BrokerState.FAILOVER_PENDING)) {
                throw new BrokerException(Globals.getBrokerResources().getKString(
                                          BrokerResources.W_WAIT_FOR_BEEN_TAKENOVER_TIMEOUT,
                                          String.valueOf(maxwaitsec)));
            }
        }

View Full Code Here

        }
        try {
            ((TakeoverThread)takeoverRunnable).doTakeover();
        } catch (Exception e) {
            if (e instanceof BrokerException) throw (BrokerException)e;
            throw new BrokerException(e.getMessage(), e, Status.ERROR);
        }
    }
View Full Code Here

            PacketReference ref = getReference();

            try {
                if (ref != null && ref.isOverrided()) {
                    BrokerException bex = new BrokerException(
                               "Message requeued:"+ref, Status.GONE);
                    bex.setRemoteConsumerUIDs(String.valueOf(getConsumerUID().longValue()));
                    bex.setRemote(true);
                    throw bex;
                }
                if (ref == null) {
                    // XXX weird
                    ref = Destination.get(id);
                }
                if (ref == null) {
                    String emsg = null;
                    if (tid == null) {
                        emsg = Globals.getBrokerResources().getKString(
                        BrokerResources.W_ACK_MESSAGE_GONE, this.toString());
                    } else {
                        emsg = Globals.getBrokerResources().getKString(
                        BrokerResources.W_ACK_MESSAGE_GONE_IN_TXN, tid.toString(),
                                             this.toString());
                    }
                    logger.log(Logger.WARNING, emsg);
                    throw new BrokerException(emsg, Status.CONFLICT);
                }
                rm = ref.acknowledged(uid, storedcid, !isUnsafeAck(uid),
                                      notify, tid, remoteNotified, ackack);
                Consumer c = (Consumer)consumers.get(uid);
                if (c != null) {
                    c.setLastAckTime(System.currentTimeMillis());
                }
            } catch (Exception ex) {
                assert false : ref;
                String emsg = Globals.getBrokerResources().getKString(
                    BrokerResources.X_UNABLE_PROCESS_MESSAGE_ACK,
                    this.toString()+"["+ref.getDestinationUID()+"]", ex.getMessage());
                if (logger.getLevel() <= Logger.DEBUG) {
                    logger.logStack(Logger.DEBUG, emsg, ex);
                } else {
                    logger.log(Logger.WARNING, emsg);
                }
                if (ex instanceof BrokerException) throw (BrokerException)ex;
                throw new BrokerException(emsg, ex);
            }
            return (rm ? ref : null);
        }
View Full Code Here

            sendReply(status, emsg, con, cmd_msg);
            return true;
        }
        try {
            if (!Globals.dynamicChangeMasterBrokerEnabled()) {
                throw new BrokerException(Globals.getBrokerResources().getKString(
                    BrokerResources.X_NO_SUPPORT_DYNAMIC_CHANGE_MASTER_BROKER),
                    Status.NOT_ALLOWED);
            }
            if (newmb == null) {
                throw new IllegalArgumentException("null "+
                    MessageType.JMQ_CLUSTER_NEW_MASTER_BROKER);
            }

            if (!fromJMSRA && Globals.isJMSRAManagedBroker()) {
                throw new IllegalAccessException(
                    Globals.getBrokerResources().getKString(
                        BrokerResources.X_ADMIN_CHANGE_MASTER_NOT_FROM_JMSRA));
            }

            ClusterManager cm = Globals.getClusterManager();
            BrokerMQAddress self = (BrokerMQAddress)cm.getMQAddress();
            BrokerMQAddress master = (cm.getMasterBroker() == null ?
                                      null:(BrokerMQAddress)cm.getMasterBroker().getBrokerURL());
            BrokerMQAddress newmba = BrokerMQAddress.createAddress(newmb);
            BrokerMQAddress oldmba = null;
            if (oldmb != null) {
                oldmba = BrokerMQAddress.createAddress(oldmb);
            }
            if (notificationOnly) {
                if (master == null) {
                    emsg = "IllegalStateException for notification "+
                            MessageType.getString(MessageType.CHANGE_CLUSTER_MASTER_BROKER)+
                            ": No master broker";
                    logger.log(logger.ERROR, emsg);
                    sendReply(Status.ERROR, emsg, con, cmd_msg);
                    Broker.getBroker().exit(1, emsg, BrokerEvent.Type.ERROR);
                    throw new IllegalStateException(emsg);
                }
                if (newmba.equals(self)) {
                    if (!master.equals(self)) {
                        emsg = "IllegalStateException for notification "+
                            MessageType.getString(MessageType.CHANGE_CLUSTER_MASTER_BROKER)+
                            ": This broker, which has master broker "+master+
                            ", is not the master broker as expected";
                        logger.log(logger.ERROR, emsg);
                        sendReply(Status.ERROR, emsg, con, cmd_msg);
                        Broker.getBroker().exit(1, emsg, BrokerEvent.Type.ERROR);
                        return true;
                    }
                }
                if (oldmba != null && oldmba.equals(self)) {
                    if (!master.equals(newmba)) {
                        emsg = "IllegalStateException for notification "+
                            MessageType.getString(MessageType.CHANGE_CLUSTER_MASTER_BROKER)+
                            ": This broker, which is the old master broker "+oldmba+
                            ", does not have "+newmba+" as the master broker as expected";
                        logger.log(logger.ERROR, emsg);
                        sendReply(Status.ERROR, emsg, con, cmd_msg);
                        Broker.getBroker().exit(1, emsg, BrokerEvent.Type.ERROR);
                        return true;
                    }
                }
                sendReply(Status.OK, null, con, cmd_msg);
                return true;
            }
            if (master == null) {
                throw new BrokerException(Globals.getBrokerResources().getKString(
                    BrokerResources.X_CLUSTER_NO_MASTER_BROKER_REJECT_CHANGE_MASTER),
                    Status.PRECONDITION_FAILED);
            }
            if (newmba.equals(master)) {
                logger.log(logger.INFO, Globals.getBrokerResources().getKString(
                    BrokerResources.I_CLUSTER_CHANGE_MASTER_BROKER_SAME, newmba));
                sendReply(Status.OK, null, con, cmd_msg);
                return true;
            }
            if (oldmba == null) {
                oldmba = master;
            }
            if (!oldmba.equals(master)) {
                throw new BrokerException(Globals.getBrokerResources().getKString(
                    BrokerResources.X_CLUSTER_CHANGE_MASTER_BROKER_MISMATCH,
                    oldmba.toString(), master), Status.PRECONDITION_FAILED);
            }
            if (!self.equals(master)) {
                if (!Globals.isJMSRAManagedBroker()) {
                    throw new BrokerException(Globals.getBrokerResources().getKString(
                        BrokerResources.X_CLUSTER_THIS_BROKER_NOT_MASTER_BROKER_REJECT_CHANGE_MASTER,
                        master.toString()), Status.NOT_ALLOWED);
                 }
                 sendReply(Status.OK, null, con, cmd_msg);
                 return true;
View Full Code Here

      msgType = (Integer) props.get(MessageType.JMQ_MESSAGE_TYPE);
    } catch (Exception e) {
      // Programming error. No need to I18N
      String emsg = rb.getString(rb.E_INTERNAL_BROKER_ERROR, "Admin: Could not extract properties from pkt");
      logger.log(Logger.WARNING, emsg, e);
      throw new BrokerException(emsg, e);
    }
    if (props == null || msgType == null) {
      // Programming error. No need to I18N
      String emsg = rb.getString(rb.E_INTERNAL_BROKER_ERROR, "Message received on administration destination "
          + dest + " has no " + MessageType.JMQ_MESSAGE_TYPE + " property ignoring it.");
      logger.log(Logger.WARNING, emsg);
      throw new BrokerException(emsg);
    }

    /**
     */
    if (bridgeAdmin) {
View Full Code Here

      storedInterests = ref.getRoutingForStore(allConsumers);

    } catch (BrokerException ex) {
      throw ex;
    } catch (RuntimeException ex) {
      throw new BrokerException(ex.toString(), ex);
    }
    return storedInterests;
  }
View Full Code Here

   
    public void forwardOrphanMessages(Collection refs,
                  ConsumerUID consumer)
         throws BrokerException
    {
        BrokerException ex = new BrokerException("INTERNAL ERROR: Unexpected call");
        logger.logStack(Logger.ERROR, ex.getMessage(), ex);
        throw ex;
    }
View Full Code Here

        String authType = ac.getAuthType();
        com.sun.messaging.jmq.auth.api.client.AuthenticationProtocolHandler hd
                                               = getClientAuthHandler(authType);
        if (!hd.getType().equals(authType)) {
            String[] args = {authType, hd.getType(), hd.getClass().getName()};
            throw new BrokerException(Globals.getBrokerResources().getKString(
                                    BrokerResources.X_AUTHTYPE_MISMATCH, args));
        }
        hd.init(username, password, null /* props */);

        int seq = 0;
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.jmsserver.util.BrokerException

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.