Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCSubscribeMessage


     
      SCPublishService publishService = sc.newPublishService("cacheGuardian1"); // name of the service to use

      DemoPublishClientCallback pubCbk = new DemoPublishClientCallback(publishService); // callback on service!!
      // set up subscribe message
      SCSubscribeMessage subMsg = new SCSubscribeMessage();
      String mask = "0000121ABCDEFGHIJKLMNO-----------X-----------";
      subMsg.setSessionInfo("subscription-info"); // optional
      subMsg.setData("certificate or what so ever"); // optional
      subMsg.setMask(mask); // mandatory
      subMsg.setNoDataIntervalSeconds(100); // mandatory
      SCSubscribeMessage subReply = publishService.subscribe(subMsg, pubCbk); // regular subscribe
     
      responseMsg = sessionSrv.execute(requestMsg); // regular synchronous call
      LOGGER.info("Message sent with cacheId=" + requestMsg.getData());
      LOGGER.info("Message received from cache=" + responseMsg.getData());   
     
View Full Code Here


      String serviceName = "publish-1";
      service = sc.newPublishService(serviceName); // name of the service to use

      DemoPublishClientCallback cbk = new DemoPublishClientCallback(service); // callback on service!!
      // set up subscribe message
      SCSubscribeMessage msg = new SCSubscribeMessage();
      String mask = "0000121ABCDEFGHIJKLMNO-----------X-----------";
      msg.setSessionInfo("subscription-info"); // optional
      msg.setData("certificate or what so ever"); // optional
      msg.setMask(mask); // mandatory
      msg.setNoDataIntervalSeconds(100); // mandatory
      SCSubscribeMessage reply = service.subscribe(msg, cbk); // regular subscribe

      String sid = service.getSessionId();

      // wait to receive messages
      while (cbk.receivedMsg < 5) {
        Thread.sleep(1500);
      }
    } catch (Exception e) {
      LOGGER.error("run", e);
    } finally {
      try {
        SCSubscribeMessage msg = new SCSubscribeMessage();
        msg.setSessionInfo("kill server");
        service.unsubscribe(5, msg);
        sc.detach(2); // detaches from SC, stops communication
      } catch (Exception e) {
        LOGGER.info("cleanup " + e.toString());
      }
View Full Code Here

   *            the operation timeout milliseconds
   * @return the sCMP message
   */
  protected final SCMPMessage baseSubscribe(SCMPMessage reqMessage, int operationTimeoutMillis) {
    // create scMessage
    SCSubscribeMessage scMessage = new SCSubscribeMessage();
    scMessage.setData(reqMessage.getBody());
    scMessage.setDataLength(reqMessage.getBodyLength());
    scMessage.setCompressed(reqMessage.getHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION));
    scMessage.setMessageInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.MSG_INFO));
    scMessage.setSessionInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.SESSION_INFO));
    scMessage.setSessionId(reqMessage.getSessionId());
    scMessage.setMask(reqMessage.getHeader(SCMPHeaderAttributeKey.MASK));
    scMessage.setServiceName(reqMessage.getServiceName());

    // call servlet service implementation
    SCMessage scReply = ((ISCPublishServerCallback) this).subscribe(scMessage, operationTimeoutMillis);

    // set up reply
View Full Code Here

   */
  protected final SCMPMessage baseUnsubscribe(SCMPMessage reqMessage, int operationTimeoutMillis) {
    // remove session from composite registry
    SCBaseServlet.compositeRegistry.removeSession(reqMessage.getSessionId());
    // create scMessage
    SCSubscribeMessage scMessage = new SCSubscribeMessage();
    scMessage.setData(reqMessage.getBody());
    scMessage.setDataLength(reqMessage.getBodyLength());
    scMessage.setSessionId(reqMessage.getSessionId());
    scMessage.setServiceName(reqMessage.getServiceName());
    scMessage.setSessionInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.SESSION_INFO));
    // call servlet service implementation
    ((ISCPublishServerCallback) this).unsubscribe(scMessage, operationTimeoutMillis);

    // set up reply
    SCMPMessage reply = new SCMPMessage();
View Full Code Here

   *            the operation timeout milliseconds
   * @return the sCMP message
   */
  protected final SCMPMessage baseAbortSubscription(SCMPMessage reqMessage, int operationTimeoutMillis) {
    // create scMessage
    SCSubscribeMessage scMessage = new SCSubscribeMessage();
    scMessage.setData(reqMessage.getBody());
    scMessage.setDataLength(reqMessage.getBodyLength());
    scMessage.setCompressed(reqMessage.getHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION));
    scMessage.setMessageInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.MSG_INFO));
    scMessage.setSessionId(reqMessage.getSessionId());
    scMessage.setServiceName(reqMessage.getServiceName());
    scMessage.setMask(reqMessage.getHeader(SCMPHeaderAttributeKey.MASK));

    // call servlet service implementation
    ((ISCPublishServerCallback) this).abortSubscription(scMessage, operationTimeoutMillis);

    // set up reply
