Search in sources :

Example 1 with RequestHandler

use of com.swiftmq.impl.routing.single.smqpr.RequestHandler in project swiftmq-ce by iitsoftware.

the class XARecoveryStage method init.

protected void init() {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init...");
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.SMQRFactory.START_STAGE_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + "...");
            RecoveryRequest rc = new RecoveryRequest();
            rc.setBranchQualifier(recoveryBranchQ);
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", sending request=" + rc);
            routingConnection.getOutboundQueue().enqueue(rc);
            routingConnection.setXaSelected(true);
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v942.SMQRFactory.RECOVERY_REPREQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + "...");
            RecoveryReplyRequest reply = (RecoveryReplyRequest) request;
            if (reply.isOk()) {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", do recovery");
                // do recovery
                List localXids = getPreparedXids(new Filter(recoveryBranchQ));
                List remoteXids = reply.getXidList();
                doRecover(localXids, remoteXids);
                localRecovered = true;
                if (remoteRecovered) {
                    if (ctx.traceSpace.enabled)
                        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", launching delivery stage");
                    getStageQueue().setStage(new XADeliveryStage(ctx, routingConnection));
                }
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", start remote delivery");
                // start delivery
                routingConnection.getOutboundQueue().enqueue(new StartDeliveryRequest());
            } else {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", disconnect");
                ctx.logSwiftlet.logError(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/exception: " + reply.getException());
                ctx.networkSwiftlet.getConnectionManager().removeConnection(routingConnection.getConnection());
            }
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v942.SMQRFactory.RECOVERY_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request);
            // It then sends a request by itself to ensure the XARecoveryStage is active at the connector side.
            if (listener)
                getStageQueue().enqueue(new StartStageRequest());
            RecoveryRequest pr = (RecoveryRequest) request;
            RecoveryReplyRequest reply = new RecoveryReplyRequest();
            reply.setOk(true);
            // fill xid list
            reply.setXidList(getPreparedXids(new Filter(pr.getBranchQualifier())));
            routingConnection.getOutboundQueue().enqueue(reply);
            remoteRecovered = true;
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v942.SMQRFactory.COMMIT_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request);
            CommitRequest cr = (CommitRequest) request;
            XAContext xac = ctx.xaResourceManagerSwiftlet.getXAContext(cr.getXid());
            try {
                xac.commit(false);
            } catch (XAContextException e) {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/visited, request=" + request + ", exception=" + e);
                ctx.logSwiftlet.logError(ctx.routingSwiftlet.getName(), toString() + "/visited, request=" + request + ", exception=" + e);
            }
            ctx.xaResourceManagerSwiftlet.removeXAContext(cr.getXid());
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v942.SMQRFactory.STARTDELIVERY_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", launching delivery stage");
            if (localRecovered && remoteRecovered)
                getStageQueue().setStage(new XADeliveryStage(ctx, routingConnection));
        }
    });
    if (!listener)
        getStageQueue().enqueue(new StartStageRequest());
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init done");
}
Also used : CommitRequest(com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest) RequestHandler(com.swiftmq.impl.routing.single.smqpr.RequestHandler) RecoveryRequest(com.swiftmq.impl.routing.single.smqpr.v942.RecoveryRequest) XAContext(com.swiftmq.swiftlet.xa.XAContext) XidFilter(com.swiftmq.swiftlet.xa.XidFilter) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) Request(com.swiftmq.tools.requestreply.Request) CommitRequest(com.swiftmq.impl.routing.single.smqpr.v942.CommitRequest) RecoveryRequest(com.swiftmq.impl.routing.single.smqpr.v942.RecoveryRequest) RecoveryReplyRequest(com.swiftmq.impl.routing.single.smqpr.v942.RecoveryReplyRequest) StartDeliveryRequest(com.swiftmq.impl.routing.single.smqpr.v942.StartDeliveryRequest) StartDeliveryRequest(com.swiftmq.impl.routing.single.smqpr.v942.StartDeliveryRequest) ArrayList(java.util.ArrayList) List(java.util.List) RecoveryReplyRequest(com.swiftmq.impl.routing.single.smqpr.v942.RecoveryReplyRequest) XAContextException(com.swiftmq.swiftlet.xa.XAContextException)

Example 2 with RequestHandler

use of com.swiftmq.impl.routing.single.smqpr.RequestHandler in project swiftmq-ce by iitsoftware.

the class XARecoveryStage method init.

