Package com.sun.messaging.jmq.io

Examples of com.sun.messaging.jmq.io.Packet


     */
    Object parseData(byte[] data, byte[] attachment) throws IOException {

  // parse message
  ByteArrayInputStream bais = new ByteArrayInputStream(data);
  msgToReturn = new Packet(false);
        msgToReturn.generateTimestamp(false);
        msgToReturn.generateSequenceNumber(false);
  msgToReturn.readPacket(bais);
  bais.close();

View Full Code Here


     * @throws BrokerException
     */
    public Packet getMessage( Connection conn, DestinationUID dstUID, String id )
        throws BrokerException {

        Packet msg = null;

        boolean myConn = false;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        Exception myex = null;
View Full Code Here

        if ( !isSingleRow ) {
            list = new ArrayList( 100 );
        }

        while ( rs.next() ) {
            Packet msg = new Packet(false);
            msg.generateTimestamp(false);
            msg.generateSequenceNumber(false);

            InputStream is = null;
            if ( getMsgColumnType(rs, 1) == Types.BLOB ) {
                Blob blob = rs.getBlob( 1 );
                is = blob.getBinaryStream();
            } else {
                is = rs.getBinaryStream( 1 );
            }

            msg.readPacket(is);
            is.close();

            if (Store.getDEBUG()) {
                logger.log(Logger.DEBUG,
                    "Loaded message from database for "+ msg.getMessageID() );
            }

            if ( isSingleRow ) {
                return msg;
            } else {
View Full Code Here

            msgDAO = dao;
            msgIDItr = itr;
        }

        public boolean hasMoreElements() {
            Packet msg = null;
            while ( msgIDItr.hasNext() ) {
                String mid = null;
                try {
                    mid = (String)msgIDItr.next();
                    msg = msgDAO.getMessage( null, dID, mid );
View Full Code Here

        // ( it may have been removed on load if it just contained
        // messages in a transaction)
        Destination dest = Destination.getDestination(duid.getName(),
            type, true, true);

        Packet message = msg.getMessage();
        ConsumerUID[] iids = msg.getStoredInterests();
        //if (iids != null)
        if(false){
          int[] states = new int[iids.length];
          for (int i = 0; i < iids.length; i++) {
View Full Code Here

            .toString();

  Statement stmt = null;
  ResultSet rs = null;
        String msgID = null;
  Packet msg = null;
    Exception myex = null;
  try {
      stmt = conn.createStatement();
      rs = stmt.executeQuery( getAllMsgFromOldSQL );
      while (rs.next()) {
                msgID = rs.getString(1);

    msg = new Packet(false);
    msg.generateTimestamp(false);
    msg.generateSequenceNumber(false);
                InputStream is = null;
                Blob blob = rs.getBlob(2);
                is = blob.getBinaryStream();
    msg.readPacket(is);
    is.close();

                String dstID = rs.getString(3);
                long sessionID = rs.getLong(4);
                long createdTS = rs.getLong(5);

                try {
                    msgDAO.insert( conn, dstID, msg, null, null, sessionID,
                        createdTS, true );
                } catch (BrokerException be) {
                    // If msg exist, just logged and continue
                    if (be.getStatusCode() == Status.CONFLICT) {
                        logger.log(Logger.WARNING, be.getMessage() + ": Ignore");
                    } else {
                        throw be;
                    }
                }

                msgToDst.put(msgID, dstID);
      }
  } catch (Exception e) {
        myex = e;
            String errorMsg = br.getKString(
                BrokerResources.X_JDBC_UPGRADE_MESSAGES_FAILED,
                (msg == null ? msgID : msg.getSysMessageID().toString()));
      logger.logStack(Logger.ERROR, errorMsg, e);
      throw new BrokerException(errorMsg, e);
  } finally {
            Util.close( rs, stmt, null, myex );
        }
View Full Code Here

      try {
    // upgrade
    MsgStore200 oldmsgstore = new MsgStore200(
          new File(oldTop, MESSAGE_DIR));
    while (oldmsgstore.hasMoreMessages()) {
        Packet msg = oldmsgstore.nextMessage();
        ConsumerUID[] iids = oldmsgstore.nextCUIDs();
        int[] states = oldmsgstore.nextStates();

        DestinationUID dst = DestinationUID.getUID(
            msg.getDestination(),
            msg.getIsQueue());
        this.storeMessage(dst, msg, iids, states, false);

        if (deleteold) {
      oldmsgstore.removeData(msg.getSysMessageID(), false);
        }
    }
    oldmsgstore.close();

      } catch (IOException e) {
View Full Code Here

      recitr = i;
      msgEnum = e;
    }

    public boolean hasMoreElements() {
      Packet msg = null;
      if (itr != null) {
        if (itr.hasNext()) {
          objToReturn = itr.next();
          return true; // RETURN TRUE
        } else {
View Full Code Here

    protected void sendConsumerInfo(int requestType, String destName,
                                    int destType, int infoType) {
        if (state >= STATE_CLOSED) return;

        Packet info_pkt = new Packet(useDirectBuffers());
        info_pkt.setPacketType(PacketType.INFO);

        Hashtable props = new Hashtable();
        props.put("JMQRequestType", Integer.valueOf(requestType));
        props.put("JMQStatus", Status.OK);
        info_pkt.setProperties(props);
        Hashtable hash = new Hashtable();
        hash.put("JMQDestination", destName);
        hash.put("JMQDestType", Integer.valueOf(destType));
        hash.put("JMQConsumerInfoType", Integer.valueOf(infoType));
        DestinationUID duid = null;
        try {
            duid = DestinationUID.getUID(destName, destType);

            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(bos);
            oos.writeObject(hash);
            oos.flush();
            bos.flush();
            info_pkt.setMessageBody(bos.toByteArray());
            bos.close();
        } catch (Throwable t) {
            logger.log(Logger.WARNING,
            "XXXI18N Error: Unable to send consumer info to client: "+duid, t);
            return;
View Full Code Here

        Object o= (Packet)inputQueue.take();
        if (o instanceof EOF) {
            EOF eof = (EOF)o;
            throw new IOException("Connection has been closed:"+eof.getReason());
        }
        Packet newp = (Packet)o; // note of type ReadWritePacket
       
        // Make a copy
        //
        // IF CLIENT IS MAKING A COPY, this can be a shallow copy
        // Otherwise, this needs to be a deep copy
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.io.Packet

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.