Package org.serviceconnector.scmp

Examples of org.serviceconnector.scmp.SCMPMessageSequenceNr


      // sending of a large response has already been started and incoming SCMP is a pull request
      if (largeResponse.hasNext()) {
        // there are still parts to send to complete request
        SCMPMessage nextSCMP = largeResponse.getNext();
        // handling msgSequenceNr
        SCMPMessageSequenceNr msgSequenceNr = this.requester.getSCMPMsgSequenceNr();
        nextSCMP.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.incrementAndGetMsgSequenceNr());
        this.writeResponse(scmpReq, nextSCMP, response);
        return true;
      }
      SCBaseServlet.compositeRegistry.removeSCMPLargeResponse(sessionId);
    }
View Full Code Here


   */
  private SCMPMessage handleLargeRequest(HttpServletRequest request, HttpServletResponse response, SCMPMessage scmpReq) {
    String sessionId = scmpReq.getSessionId();
    // gets the large request or creates a new one if necessary
    SCMPCompositeReceiver largeRequest = SCBaseServlet.compositeRegistry.getSCMPLargeRequest(sessionId);
    SCMPMessageSequenceNr msgSequenceNr = this.requester.getSCMPMsgSequenceNr();
    SCMPMessage scmpReply = null;
    if (scmpReq.isPart()) {
      // received message part - request not complete yet
      largeRequest.incomplete();
      // set up poll response - SCMP Version request
      scmpReply = new SCMPPart(scmpReq.getSCMPVersion(), true);
      scmpReply.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.incrementAndGetMsgSequenceNr());
      scmpReply.setIsReply(true);
      scmpReply.setMessageType(scmpReq.getMessageType());
    } else {
      // last message of a chunk message received - request complete now
      largeRequest.complete();
      largeRequest.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.incrementAndGetMsgSequenceNr());
      scmpReply = largeRequest;
    }

    if (largeRequest != null && largeRequest.isComplete() == false) {
      // request is not complete yet
View Full Code Here

        reply.setHeaderFlag(SCMPHeaderAttributeKey.REJECT_SESSION);
      } else {
        // create session in SCMPSessionCompositeRegistry
        SrvCommandAdapter.sessionCompositeRegistry.addSession(sessionId);
        // handling msgSequenceNr
        SCMPMessageSequenceNr msgSequenceNr = SrvCommandAdapter.sessionCompositeRegistry.getSCMPMsgSequenceNr(sessionId);
        reply.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
      }
      if (scReply.getSessionInfo() != null) {
        reply.setHeader(SCMPHeaderAttributeKey.SESSION_INFO, scReply.getSessionInfo());
      }
    }