protected void init() {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init...");
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.SMQRFactory.START_STAGE_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + "...");
            RecoveryRequest rc = new RecoveryRequest();
            rc.setBranchQualifier(recoveryBranchQ);
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", sending request=" + rc);
            routingConnection.getOutboundQueue().enqueue(rc);
            routingConnection.setXaSelected(true);
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v400.SMQRFactory.RECOVERY_REPREQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + "...");
            RecoveryReplyRequest reply = (RecoveryReplyRequest) request;
            if (reply.isOk()) {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", do recovery");
                // do recovery
                List localXids = getPreparedXids(new Filter(recoveryBranchQ));
                List remoteXids = reply.getXidList();
                doRecover(localXids, remoteXids);
                localRecovered = true;
                if (remoteRecovered) {
                    if (ctx.traceSpace.enabled)
                        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", launching delivery stage");
                    getStageQueue().setStage(new XADeliveryStage(ctx, routingConnection));
                }
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", start remote delivery");
                // start delivery
                routingConnection.getOutboundQueue().enqueue(new StartDeliveryRequest());
            } else {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", disconnect");
                ctx.logSwiftlet.logError(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/exception: " + reply.getException());
                ctx.networkSwiftlet.getConnectionManager().removeConnection(routingConnection.getConnection());
            }
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v400.SMQRFactory.RECOVERY_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request);
            // It then sends a request by itself to ensure the XARecoveryStage is active at the connector side.
            if (listener)
                getStageQueue().enqueue(new StartStageRequest());
            RecoveryRequest pr = (RecoveryRequest) request;
            RecoveryReplyRequest reply = new RecoveryReplyRequest();
            reply.setOk(true);
            // fill xid list
            reply.setXidList(getPreparedXids(new Filter(pr.getBranchQualifier())));
            routingConnection.getOutboundQueue().enqueue(reply);
            remoteRecovered = true;
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v400.SMQRFactory.COMMIT_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request);
            CommitRequest cr = (CommitRequest) request;
            XAContext xac = ctx.xaResourceManagerSwiftlet.getXAContext(cr.getXid());
            try {
                xac.commit(false);
            } catch (XAContextException e) {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/visited, request=" + request + ", exception=" + e);
                ctx.logSwiftlet.logError(ctx.routingSwiftlet.getName(), toString() + "/visited, request=" + request + ", exception=" + e);
            }
            ctx.xaResourceManagerSwiftlet.removeXAContext(cr.getXid());
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v400.SMQRFactory.STARTDELIVERY_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), XARecoveryStage.this.toString() + "/visited, request=" + request + ", launching delivery stage");
            if (localRecovered && remoteRecovered)
                getStageQueue().setStage(new XADeliveryStage(ctx, routingConnection));
        }
    });
    if (!listener)
        getStageQueue().enqueue(new StartStageRequest());
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init done");
}
Also used : CommitRequest(com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest) RequestHandler(com.swiftmq.impl.routing.single.smqpr.RequestHandler) RecoveryRequest(com.swiftmq.impl.routing.single.smqpr.v400.RecoveryRequest) XAContext(com.swiftmq.swiftlet.xa.XAContext) XidFilter(com.swiftmq.swiftlet.xa.XidFilter) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) CommitRequest(com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest) RecoveryRequest(com.swiftmq.impl.routing.single.smqpr.v400.RecoveryRequest) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) Request(com.swiftmq.tools.requestreply.Request) StartDeliveryRequest(com.swiftmq.impl.routing.single.smqpr.v400.StartDeliveryRequest) RecoveryReplyRequest(com.swiftmq.impl.routing.single.smqpr.v400.RecoveryReplyRequest) StartDeliveryRequest(com.swiftmq.impl.routing.single.smqpr.v400.StartDeliveryRequest) ArrayList(java.util.ArrayList) List(java.util.List) RecoveryReplyRequest(com.swiftmq.impl.routing.single.smqpr.v400.RecoveryReplyRequest) XAContextException(com.swiftmq.swiftlet.xa.XAContextException)

Example 3 with RequestHandler

use of com.swiftmq.impl.routing.single.smqpr.RequestHandler in project swiftmq-ce by iitsoftware.

the class ConnectStage method init.

