Examples of SCMPMessage


Examples of org.serviceconnector.scmp.SCMPMessage

          PublishMessageQueue<SCMPMessage> publishMessageQueue = publishService.getMessageQueue();
          writer.writeStartElement("publishMessageQueue");
          Iterator<LinkedNode<SCMPMessage>> sqIter = publishMessageQueue.nodeIterator();
          while (sqIter.hasNext()) {
            LinkedNode<SCMPMessage> node = sqIter.next();
            SCMPMessage scmpMessage = node.getValue();
            writer.writeStartElement("scmpMessage");
            writer.writeStartElement("header");
            Map<String, String> header = scmpMessage.getHeader();
            for (Entry<?, ?> headerEntry : header.entrySet()) {
              writer.writeStartElement((String) headerEntry.getKey());
              Object value = headerEntry.getValue();
              if (value != null) {
                writer.writeCData(value.toString());
              }
              writer.writeEndElement();
            }
            writer.writeEndElement(); // end of header
            writer.writeStartElement("references");
            writer.writeCData(String.valueOf(node.getReferenceCount()));
            writer.writeEndElement(); // end of references
            writer.writeEndElement(); // end of scmpMessage
          }
          for (int j = 0; j < simulation; j++) {
            SCMPMessage scmpMessage = new SCMPMessage();
            scmpMessage.setHeader(SCMPHeaderAttributeKey.MASK, "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
            scmpMessage.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, j);
            writer.writeStartElement("scmpMessage");
            writer.writeStartElement("header");
            Map<String, String> header = scmpMessage.getHeader();
            for (Entry<?, ?> headerEntry : header.entrySet()) {
              writer.writeStartElement((String) headerEntry.getKey());
              Object value = headerEntry.getValue();
              if (value != null) {
                writer.writeCData(value.toString());
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void receive(SCMPMessage reply) {
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();

    if (reply.isFault()) {
      // response is an error - remove session id from header
      reply.removeHeader(SCMPHeaderAttributeKey.SESSION_ID);
      // remove session from server
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

     */
    private void handlingLargeResponse(SCMPMessage scmpReply) throws Exception {
      // response is a part - response is large, continue polling
      // SCMPLargeResponse handles parts of large requests, putting all together
      this.largeResponse = new SCMPCompositeReceiver(requestMsg, scmpReply);
      SCMPMessage message = largeResponse.getPart();
      // handling msgSequenceNr
      if (SCMPMessageSequenceNr.necessaryToWrite(message.getMessageType())) {
        // increment msgSequenceNr
        this.msgSequenceNr.incrementAndGetMsgSequenceNr();
        message.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
      }
      // updating cache part number for poll request
      Integer partNr = scmpReply.getHeaderInt(SCMPHeaderAttributeKey.CACHE_PARTN_NUMBER);
      if (partNr == null) {
        partNr = 1;
      }
      message.setHeader(SCMPHeaderAttributeKey.CACHE_PARTN_NUMBER, partNr);
      LOGGER.debug("handling large response using cache id = " + message.getCacheId());
      // poll & exit
      this.connectionCtx.getConnection().send(message, this);
      LOGGER.debug("handling large response after send using cache id = " + message.getCacheId());
    }
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void receive(Exception ex) {
    SCMPMessage reqMessage = this.request.getMessage();
    String sid = reqMessage.getSessionId();
    LOGGER.warn("receive exception sid=" + sid + " " + ex.toString());
    server.removeSession(session);
    SCMPMessage fault = null;
    String serviceName = reqMessage.getServiceName();
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling
      fault = new SCMPMessageFault(SCMPError.OPERATION_TIMEOUT, "Operation timeout expired on SC create session sid=" + sid);
    } else if (ex instanceof IOException) {
      fault = new SCMPMessageFault(SCMPError.CONNECTION_EXCEPTION, "broken connection on SC create session sid=" + sid);
    } else {
      fault = new SCMPMessageFault(SCMPError.SC_ERROR, "executing create session failed sid=" + sid);
    }
    fault.setIsReply(true);
    fault.setServiceName(serviceName);
    fault.setMessageType(this.msgType);
    this.response.setSCMP(fault);
    this.responderCallback.responseCallback(request, response);
  }
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

     * @return true, if successful
     * @throws Exception
     *             the exception
     */
    private boolean handlingLargeRequest(SCMPMessage scmpReply) throws Exception {
      SCMPMessage part = null;

      part = largeRequest.getCurrentPart();
      if (part.isRequest()) {
        /*
         * request has been sent completely. The response can be small or large, this doesn't matter, we continue reading any
         * large response later
         */
        return true;
      }
      if (largeRequest.hasNext() == false) {
        if (this.requestMsg.isGroup()) {
          /*
           * client processes group call, he needs to get the response - happens in special case: client sends a single
           * part of a group but content is to large and we need to split
           */
          return true;
        }
        LOGGER.warn("largeRequest.hasNext() == false but part request not done");
        return true;
      }
      part = largeRequest.getNext();
      // handling msgSequenceNr
      if (SCMPMessageSequenceNr.necessaryToWrite(part.getMessageType())) {
        this.msgSequenceNr.incrementAndGetMsgSequenceNr();
        part.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
      }
      this.connectionCtx.getConnection().send(part, this);
      return false;
    }
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage message = request.getMessage();
    String serviceName = message.getServiceName();
    // check service is present
    Service abstractService = this.getService(serviceName);

    // enhance ipAddressList
    String ipAddressList = message.getHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST);
    ipAddressList = ipAddressList + Constants.SLASH + request.getRemoteSocketAddress().getAddress().getHostAddress();
    message.setHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST, ipAddressList);

    switch (abstractService.getType()) {
    case CASCADED_SESSION_SERVICE:
      int oti = message.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
      CascadedSC cascadedSC = ((CascadedSessionService) abstractService).getCascadedSC();
      CommandCascCallback callback = new CommandCascCallback(request, response, responderCallback);
      cascadedSC.echo(message, callback, oti);
      return;
    default:
      // code for other types of services is below
      break;
    }
    String sessionId = message.getSessionId();
    Session session = this.getSessionById(sessionId);
    message.setIsReply(true);
    response.setSCMP(message);

    synchronized (session) {
      // needs to be in sync because of setting pending request & reseting timer
      if (session.hasPendingRequest() == false) {
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void validate(IRequest request) throws Exception {
    SCMPMessage message = request.getMessage();
    try {
      // serviceName mandatory
      String serviceName = message.getServiceName();
      ValidatorUtility.validateStringLengthTrim(1, serviceName, Constants.MAX_LENGTH_SERVICENAME,
          SCMPError.HV_WRONG_SERVICE_NAME);
      // operation timeout mandatory
      String otiValue = message.getHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
      ValidatorUtility.validateInt(Constants.MIN_OTI_VALUE_CLN, otiValue, Constants.MAX_OTI_VALUE,
          SCMPError.HV_WRONG_OPERATION_TIMEOUT);
      // sessionId mandatory
      String sessionId = message.getSessionId();
      ValidatorUtility.validateStringLengthTrim(1, sessionId, Constants.MAX_STRING_LENGTH_256, SCMPError.HV_WRONG_SESSION_ID);
    } catch (HasFaultResponseException ex) {
      LOGGER.warn("validation error " + ex.toString());
      // needs to set message type at this point
      ex.setMessageType(getKey());
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage reqMessage = request.getMessage();
    String subscriptionId = reqMessage.getSessionId();
    SCMPMessage message = null;
    Subscription subscription = this.getSubscriptionById(subscriptionId);
    // looks up subscription queue
    PublishMessageQueue<SCMPMessage> publishMessageQueue = this.getPublishMessageQueueById(subscription);
    synchronized (publishMessageQueue) {
      // reset subscription timeout to NOI+ECI
      this.subscriptionRegistry.resetSubscriptionTimeout(subscription,
          subscription.getNoDataIntervalMillis() + subscription.getSubscriptionTimeoutMillis());
      // tries polling message
      message = publishMessageQueue.getMessageOrListen(subscriptionId, request, response);
      if (message == null) {
        // no message available, switched to listening mode for new message
        return;
      }
    }
    LOGGER.debug("CRP message found in queue subscriptionId " + subscriptionId);
    // message found in subscription queue set up reply
    SCMPMessage reply = new SCMPMessage();
    if (message.isPart()) {
      // message from queue is of type part - outgoing must be part too, no poll request
      reply = new SCMPPart(false);
    }
    reply.setServiceName(reqMessage.getServiceName());
    reply.setSessionId(reqMessage.getSessionId());
    reply.setMessageType(reqMessage.getMessageType());
    reply.setIsReply(true);
    reply.setBody(message.getBody());
    reply.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, message.getMessageSequenceNr());
    String messageInfo = message.getHeader(SCMPHeaderAttributeKey.MSG_INFO);
    if (messageInfo != null) {
      reply.setHeader(SCMPHeaderAttributeKey.MSG_INFO, messageInfo);
    }
    reply.setHeader(SCMPHeaderAttributeKey.MASK, message.getHeader(SCMPHeaderAttributeKey.MASK));
    response.setSCMP(reply);
    // reset subscription timeout to ECI
    this.subscriptionRegistry.resetSubscriptionTimeout(subscription, subscription.getSubscriptionTimeoutMillis());
    // message already gotten from queue no asynchronous process necessary call callback right away
    responderCallback.responseCallback(request, response);
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void validate(IRequest request) throws Exception {
    SCMPMessage message = request.getMessage();
    try {
      // msgSequenceNr mandatory
      String msgSequenceNr = message.getMessageSequenceNr();
      ValidatorUtility.validateLong(1, msgSequenceNr, SCMPError.HV_WRONG_MESSAGE_SEQUENCE_NR);
      // serviceName mandatory
      String serviceName = message.getServiceName();
      ValidatorUtility.validateStringLengthTrim(1, serviceName, Constants.MAX_LENGTH_SERVICENAME,
          SCMPError.HV_WRONG_SERVICE_NAME);
      // sessionId mandatory
      String sessionId = message.getSessionId();
      ValidatorUtility.validateStringLengthTrim(1, sessionId, Constants.MAX_STRING_LENGTH_256, SCMPError.HV_WRONG_SESSION_ID);
    } catch (HasFaultResponseException ex) {
      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
View Full Code Here

Examples of org.serviceconnector.scmp.SCMPMessage

  }

  /** {@inheritDoc} */
  @Override
  public void run(IRequest request, IResponse response, IResponderCallback responderCallback) throws Exception {
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();

    // check service is present
    Service abstractService = this.getService(serviceName);
    String cascSubscriptionId = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_SUBSCRIPTION_ID);
    Subscription cascSubscription = this.getSubscriptionById(cascSubscriptionId);
    String cascadedSCMask = reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_MASK);
    int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);

    // update csc subscription id list for cascaded subscription
    cascSubscription.removeCscSubscriptionId(reqMessage.getSessionId());

    switch (abstractService.getType()) {
    case CASCADED_PUBLISH_SERVICE:
      CascadedPublishService cascadedPublishService = (CascadedPublishService) abstractService;
      // publish service is cascaded
      CascadedSC cascadedSC = cascadedPublishService.getCascadedSC();

      PublishMessageQueue<SCMPMessage> queue = ((IPublishService) cascSubscription.getService()).getMessageQueue();
      if (cascadedSCMask == null) {
        // subscription abort made by cascaded SC on behalf of his last client
        this.subscriptionRegistry.removeSubscription(cascSubscription.getId());
        queue.unsubscribe(cascSubscription.getId());
        cascSubscription.getServer().removeSession(cascSubscription);
        SubscriptionLogger.logUnsubscribe(serviceName, cascSubscription.getId());
      } else {
        // unsubscribe made by cascaded SC on behalf of a clients, others are left
        SubscriptionMask cascSCMask = new SubscriptionMask(cascadedSCMask);
        queue.changeSubscription(cascSubscription.getId(), cascSCMask);
        cascSubscription.setMask(cascSCMask);
        SubscriptionLogger.logChangeSubscribe(serviceName, cascSubscription.getId(), cascadedSCMask);
      }
      CscAbortSubscriptionCommandCallback callback = new CscAbortSubscriptionCommandCallback(request, response,
          responderCallback, cascSubscription);
      cascadedSC.cascadedSCAbortSubscription(cascadedPublishService.getCascClient(), reqMessage, callback, oti);
      return;
    default:
      // code for other types of services is below
      break;
    }
    StatefulServer server = (StatefulServer) cascSubscription.getServer();

    PublishMessageQueue<SCMPMessage> publishMessageQueue = ((IPublishService) cascSubscription.getService()).getMessageQueue();
    if (cascadedSCMask == null) {
      // subscription abort made by cascaded SC on behalf of his last client
      this.subscriptionRegistry.removeSubscription(cascSubscription.getId());
      publishMessageQueue.unsubscribe(cascSubscription.getId());
      cascSubscription.getServer().removeSession(cascSubscription);
      SubscriptionLogger.logUnsubscribe(serviceName, cascSubscription.getId());
    } else {
      // unsubscribe made by cascaded SC on behalf of a clients, others are left
      SubscriptionMask cascSCMask = new SubscriptionMask(cascadedSCMask);
      publishMessageQueue.changeSubscription(cascSubscription.getId(), cascSCMask);
      cascSubscription.setMask(cascSCMask);
      SubscriptionLogger.logChangeSubscribe(serviceName, cascSubscription.getId(), cascadedSCMask);
    }
    // set up abort message
    SCMPMessage abortMessage = new SCMPMessage();
    abortMessage.setHeader(SCMPHeaderAttributeKey.SC_ERROR_CODE, SCMPError.SESSION_ABORT.getErrorCode());
    abortMessage.setHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT,
        SCMPError.SESSION_ABORT.getErrorText("Cascaded subscription abort received."));
    abortMessage.setServiceName(serviceName);
    abortMessage.setSessionId(reqMessage.getSessionId());
    abortMessage.setHeader(SCMPHeaderAttributeKey.OPERATION_TIMEOUT, oti);
    server.abortSessionAndWaitMech(oti, abortMessage, "Cascaded subscription abort received", true);
    // reply to client
    reqMessage.setIsReply(true);
    response.setSCMP(reqMessage);
    responderCallback.responseCallback(request, response);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.