Search in sources :

Example 6 with Milliseconds

use of com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds in project swiftmq-client by iitsoftware.

the class OpenFrame method decode.

private void decode() throws Exception {
    List l = body.getValue();
    AMQPType t = null;
    int idx = 0;
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    if (t.getCode() == AMQPTypeDecoder.NULL)
        throw new Exception("Mandatory field 'containerId' in 'Open' frame is NULL");
    try {
        containerId = (AMQPString) t;
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'containerId' in 'Open' frame: " + e);
    }
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            hostname = (AMQPString) t;
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'hostname' in 'Open' frame: " + e);
    }
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            maxFrameSize = (AMQPUnsignedInt) t;
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'maxFrameSize' in 'Open' frame: " + e);
    }
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            channelMax = (AMQPUnsignedShort) t;
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'channelMax' in 'Open' frame: " + e);
    }
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            idleTimeOut = new Milliseconds(((AMQPUnsignedInt) t).getValue());
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'idleTimeOut' in 'Open' frame: " + e);
    }
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            outgoingLocales = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'outgoingLocales' in 'Open' frame: " + e);
    }
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            incomingLocales = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'incomingLocales' in 'Open' frame: " + e);
    }
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            offeredCapabilities = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'offeredCapabilities' in 'Open' frame: " + e);
    }
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            desiredCapabilities = AMQPTypeDecoder.isArray(t.getCode()) ? (AMQPArray) t : singleToArray(t);
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'desiredCapabilities' in 'Open' frame: " + e);
    }
    // Factory  : ./.
    if (idx >= l.size())
        return;
    t = (AMQPType) l.get(idx++);
    try {
        if (t.getCode() != AMQPTypeDecoder.NULL)
            properties = new Fields(((AMQPMap) t).getValue());
    } catch (ClassCastException e) {
        throw new Exception("Invalid type of field 'properties' in 'Open' frame: " + e);
    }
}
Also used : Fields(com.swiftmq.amqp.v100.generated.transport.definitions.Fields) List(java.util.List) ArrayList(java.util.ArrayList) Milliseconds(com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds) IOException(java.io.IOException)

Example 7 with Milliseconds

use of com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds in project swiftmq-client by iitsoftware.

the class ConnectionDispatcher method visit.

public void visit(POOpen po) {
    if (pTracer.isEnabled())
        pTracer.trace(toString(), ", visit, po=" + po + " ...");
    openPO = po;
    try {
        OpenFrame openFrame = new OpenFrame(0);
        openFrame.setContainerId(new AMQPString(po.getContainerId()));
        openFrame.setChannelMax(new AMQPUnsignedShort(po.getMaxChannel()));
        if (myConnection.getOpenHostname() == null)
            openFrame.setHostname(new AMQPString(remoteHostname));
        else
            openFrame.setHostname(new AMQPString(myConnection.getOpenHostname()));
        maxLocalFrameSize = po.getMaxFrameSize() > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) po.getMaxFrameSize();
        openFrame.setMaxFrameSize(new AMQPUnsignedInt(maxLocalFrameSize));
        myIdleTimeout = po.getIdleTimeout();
        if (myIdleTimeout > 0) {
            openFrame.setIdleTimeOut(new Milliseconds(myIdleTimeout));
            idleTimeoutDelay = po.getIdleTimeout() / 2;
            idleTimeoutChecker = new TimerListener() {

                public void performTimeAction(TimerEvent evt) {
                    dispatch(new POCheckIdleTimeout(null));
                }
            };
            TimerRegistry.Singleton().addTimerListener(idleTimeoutDelay, idleTimeoutChecker);
        }
        outboundHandler.send(openFrame);
    } catch (Exception e) {
        e.printStackTrace();
    }
    checkBothSidesOpen();
    if (pTracer.isEnabled())
        pTracer.trace(toString(), ", visit, po=" + po + " done");
}
Also used : TimerEvent(com.swiftmq.tools.timer.TimerEvent) TimerListener(com.swiftmq.tools.timer.TimerListener) Milliseconds(com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds) SaslException(javax.security.sasl.SaslException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Aggregations

Milliseconds (com.swiftmq.amqp.v100.generated.transport.definitions.Milliseconds)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AMQPException (com.swiftmq.amqp.v100.client.AMQPException)1 POSendMessage (com.swiftmq.amqp.v100.client.po.POSendMessage)1 AddressString (com.swiftmq.amqp.v100.generated.messaging.message_format.AddressString)1 Header (com.swiftmq.amqp.v100.generated.messaging.message_format.Header)1 MessageIdString (com.swiftmq.amqp.v100.generated.messaging.message_format.MessageIdString)1 Properties (com.swiftmq.amqp.v100.generated.messaging.message_format.Properties)1 Fields (com.swiftmq.amqp.v100.generated.transport.definitions.Fields)1 SequenceNo (com.swiftmq.amqp.v100.generated.transport.definitions.SequenceNo)1 AMQPMessage (com.swiftmq.amqp.v100.messaging.AMQPMessage)1 MessageImpl (com.swiftmq.jms.MessageImpl)1 Entity (com.swiftmq.mgmt.Entity)1 TimerListener (com.swiftmq.swiftlet.timer.event.TimerListener)1 Semaphore (com.swiftmq.tools.concurrent.Semaphore)1 TimerEvent (com.swiftmq.tools.timer.TimerEvent)1 TimerListener (com.swiftmq.tools.timer.TimerListener)1 UnknownHostException (java.net.UnknownHostException)1