protected void init() {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init...");
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.SMQRFactory.START_STAGE_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request + "...");
            ConnectRequest cr = new ConnectRequest(ctx.routerName, routingConnection.isXa());
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request + ", sending request= " + cr);
            routingConnection.getOutboundQueue().enqueue(cr);
            startValidTimer();
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v942.SMQRFactory.CONNECT_REPREQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request + "...");
            ConnectReplyRequest reply = (ConnectReplyRequest) request;
            if (reply.isOk()) {
                routingConnection.setRouterName(reply.getRouterName());
                ctx.connectionManager.enqueue(new POAddObject(new ConnectorCallback(reply), null, routingConnection));
            } else {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request + ", disconnect");
                ctx.networkSwiftlet.getConnectionManager().removeConnection(routingConnection.getConnection());
            }
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v942.SMQRFactory.CONNECT_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request);
            ConnectRequest pr = (ConnectRequest) request;
            routingConnection.setRouterName(pr.getRouterName());
            ctx.connectionManager.enqueue(new POAddObject(new ListenerCallback(pr), null, routingConnection));
        }
    });
    if (!listener)
        getStageQueue().enqueue(new StartStageRequest());
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init done");
}
Also used : ConnectRequest(com.swiftmq.impl.routing.single.smqpr.v942.ConnectRequest) ConnectReplyRequest(com.swiftmq.impl.routing.single.smqpr.v942.ConnectReplyRequest) RequestHandler(com.swiftmq.impl.routing.single.smqpr.RequestHandler) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) ConnectRequest(com.swiftmq.impl.routing.single.smqpr.v942.ConnectRequest) Request(com.swiftmq.tools.requestreply.Request) ConnectReplyRequest(com.swiftmq.impl.routing.single.smqpr.v942.ConnectReplyRequest) POAddObject(com.swiftmq.impl.routing.single.manager.po.POAddObject)

Example 4 with RequestHandler

use of com.swiftmq.impl.routing.single.smqpr.RequestHandler in project swiftmq-ce by iitsoftware.

the class AuthStage method init.

protected void init() {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init...");
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.SMQRFactory.START_STAGE_REQ, new RequestHandler() {

        public void visited(Request request) {
            try {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/visited, request=" + request + " ...");
                String password = routingConnection.getPassword();
                if (password == null)
                    throw new Exception("Authentication request by remote router but no password is defined!");
                ChallengeResponseFactory crf = (ChallengeResponseFactory) Class.forName(connectReply.getCrFactory()).newInstance();
                AuthRequest ar = new AuthRequest(crf.createResponse(connectReply.getChallenge(), password));
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/visited, request=" + request + ", sending request: " + ar);
                routingConnection.getOutboundQueue().enqueue(ar);
                startValidTimer();
            } catch (Exception e) {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/visited, request=" + request + ", exception=" + e + ", disconnect");
                ctx.logSwiftlet.logError(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/exception: " + e.getMessage());
                ctx.networkSwiftlet.getConnectionManager().removeConnection(routingConnection.getConnection());
            }
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v400.SMQRFactory.AUTH_REPREQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/visited, request=" + request + "...");
            AuthReplyRequest reply = (AuthReplyRequest) request;
            if (reply.isOk()) {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/visited, request=" + request + ", launching recovery stage");
                // Launch recovery stage
                getStageQueue().setStage(new XARecoveryStage(ctx, routingConnection));
            } else {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/visited, request=" + request + ", disconnect");
                ctx.logSwiftlet.logError(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/exception: " + reply.getException());
                ctx.networkSwiftlet.getConnectionManager().removeConnection(routingConnection.getConnection());
            }
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v400.SMQRFactory.AUTH_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/visited, request=" + request);
            AuthRequest pr = (AuthRequest) request;
            AuthReplyRequest reply = new AuthReplyRequest();
            if (ctx.challengeResponseFactory.verifyResponse(connectReply.getChallenge(), pr.getResponse(), routingConnection.getPassword())) {
                reply.setOk(true);
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/visited, request=" + request + ", response ok, launching recovery stage");
                // Launch recovery stage
                getStageQueue().setStage(new XARecoveryStage(ctx, routingConnection));
            } else {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/visited, request=" + request + ", invalid password, diconnect");
                ctx.logSwiftlet.logError(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/connection rejected, invalid password!");
                reply.setOk(false);
                reply.setException(new Exception("Invalid password!"));
                ctx.timerSwiftlet.addInstantTimerListener(((Long) ctx.root.getProperty("reject-disconnect-delay").getValue()).longValue(), new TimerListener() {

                    public void performTimeAction() {
                        if (ctx.traceSpace.enabled)
                            ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), AuthStage.this.toString() + "/disconnect timeout");
                        ctx.networkSwiftlet.getConnectionManager().removeConnection(routingConnection.getConnection());
                    }
                });
            }
            routingConnection.getOutboundQueue().enqueue(reply);
        }
    });
    if (!listener)
        getStageQueue().enqueue(new StartStageRequest());
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init done");
}
Also used : AuthRequest(com.swiftmq.impl.routing.single.smqpr.v400.AuthRequest) RequestHandler(com.swiftmq.impl.routing.single.smqpr.RequestHandler) ChallengeResponseFactory(com.swiftmq.auth.ChallengeResponseFactory) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) Request(com.swiftmq.tools.requestreply.Request) ConnectReplyRequest(com.swiftmq.impl.routing.single.smqpr.v400.ConnectReplyRequest) AuthReplyRequest(com.swiftmq.impl.routing.single.smqpr.v400.AuthReplyRequest) AuthRequest(com.swiftmq.impl.routing.single.smqpr.v400.AuthRequest) TimerListener(com.swiftmq.swiftlet.timer.event.TimerListener) AuthReplyRequest(com.swiftmq.impl.routing.single.smqpr.v400.AuthReplyRequest)

