Package org.serviceconnector.scmp

Examples of org.serviceconnector.scmp.SCMPMessageFault


      LOGGER.trace("timeout receive publication timer datapointer subscriptionId " + subscriptionId);
      subscription = subscriptionRegistry.getSubscription(subscriptionId);
      if (subscription == null) {
        LOGGER.trace("subscription not found - already deleted subscriptionId=" + subscriptionId);
        // subscription has already been deleted
        SCMPMessageFault fault = new SCMPMessageFault(reqMsg.getSCMPVersion(), SCMPError.SUBSCRIPTION_NOT_FOUND,
            subscriptionId);
        fault.setMessageType(reqMsg.getMessageType());
        response.setSCMP(fault);
      } else {
        // tries polling from queue
        SCMPMessage message = this.publishMessageQueue.getMessage(subscriptionId);
        if (message == null) {
          LOGGER.trace("no message found on queue - subscription timeout set up no data message subscriptionId="
              + subscriptionId);
          // no message found on queue - subscription timeout set up no data message
          reqMsg.setHeaderFlag(SCMPHeaderAttributeKey.NO_DATA);
          reqMsg.setIsReply(true);
          this.response.setSCMP(reqMsg);
        } else {
          // message polling successful
          LOGGER.trace("message found on queue - subscription timeout set up reply message subscriptionId="
              + subscriptionId);
          // set up reply
          SCMPMessage reply = null;
          if (message.isPart()) {
            // message from queue is of type part - outgoing must be part too, no poll request
            reply = new SCMPPart(message.getSCMPVersion(), false, message.getHeader());
          } else {
            reply = new SCMPMessage(message.getSCMPVersion(), message.getHeader());
          }
          reply.setSessionId(subscriptionId);
          reply.setMessageType(reqMsg.getMessageType());
          reply.setIsReply(true);
          reply.setBody(message.getBody());
          this.response.setSCMP(reply);
        }
      }
    } catch (Exception ex) {
      LOGGER.warn("timeout expired procedure failed, " + ex.getMessage());
      SCMPMessageFault scmpFault = new SCMPMessageFault(reqMsg.getSCMPVersion(), SCMPError.SERVER_ERROR, ex.getMessage());
      scmpFault.setMessageType(SCMPMsgType.RECEIVE_PUBLICATION);
      scmpFault.setLocalDateTime();
      response.setSCMP(scmpFault);
    } finally {
      if (subscription != null) {
        // reset subscription timeout to ECI
        subscriptionRegistry.resetSubscriptionTimeout(subscription, subscription.getSubscriptionTimeoutMillis());
View Full Code Here


    case PAC:
      // poll request
      scmpMsg = new SCMPPart(receivedVersion, true);
      break;
    case EXC:
      scmpMsg = new SCMPMessageFault(receivedVersion);
      break;
    case UNDEF:
      throw new EncodingDecodingException("wrong protocol in message not possible to decode");
    default:
      scmpMsg = new SCMPMessage(receivedVersion);
View Full Code Here

    @Override
    public void timeout() {
      LOGGER.warn("oti timeout expiration in sc client API oti=" + this.timeoutMillis);
      this.disconnectConnection(true);
      try {
        SCMPMessageFault fault = new SCMPMessageFault(SCMPVersion.CURRENT, SCMPError.REQUEST_TIMEOUT,
            "Operation timeout expired on client");
        fault.setMessageType(requestMsg.getMessageType());
        this.scmpCallback.receive(fault);
      } catch (Exception e) {
        this.scmpCallback.receive(e);
      }
    }
View Full Code Here

    if (this.synchronous == false) {
      // offering is only allowed if someone is expecting a message - prevents race conditions, an answer might
      // arrive late after operation timeout already run out, can be ignored
      return;
    }
    SCMPMessage fault = new SCMPMessageFault(SCMPVersion.LOWEST, ex, SCMPError.SERVER_ERROR);
    if (this.answer.offer(fault)) {
      // queue empty object can be added
      return;
    }
    // object could not be added - clear queue and offer again
View Full Code Here

      // finally clause handles exception too
      LOGGER.warn("InterruptedException when waiting for message " + e);
    } finally {
      if (reply == null) {
        // time runs out before message got received
        reply = new SCMPMessageFault(SCMPVersion.LOWEST, SCMPError.REQUEST_WAIT_ABORT, "");
        reply.setMessageType(SCMPMsgType.UNDEFINED);
        LOGGER.error("Operation did not complete in time, timeout=" + timeoutMillis + "ms aborting callback="
            + this.getClass().getName());
      }
    }
View Full Code Here

      ConnectionPoolCallback callback = new ConnectionPoolCallback(true);
      connection.send(keepAliveMessage, callback);
      SCMPMessage reply = callback.getMessageSync(this.keepAliveOTIMillis);
      if (reply.isFault() == true) {
        // reply of keep alive is fault
        SCMPMessageFault fault = (SCMPMessageFault) reply;
        LOGGER.error("send keepalive failed - connection gets destroyed, scErrorText="
            + fault.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT) + " scErrorCode="
            + fault.getHeader(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        this.forceClosingConnection(connection, false);
        return;
      }
      synchronized (this) {
        this.usedConnections.remove(connection);
View Full Code Here

      } catch (Exception e) {
        LOGGER.error("Sending a response failed.", e);
      }
    } catch (Exception e2) {
      LOGGER.error("run ", e2);
      SCMPMessageFault scmpFault = new SCMPMessageFault(SCMPVersion.LOWEST, SCMPError.SERVER_ERROR, e2.getMessage());
      scmpFault.setMessageType(SCMPMsgType.UNDEFINED);
      scmpFault.setLocalDateTime();
      response.setSCMP(scmpFault);
      try {
        response.write();
      } catch (Exception ex) {
        LOGGER.error("Sending a response failed.", ex);
View Full Code Here

   *            the SCMP request
   * @throws Exception
   *             the exception
   */
  protected void sendBadRequestError(IResponse response, SCMPMessage scmpReq) throws Exception {
    SCMPMessageFault scmpFault = new SCMPMessageFault(scmpReq.getSCMPVersion(), SCMPError.BAD_REQUEST, "messagType="
        + scmpReq.getMessageType());
    scmpFault.setMessageType(scmpReq.getMessageType());
    scmpFault.setLocalDateTime();
    response.setSCMP(scmpFault);
    response.write();
  }
View Full Code Here

      // last package arrived
      out.close();
      httpCon = session.getHttpURLConnection();
      if (httpCon.getResponseCode() != HttpResponseStatus.OK.getCode()) {
        // error handling - SCMP Version request
        SCMPMessageFault fault = new SCMPMessageFault(message.getSCMPVersion(), SCMPError.FILE_UPLOAD_FAILED,
            httpCon.getResponseMessage());
        LOGGER.warn("Upload file failed =" + httpCon.getResponseMessage());
        return fault;
      }
      httpCon.disconnect();
View Full Code Here

        httpCon = (HttpURLConnection) url.openConnection();
        httpCon.connect();
        in = httpCon.getInputStream();
      } catch (Exception e) {
        // SCMP Version request
        SCMPMessageFault fault = new SCMPMessageFault(message.getSCMPVersion(), SCMPError.SERVER_ERROR,
            httpCon.getResponseMessage() + " " + e.getMessage());
        LOGGER.warn("Download file request failed " + httpCon.getResponseMessage());
        return fault;
      }
      // set session to streaming mode
View Full Code Here

TOP

Related Classes of org.serviceconnector.scmp.SCMPMessageFault

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.