Search in sources :

Example 1 with TimerListener

use of com.swiftmq.tools.timer.TimerListener 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)1 TimerEvent (com.swiftmq.tools.timer.TimerEvent)1 TimerListener (com.swiftmq.tools.timer.TimerListener)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 SaslException (javax.security.sasl.SaslException)1