Example 5 with RequestHandler

use of com.swiftmq.impl.routing.single.smqpr.RequestHandler in project swiftmq-ce by iitsoftware.

the class ConnectStage method init.

protected void init() {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init...");
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.SMQRFactory.START_STAGE_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request + "...");
            ConnectRequest cr = new ConnectRequest(ctx.routerName);
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request + ", sending request= " + cr);
            routingConnection.getOutboundQueue().enqueue(cr);
            startValidTimer();
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v400.SMQRFactory.CONNECT_REPREQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request + "...");
            ConnectReplyRequest reply = (ConnectReplyRequest) request;
            if (reply.isOk()) {
                routingConnection.setRouterName(reply.getRouterName());
                ctx.connectionManager.enqueue(new POAddObject(new ConnectorCallback(reply), null, routingConnection));
            } else {
                if (ctx.traceSpace.enabled)
                    ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request + ", disconnect");
                ctx.networkSwiftlet.getConnectionManager().removeConnection(routingConnection.getConnection());
            }
        }
    });
    visitor.setRequestHandler(com.swiftmq.impl.routing.single.smqpr.v400.SMQRFactory.CONNECT_REQ, new RequestHandler() {

        public void visited(Request request) {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), ConnectStage.this.toString() + "/visited, request=" + request);
            ConnectRequest pr = (ConnectRequest) request;
            routingConnection.setRouterName(pr.getRouterName());
            ctx.connectionManager.enqueue(new POAddObject(new ListenerCallback(pr), null, routingConnection));
        }
    });
    if (!listener)
        getStageQueue().enqueue(new StartStageRequest());
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/init done");
}
Also used : ConnectRequest(com.swiftmq.impl.routing.single.smqpr.v400.ConnectRequest) ConnectReplyRequest(com.swiftmq.impl.routing.single.smqpr.v400.ConnectReplyRequest) RequestHandler(com.swiftmq.impl.routing.single.smqpr.RequestHandler) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) StartStageRequest(com.swiftmq.impl.routing.single.smqpr.StartStageRequest) ConnectRequest(com.swiftmq.impl.routing.single.smqpr.v400.ConnectRequest) Request(com.swiftmq.tools.requestreply.Request) ConnectReplyRequest(com.swiftmq.impl.routing.single.smqpr.v400.ConnectReplyRequest) POAddObject(com.swiftmq.impl.routing.single.manager.po.POAddObject)

Aggregations

RequestHandler (com.swiftmq.impl.routing.single.smqpr.RequestHandler)6 StartStageRequest (com.swiftmq.impl.routing.single.smqpr.StartStageRequest)6 Request (com.swiftmq.tools.requestreply.Request)6 ChallengeResponseFactory (com.swiftmq.auth.ChallengeResponseFactory)2 POAddObject (com.swiftmq.impl.routing.single.manager.po.POAddObject)2 ConnectReplyRequest (com.swiftmq.impl.routing.single.smqpr.v400.ConnectReplyRequest)2 ConnectReplyRequest (com.swiftmq.impl.routing.single.smqpr.v942.ConnectReplyRequest)2 TimerListener (com.swiftmq.swiftlet.timer.event.TimerListener)2 XAContext (com.swiftmq.swiftlet.xa.XAContext)2 XAContextException (com.swiftmq.swiftlet.xa.XAContextException)2 XidFilter (com.swiftmq.swiftlet.xa.XidFilter)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AuthReplyRequest (com.swiftmq.impl.routing.single.smqpr.v400.AuthReplyRequest)1 AuthRequest (com.swiftmq.impl.routing.single.smqpr.v400.AuthRequest)1 CommitRequest (com.swiftmq.impl.routing.single.smqpr.v400.CommitRequest)1 ConnectRequest (com.swiftmq.impl.routing.single.smqpr.v400.ConnectRequest)1 RecoveryReplyRequest (com.swiftmq.impl.routing.single.smqpr.v400.RecoveryReplyRequest)1 RecoveryRequest (com.swiftmq.impl.routing.single.smqpr.v400.RecoveryRequest)1 StartDeliveryRequest (com.swiftmq.impl.routing.single.smqpr.v400.StartDeliveryRequest)1