Package org.jboss.narayana.blacktie.jatmibroker.xatmi

Examples of org.jboss.narayana.blacktie.jatmibroker.xatmi.Response


    X_COMMON dptr = (X_COMMON) connection.tpalloc("X_COMMON", "deposit", 0);

    dptr.setLong("acct_no", 12345678);
    dptr.setShort("amount", (short) 50);

    Response rcvbuf = connection.tpcall(
        RunServer.getServiceNametpcallXCommon(), dptr, 0);
    assertTrue(rcvbuf.getRcode() == 22);
    byte[] received = ((X_OCTET) rcvbuf.getBuffer()).getByteArray();
    byte[] expected = new byte[received.length];
    System.arraycopy("tpcall_x_common".getBytes(), 0, expected, 0,
        "tpcall_x_common".getBytes().length);
    assertTrue(Arrays.equals(received, expected));
  }
View Full Code Here


    double[] balances = new double[2];
    balances[0] = 1.1;
    balances[1] = 2.2;
    aptr.setDoubleArray("balances", balances);

    Response rcvbuf = connection.tpcall(
        RunServer.getServiceNametpcallXCType(), aptr,
        Connection.TPNOCHANGE);
    assertTrue(rcvbuf.getRcode() == 23);
    byte[] received = ((X_OCTET) rcvbuf.getBuffer()).getByteArray();
    byte[] expected = new byte[received.length];
    System.arraycopy("tpcall_x_c_type".getBytes(), 0, expected, 0,
        "tpcall_x_c_type".getBytes().length);
    assertTrue(Arrays.equals(received, expected));
  }
View Full Code Here

    int cancelled = connection.tpcancel(cd);
    assertTrue(cancelled != -1);

    // FAIL TO RETRIEVE THE RESPONSE
    try {
      Response valToTest = connection.tpgetrply(cd, 0);
      assertNull("Could get a reply", valToTest);
      fail("Method completed ok");
    } catch (ConnectionException e) {
      assertTrue(e.getTperrno() == Connection.TPEBADDESC);
    }
View Full Code Here

    log.info(response);

    X_OCTET toReturn = (X_OCTET) svcinfo.getConnection().tpalloc("X_OCTET",
        null, response.getBytes().length);
    toReturn.setByteArray(response.getBytes());
    return new Response(Connection.TPSUCCESS, 0, toReturn, 0);
  }
View Full Code Here

    X_OCTET sbuf = (X_OCTET) connection.tpalloc("X_OCTET", null, 29);
    sbuf.setByteArray("THIS IS YOUR CLIENT SPEAKING".getBytes());
    log.info("Calling tpcall with input: %s"
        + new String(sbuf.getByteArray()));
    int cd = connection.tpacall("JAVASERV", sbuf, 0);
    Response retbuf = connection.tpgetrply(cd, 0);
    log.info("Called tpcall with length: %d output: %s"
        + retbuf.getBuffer().getLen() + " "
        + new String(((X_OCTET) retbuf.getBuffer()).getByteArray()));
    connection.close();
  }
View Full Code Here

      int sendlen = toSend.length() + 1;
      X_OCTET sendbuf = (X_OCTET) connection.tpalloc("X_OCTET", null,
          sendlen);
      sendbuf.setByteArray(toSend.getBytes());

      Response rcvbuf = connection.tpcall(RunServer.getServiceNameTTL(),
          sendbuf, 0);
      fail("Expected TPETIME, got a buffer with rval: "
          + rcvbuf.getRval());
    } catch (ConnectionException e) {
      if (e.getTperrno() != Connection.TPETIME) {
        fail("Expected TPETIME, got: " + e.getTperrno());
      }
    }

    try {
      log.info("send second message");

      String toSend = "test_call_ttl_2";
      int sendlen = toSend.length() + 1;
      X_OCTET sendbuf = (X_OCTET) connection.tpalloc("X_OCTET", null,
          sendlen);
      sendbuf.setByteArray(toSend.getBytes());

      Response rcvbuf = connection.tpcall(RunServer.getServiceNameTTL(),
          sendbuf, 0);
      fail("Expected TPETIME, got a buffer with rval: "
          + rcvbuf.getRval());
    } catch (ConnectionException e) {
      if (e.getTperrno() != Connection.TPETIME) {
        fail("Expected TPETIME, got: " + e.getTperrno());
      }
    }

    try {
      log.info("wait 30 second for first message process");
      Thread.sleep(30 * 1000);
      log.info("wait done");
    } catch (Exception e) {
      log.warn("sleep exception " + e);
    }

    String toSend = "counter";
    int sendlen = toSend.length() + 1;
    X_OCTET sendbuf = (X_OCTET) connection
        .tpalloc("X_OCTET", null, sendlen);
    sendbuf.setByteArray(toSend.getBytes());

    Response rcvbuf = connection.tpcall(RunServer.getServiceNameTTL(),
        sendbuf, 0);

    assertTrue(rcvbuf != null);
    assertTrue(rcvbuf.getBuffer() != null);
    assertTrue(((X_OCTET) rcvbuf.getBuffer()).getByteArray() != null);
    byte[] received = ((X_OCTET) rcvbuf.getBuffer()).getByteArray();

    log.info("received length is " + received.length);
    String counter = new String(received);
    log.info("get message counter of TTL is " + counter);
    assertTrue(received[0] == '1');
View Full Code Here

    // TODO tx_begin(); /* start global transaction */
    /* issue asynchronous request to DEBIT, while it is processing... */
    cd = connection.tpacall(RunServer.getServiceNameDEBIT(), dptr,
        Connection.TPSIGRSTRT);
    /* ...issue synchronous request to CREDIT */
    Response response = connection.tpcall(RunServer.getServiceNameCREDIT(),
        cptr, Connection.TPSIGRSTRT);
    cptr = (X_C_TYPE) response.getBuffer();
    clen = response.getBuffer().getLen();
    /* retrieve DEBIT�s reply */
    response = connection.tpgetrply(cd, Connection.TPSIGRSTRT);
    dptr = (X_C_TYPE) response.getBuffer();
    dlen = response.getBuffer().getLen();
    if (dptr.getInt("output") == OK && cptr.getInt("output") == OK) {
      // TODO tx_commit(); /* commit global transaction */
    } else {
      // TODO tx_rollback(); /* rollback global transaction */
    }
 
View Full Code Here

  private static final Logger log = LogManager
      .getLogger(TPReturnOpenSession2Service.class);

  public Response tpservice(TPSVCINFO svcinfo) {
    log.info("testtpreturn_service_opensession2");
    return new Response(Connection.TPSUCCESS, 0, svcinfo.getBuffer(), 0);
  }
View Full Code Here

        toReturn.setByteArray("test_ttl_service".getBytes());
      } catch (Exception e) {
        log.error("sleep failed with " + e);
      }
    }
    return new Response(Connection.TPSUCCESS, 22, toReturn, 0);
  }
View Full Code Here

    if (ok) {
      toReturn.setByteArray("tpcall_x_c_type".getBytes());
    } else {
      toReturn.setByteArray("fail".getBytes());
    }
    return new Response(Connection.TPSUCCESS, 23, toReturn, 0);
  }
View Full Code Here

TOP

Related Classes of org.jboss.narayana.blacktie.jatmibroker.xatmi.Response

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.