View Full Code Here

   *            the operation timeout milliseconds
   * @return the sCMP message
   */
  protected final SCMPMessage baseChangeSubscription(SCMPMessage reqMessage, int operationTimeoutMillis) {
    // create scMessage
    SCSubscribeMessage scMessage = new SCSubscribeMessage();
    scMessage.setData(reqMessage.getBody());
    scMessage.setDataLength(reqMessage.getBodyLength());
    scMessage.setCompressed(reqMessage.getHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION));
    scMessage.setMessageInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.MSG_INFO));
    scMessage.setSessionInfo(reqMessage.getHeader(SCMPHeaderAttributeKey.SESSION_INFO));
    scMessage.setSessionId(reqMessage.getSessionId());
    scMessage.setMask(reqMessage.getHeader(SCMPHeaderAttributeKey.MASK));
    scMessage.setServiceName(reqMessage.getServiceName());
    scMessage.setActualMask(reqMessage.getHeader(SCMPHeaderAttributeKey.ACTUAL_MASK));

    // call servlet service implementation
    SCMessage scReply = ((ISCPublishServerCallback) this).changeSubscription(scMessage, operationTimeoutMillis);

    // set up reply
View Full Code Here

    }
    // 4. post process, reply to client
    this.sessionId = reply.getSessionId();
    this.sessionActive = true;
    this.receivePublication();
    SCSubscribeMessage replyToClient = new SCSubscribeMessage();
    replyToClient.setData(reply.getBody());
    replyToClient.setDataLength(reply.getBodyLength());
    replyToClient.setCompressed(reply.getHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION));
    replyToClient.setSessionId(this.sessionId);
    replyToClient.setSessionInfo(reply.getHeader(SCMPHeaderAttributeKey.SESSION_INFO));
    replyToClient.setAppErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.APP_ERROR_CODE));
    replyToClient.setAppErrorText(reply.getHeader(SCMPHeaderAttributeKey.APP_ERROR_TEXT));
    return replyToClient;
  }
View Full Code Here

      ex.setAppErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.APP_ERROR_CODE));
      ex.setAppErrorText(reply.getHeader(SCMPHeaderAttributeKey.APP_ERROR_TEXT));
      throw ex;
    }
    // 4. post process, reply to client
    SCSubscribeMessage replyToClient = new SCSubscribeMessage();
    replyToClient.setData(reply.getBody());
    replyToClient.setDataLength(reply.getBodyLength());
    replyToClient.setCompressed(reply.getHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION));
    replyToClient.setSessionId(this.sessionId);
    replyToClient.setSessionInfo(reply.getHeader(SCMPHeaderAttributeKey.SESSION_INFO));
    replyToClient.setAppErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.APP_ERROR_CODE));
    replyToClient.setAppErrorText(reply.getHeader(SCMPHeaderAttributeKey.APP_ERROR_TEXT));
    return replyToClient;
  }
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t02a_receive() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage();
    SCSubscribeMessage subMsgResponse = null;
    msgCallback = new MsgCallback(publishService);
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.publishCompressedMsgCmd);
    int nrMessages = 1000;
    subMsgRequest.setData(Integer.toString(nrMessages));
    subMsgRequest.setDataLength(((String) subMsgRequest.getData()).length());
    msgCallback.setExpectedMessages(nrMessages);
    subMsgResponse = publishService.subscribe(subMsgRequest, msgCallback);
    Assert.assertNotNull("the session ID is null", publishService.getSessionId());
    Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
    Assert.assertEquals("compression is not the same", subMsgRequest.isCompressed(), subMsgResponse.isCompressed());
    Assert.assertTrue("is not subscribed", publishService.isSubscribed());

    msgCallback.waitForMessage(20);
    Assert.assertEquals("Nr messages does not match", nrMessages, msgCallback.getMessageCount());
    SCMessage response = msgCallback.getMessage();
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t02b_receive() throws Exception {
    publishService = client.newPublishService(TestConstants.pubServiceName1);
    SCSubscribeMessage subMsgRequest = new SCSubscribeMessage();
    SCSubscribeMessage subMsgResponse = null;
    msgCallback = new MsgCallback(publishService);
    subMsgRequest.setMask(TestConstants.mask);
    subMsgRequest.setSessionInfo(TestConstants.publishCompressedMsgCmd);
    int nrMessages = 5000;
    subMsgRequest.setData(Integer.toString(nrMessages));
    subMsgRequest.setDataLength(((String) subMsgRequest.getData()).length());
    msgCallback.setExpectedMessages(nrMessages);
    subMsgResponse = publishService.subscribe(subMsgRequest, msgCallback);
    Assert.assertNotNull("the session ID is null", publishService.getSessionId());
    Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
    Assert.assertEquals("compression is not the same", subMsgRequest.isCompressed(), subMsgResponse.isCompressed());
    Assert.assertTrue("is not subscribed", publishService.isSubscribed());

    msgCallback.waitForMessage(5000);
    Assert.assertEquals("Nr messages does not match", nrMessages, msgCallback.getMessageCount());
    SCMessage response = msgCallback.getMessage();
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.SCSubscribeMessage

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.