Package org.jboss.narayana.blacktie.jatmibroker.core.transport

Examples of org.jboss.narayana.blacktie.jatmibroker.core.transport.Receiver


    TransportFactory factory = new TransportFactory(properties);
    Transport proxy = factory.createTransport();
    Sender serviceFactory = proxy.getSender("BAR", false);

    String aString = "Hello from Java Land";
    Receiver endpoint = proxy.createReceiver(1, null);
    serviceFactory.send(endpoint.getReplyTo(), (short) 0, 0,
        aString.getBytes(), aString.getBytes().length, 0, 0, 0,
        "X_OCTET", "");
    Message receive = endpoint.receive(0);

    assertNotNull(receive);
    String string = new String(receive.data).intern();
    String expectedResponse = "BAR SAYS HELLO";
    log.debug("Bar ServiceManager service_request response is " + string);
View Full Code Here


    if (conversationalMap == null) {
      conversationalMap = new HashMap<String, Receiver>();
      receivers.put(conversational, conversationalMap);
    }

    Receiver toReturn = conversationalMap.get(serviceName);
    if (toReturn == null) {
      try {
        log.debug("Resolved destination");
        String type = (String) properties.get(
            "blacktie." + serviceName + ".type");
View Full Code Here

    serviceTransport.close();
    transportFactory.close();
  }

  public void test() throws ConnectionException, IOException {
    Receiver serviceDispatcher = serviceTransport.getReceiver(
        "JAVA_Converse", false);
    Sender clientSender = clientTransport.getSender("JAVA_Converse", false);
    Receiver clientReceiver = clientTransport.createReceiver(1, null);
    clientSender.send(clientReceiver.getReplyTo(), (short) 1, 1,
        "hi".getBytes(), 2, 0, 0, 0, "X_OCTET", null);
    Message receive = serviceDispatcher.receive(0);
    receive.ack();
    assertTrue(receive.len == 2);

    Sender serviceSender = serviceTransport.createSender(receive.replyTo);
    Receiver serviceReceiver = serviceTransport.createReceiver(1, null);

    log.info("Chatting");
    for (int i = 0; i < 100; i++) {
      String toSend = String.valueOf(i);
      serviceSender.send(serviceReceiver.getReplyTo(), (short) 1, 1,
          toSend.getBytes(), toSend.length(), 0, 0, 0, "X_OCTET",
          null);
      Message receive2 = clientReceiver.receive(0);
      assertTrue(receive2.len == toSend.length());
      String received = new String(receive2.data);
View Full Code Here

    synchronized (this) {
      correlationId = ++nextId;
      log.trace("Allocated next sessionId: " + correlationId);
    }
    Transport transport = getTransport(svc);
    Receiver endpoint = transport.createReceiver(correlationId,
        responseMonitor);
    temporaryQueues.put(correlationId, endpoint);
    log.trace("Added a queue for: " + correlationId);
    // TODO HANDLE TRANSACTION
    String type = null;
    String subtype = null;
    int len = 0;
    byte[] data = null;
    if (toSend != null) {
      data = toSend.serialize();
      type = toSend.getType();
      subtype = toSend.getSubtype();
      len = toSend.getLen();
    }

    String timeToLive = properties.getProperty("TimeToLive");
    int ttl = 0;

    // Don't set ttl when tpacall and TPNOREPLY set
    if (timeToLive != null
        && ((flags & Connection.TPNOREPLY) != Connection.TPNOREPLY)) {
      ttl = Integer.parseInt(timeToLive) * 1000;
      log.debug("Set ttl: " + ttl);
    }
    transport.getSender(svc, false).send(endpoint.getReplyTo(), (short) 0,
        0, data, len, correlationId, flags, ttl, type, subtype);
    if ((flags & Connection.TPNOREPLY) == Connection.TPNOREPLY) {
      correlationId = 0;
    }
    log.debug("Returning cd: " + correlationId);
View Full Code Here

   *             If the client cannot be cleaned up.
   */
  public int tpcancel(int cd) throws ConnectionException {
    log.debug("tpcancel: " + cd);
    int toReturn = -1;
    Receiver endpoint = temporaryQueues.remove(cd);
    if (endpoint != null) {
      log.debug("closing endpoint");
      endpoint.close();
      log.debug("endpoint closed");
      toReturn = 0;
    } else {
      log.debug("No endpoint available");
      throw new ConnectionException(Connection.TPEBADDESC, "cd " + cd
View Full Code Here

      correlationId = nextId++;
    }
    Transport transport = getTransport(svc);
    Session session = new Session(this, svc, transport, correlationId);

    Receiver receiver = session.getReceiver();
    // TODO HANDLE TRANSACTION
    String type = null;
    String subtype = null;
    int len = 0;
    byte[] data = null;
    if (toSend != null) {
      data = toSend.serialize();
      type = toSend.getType();
      subtype = toSend.getSubtype();
      len = toSend.getLen();
    }

    String timeToLive = properties.getProperty("TimeToLive");
    int ttl = 0;

    if (timeToLive != null) {
      ttl = Integer.parseInt(timeToLive) * 1000;
    }
    log.debug("tpconnect sending data");
    session.getSender().send(receiver.getReplyTo(), (short) 0, 0, data,
        len, correlationId, flags | TPCONV, ttl, type, subtype);

    byte[] response = null;
    try {
      log.debug("tpconnect receiving data");
View Full Code Here

   * @throws ConnectionException
   *             If the response cannot be retrieved.
   */
  private Response receive(int cd, int flags) throws ConnectionException {
    log.debug("receive: " + cd);
    Receiver endpoint = temporaryQueues.get(cd);
    if (endpoint == null) {
      throw new ConnectionException(Connection.TPEBADDESC,
          "Session does not exist: " + cd);
    }
    Message message = endpoint.receive(flags);
    Buffer buffer = null;
    if (message.type != null && !message.type.equals("")) {
      buffer = tpalloc(message.type, message.subtype, message.len);
      buffer.deserialize(message.data);
    }
View Full Code Here

TOP

Related Classes of org.jboss.narayana.blacktie.jatmibroker.core.transport.Receiver

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.