Search in sources :

Example 16 with FilteringObjectInputStream

use of com.sun.messaging.jmq.util.io.FilteringObjectInputStream in project openmq by eclipse-ee4j.

the class ClusterImpl method receiveBrokerInfo.

/**
 * Receive and process the BROKER_INFO packet.
 */
private BrokerInfo receiveBrokerInfo(BrokerAddressImpl sender, byte[] pkt, String realRemote, BrokerLink l) {
    ByteArrayInputStream bis = new ByteArrayInputStream(pkt);
    BrokerInfo info = null;
    try {
        ObjectInputStream ois = new FilteringObjectInputStream(bis);
        info = (BrokerInfo) ois.readObject();
        info.setRealRemoteString(realRemote);
    } catch (Exception e) {
        logger.log(Logger.WARNING, br.W_MBUS_SERIALIZATION, sender);
        if (l != null) {
            l.shutdown();
        }
        return null;
    }
    Integer v = info.getClusterProtocolVersion();
    if (v != null && v.intValue() >= ProtocolGlobals.VERSION_400) {
        return info;
    }
    if (l != null) {
        l.handshakeSent();
    }
    int status = cb.addBrokerInfo(info);
    if (status == cb.ADD_BROKER_INFO_OK) {
        return info;
    }
    if (status == cb.ADD_BROKER_INFO_RETRY) {
        synchronized (brokerList) {
            BrokerLink link = (BrokerLink) brokerList.get(sender);
            if (link != null) {
                link.closeConn();
            }
        }
    } else if (status == cb.ADD_BROKER_INFO_BAN) {
        synchronized (brokerList) {
            BrokerLink link = (BrokerLink) brokerList.get(sender);
            if (link != null) {
                link.shutdown();
            }
        }
    }
    return null;
}
Also used : FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) LoopbackAddressException(com.sun.messaging.jmq.jmsserver.util.LoopbackAddressException) LoadException(com.sun.messaging.jmq.jmsserver.persist.api.LoadException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) BrokerInfo(com.sun.messaging.jmq.jmsserver.multibroker.BrokerInfo) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream)

Example 17 with FilteringObjectInputStream

use of com.sun.messaging.jmq.util.io.FilteringObjectInputStream in project openmq by eclipse-ee4j.

the class RemoteTransaction2PPrepareEvent method readFromBytes.

@Override
public void readFromBytes(byte[] data) throws IOException, BrokerException {
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    DataInputStream dis = new DataInputStream(bais);
    remoteTransaction = new RemoteTransaction();
    dis.skip(2);
    remoteTransaction.getTransactionDetails().readContent(dis);
    int objectBodySize = dis.readInt();
    byte[] objectBody = new byte[objectBodySize];
    dis.read(objectBody);
    ByteArrayInputStream bais2 = new ByteArrayInputStream(objectBody);
    ObjectInputStream ois = new FilteringObjectInputStream(bais2);
    try {
        remoteTransaction.setTransactionState((TransactionState) ois.readObject());
        remoteTransaction.setTxnHomeBroker((BrokerAddress) ois.readObject());
        remoteTransaction.setTxnAcks((TransactionAcknowledgement[]) ois.readObject());
        remoteTransaction.setDestIds((DestinationUID[]) ois.readObject());
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    ois.close();
    bais2.close();
    dis.close();
    bais.close();
}
Also used : RemoteTransaction(com.sun.messaging.jmq.jmsserver.data.RemoteTransaction) TransactionAcknowledgement(com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) ByteArrayInputStream(java.io.ByteArrayInputStream) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) DataInputStream(java.io.DataInputStream) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 18 with FilteringObjectInputStream

use of com.sun.messaging.jmq.util.io.FilteringObjectInputStream in project openmq by eclipse-ee4j.

the class LocalTransaction2PPrepareEvent method readFromBytes.

@Override
void readFromBytes(byte[] data) throws IOException, BrokerException {
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    DataInputStream dis = new DataInputStream(bais);
    localTransaction = new LocalTransaction();
    dis.skip(2);
    localTransaction.getTransactionDetails().readContent(dis);
    TransactionWork work = new TransactionWork();
    work.readWork(dis);
    localTransaction.setTransactionWork(work);
    // need to write transaction info here
    int objectBodySize = dis.readInt();
    byte[] objectBody = new byte[objectBodySize];
    dis.read(objectBody);
    ByteArrayInputStream bais2 = new ByteArrayInputStream(objectBody);
    ObjectInputStream ois = new FilteringObjectInputStream(bais2);
    try {
        TransactionState ts = (TransactionState) ois.readObject();
        localTransaction.setTransactionState(ts);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    ois.close();
    bais2.close();
    dis.close();
    bais.close();
}
Also used : TransactionState(com.sun.messaging.jmq.jmsserver.data.TransactionState) TransactionWork(com.sun.messaging.jmq.jmsserver.data.TransactionWork) LocalTransaction(com.sun.messaging.jmq.jmsserver.data.LocalTransaction) ByteArrayInputStream(java.io.ByteArrayInputStream) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) DataInputStream(java.io.DataInputStream) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 19 with FilteringObjectInputStream