View Full Code Here

    try {
      // inform callback with scMessages
      srvService.getCallback().unsubscribe(scMessage,
          Integer.parseInt(reqMessage.getHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT)));
      // handling msgSequenceNr
      SCMPMessageSequenceNr msgSequenceNr = SrvCommandAdapter.sessionCompositeRegistry.getSCMPMsgSequenceNr(sessionId);
      msgSequenceNr.incrementAndGetMsgSequenceNr();
      // set up reply
      SCMPMessage reply = new SCMPMessage();
      reply.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
      reply.setServiceName(serviceName);
      reply.setSessionId(reqMessage.getSessionId());
      reply.setMessageType(this.getKey());
      response.setSCMP(reply);
    } finally {
View Full Code Here

    // inform callback with scMessages
    SCMessage scReply = srvService.getCallback().execute(scMessage,
        Integer.parseInt(reqMessage.getHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT)));

    // handling msgSequenceNr
    SCMPMessageSequenceNr msgSequenceNr = SrvCommandAdapter.sessionCompositeRegistry.getSCMPMsgSequenceNr(reqMessage
        .getSessionId());
    msgSequenceNr.incrementAndGetMsgSequenceNr();
    // set up reply
    SCMPMessage reply = new SCMPMessage();
    reply.setServiceName(serviceName);
    reply.setSessionId(reqMessage.getSessionId());
    reply.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
    reply.setMessageType(this.getKey());
    if (scReply != null) {
      reply.setBody(scReply.getData());
      if (scReply.getCacheExpirationDateTime() != null) {
        reply.setHeader(SCMPHeaderAttributeKey.CACHE_EXPIRATION_DATETIME, DateTimeUtility.getDateTimeAsString(scReply
View Full Code Here

    this.remoteNodeConfiguration = remoteNodeConfiguration;
    this.connectionPool = new ConnectionPool(remoteNodeConfiguration.getHost(), remoteNodeConfiguration.getPort(),
        remoteNodeConfiguration.getConnectionType(), remoteNodeConfiguration.getKeepAliveIntervalSeconds(),
        keepAliveTimeoutMillis);
    this.connectionPool.setMaxConnections(remoteNodeConfiguration.getMaxPoolSize());
    this.msgSequenceNr = new SCMPMessageSequenceNr();
  }
View Full Code Here

    try {
      // loading message
      request.load();
      SCMPMessage scmpReq = request.getMessage();
      String sessionId = scmpReq.getSessionId();
      SCMPMessageSequenceNr msgSequenceNr = NettyResponderRequestHandlerTask.compositeRegistry
          .getSCMPMsgSequenceNr(sessionId);

      if (scmpReq.isKeepAlive()) {
        scmpReq.setIsReply(true);
        response.setSCMP(scmpReq);
        response.write();
        return;
      }
      if (scmpReq.isFault()) {
        // fault received nothing to to return - delete largeRequest/largeResponse
        this.sendBadRequestError(response, scmpReq);
        NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeResponse(sessionId);
        NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeRequest(sessionId);
        return;
      }

      // needs to set a key in thread local to identify thread later and get access to the responder
      ResponderRegistry responderRegistry = AppContext.getResponderRegistry();
      int port = request.getLocalSocketAddress().getPort();
      responderRegistry.setThreadLocal(port);

      ICommand command = AppContext.getCommandFactory().getCommand(request.getKey());
      // gets the command
      if (command == null) {
        this.sendBadRequestError(response, scmpReq);
        return;
      }

      if (command.isPassThroughPartMsg() == false) {
        // large messages needs to be handled
        SCMPCompositeSender largeResponse = NettyResponderRequestHandlerTask.compositeRegistry
            .getSCMPLargeResponse(sessionId);

        if (largeResponse != null && scmpReq.isPart()) {
          // sending of a large response has already been started and incoming scmp is a pull request
          if (largeResponse.hasNext()) {
            // there are still parts to send to complete request
            SCMPMessage nextSCMP = largeResponse.getNext();
            // handling msgSequenceNr
            msgSequenceNr.incrementAndGetMsgSequenceNr();
            nextSCMP.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
            response.setSCMP(nextSCMP);
            response.write();
            return;
          }
          NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeResponse(sessionId);
View Full Code Here

    } else {
      // next part of a large request received - add to large request
      largeRequest.add(scmpReq);
    }

    SCMPMessageSequenceNr msgSequenceNr = NettyResponderRequestHandlerTask.compositeRegistry.getSCMPMsgSequenceNr(sessionId);

    if (scmpReq.isPart()) {
      // received message part - request not complete yet
      largeRequest.incomplete();
      // set up poll response - SCMP Version request
      SCMPMessage scmpReply = new SCMPPart(scmpReq.getSCMPVersion(), true);
      scmpReply.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.incrementAndGetMsgSequenceNr());
      scmpReply.setIsReply(true);
      scmpReply.setMessageType(scmpReq.getMessageType());
      response.setSCMP(scmpReply);
    } else {
      // last message of a chunk message received - request complete now
      largeRequest.complete();
      largeRequest.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.incrementAndGetMsgSequenceNr());
      request.setMessage(largeRequest);
    }
    return largeRequest;
  }
View Full Code Here

  @Override
  public void responseCallback(IRequest request, IResponse response) {

    SCMPMessage scmpRequest = request.getMessage();
    String sessionId = scmpRequest.getSessionId();
    SCMPMessageSequenceNr msgSequenceNr = NettyResponderRequestHandlerTask.compositeRegistry.getSCMPMsgSequenceNr(sessionId);
    if (response.isLarge() && AppContext.isScEnvironment() == false) {
      // response is large & not on SC, create a large response for reply
      SCMPCompositeSender largeResponse = new SCMPCompositeSender(response.getSCMP());
      SCMPMessage firstSCMP = largeResponse.getFirst();
      response.setSCMP(firstSCMP);
      if (SCMPMessageSequenceNr.necessaryToWrite(firstSCMP.getMessageType())) {
        // no incrementation necessary - already done inside commands
        firstSCMP.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
      }
      int oti = scmpRequest.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
      // adding compositeReceiver to the composite registry
      NettyResponderRequestHandlerTask.compositeRegistry.addSCMPLargeResponse(sessionId, largeResponse, oti);
    }
View Full Code Here

TOP

Related Classes of org.serviceconnector.scmp.SCMPMessageSequenceNr

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.