use of com.sun.messaging.jmq.util.io.FilteringObjectInputStream in project openmq by eclipse-ee4j.

the class ClusterTransaction2PPrepareEvent method readFromBytes.

@Override
public void readFromBytes(byte[] data) throws IOException, BrokerException {
    if (Store.getDEBUG()) {
        Globals.getLogger().log(Logger.DEBUG, getPrefix() + "readFromBytes");
    }
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    DataInputStream dis = new DataInputStream(bais);
    clusterTransaction = new ClusterTransaction();
    dis.skip(2);
    clusterTransaction.getTransactionDetails().readContent(dis);
    if (Store.getDEBUG()) {
        Globals.getLogger().log(Logger.DEBUG, getPrefix() + "read details " + clusterTransaction.getTransactionDetails());
    }
    TransactionWork work = new TransactionWork();
    work.readWork(dis);
    clusterTransaction.setTransactionWork(work);
    int objectBodySize = dis.readInt();
    byte[] objectBody = new byte[objectBodySize];
    dis.read(objectBody);
    ByteArrayInputStream bais2 = new ByteArrayInputStream(objectBody);
    ObjectInputStream ois = new FilteringObjectInputStream(bais2);
    try {
        clusterTransaction.setTransactionState((TransactionState) ois.readObject());
        clusterTransaction.setTransactionBrokers((TransactionBroker[]) ois.readObject());
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    ois.close();
    bais2.close();
    dis.close();
    bais.close();
}
Also used : TransactionWork(com.sun.messaging.jmq.jmsserver.data.TransactionWork) ByteArrayInputStream(java.io.ByteArrayInputStream) TransactionBroker(com.sun.messaging.jmq.jmsserver.data.TransactionBroker) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) DataInputStream(java.io.DataInputStream) ClusterTransaction(com.sun.messaging.jmq.jmsserver.data.ClusterTransaction) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 20 with FilteringObjectInputStream

use of com.sun.messaging.jmq.util.io.FilteringObjectInputStream in project openmq by eclipse-ee4j.

the class DirectMapPacket method _getMessageBodyFromPacket.

/**
 * Get the message body from the packet
 */
@Override
protected void _getMessageBodyFromPacket() throws JMSException {
    try {
        this.messageBody = super._getMessageBodyByteArray();
        this.byteArrayInputStream = new ByteArrayInputStream(messageBody);
        this.objectInputStream = new FilteringObjectInputStream(byteArrayInputStream);
        this.map = (Map<String, Object>) objectInputStream.readObject();
    } catch (Exception e) {
        String errMsg = _lgrMID_EXC + ":MapMessage:Exception deserializing on deliver:" + e.getMessage();
        _loggerJM.severe(errMsg);
        JMSException jmse = new jakarta.jms.JMSException(errMsg);
        jmse.initCause(e);
        throw jmse;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) JMSException(jakarta.jms.JMSException) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) JMSException(jakarta.jms.JMSException) MessageNotWriteableException(jakarta.jms.MessageNotWriteableException) JMSException(jakarta.jms.JMSException) MessageFormatException(jakarta.jms.MessageFormatException)

Aggregations

FilteringObjectInputStream (com.sun.messaging.jmq.util.io.FilteringObjectInputStream)22 ObjectInputStream (java.io.ObjectInputStream)13 ByteArrayInputStream (java.io.ByteArrayInputStream)12 DataInputStream (java.io.DataInputStream)5 Hashtable (java.util.Hashtable)5 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)3 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)2 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)2 TransactionWork (com.sun.messaging.jmq.jmsserver.data.TransactionWork)2 JMSException (jakarta.jms.JMSException)2 MessageFormatException (jakarta.jms.MessageFormatException)2 MessageNotWriteableException (jakarta.jms.MessageNotWriteableException)2 IOException (java.io.IOException)2 ByteBuffer (java.nio.ByteBuffer)2 HashMap (java.util.HashMap)2 UpdateOpaqueDataCallback (com.sun.messaging.bridge.api.UpdateOpaqueDataCallback)1 BranchXid (com.sun.messaging.bridge.service.jms.tx.BranchXid)1 GlobalXid (com.sun.messaging.bridge.service.jms.tx.GlobalXid)1 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)1 ClusterTransaction (com.sun.messaging.jmq.jmsserver.data.ClusterTransaction)1