Package org.jboss.blacktie.jatmibroker.xatmi

Examples of org.jboss.blacktie.jatmibroker.xatmi.ConnectionException


  public void send(Object replyTo, short rval, int rcode, byte[] data,
      int len, int correlationId, int flags, int ttl, String type,
      String subtype) throws ConnectionException {
    if (closed) {
      throw new ConnectionException(Connection.TPEPROTO, "Sender closed");
    }

    if (data == null) {
      data = new byte[1];
      len = 1;
    }
    if (len < 1) {
      throw new ConnectionException(Connection.TPEINVAL,
          "Length of buffer must be greater than 0");
    }

    log.debug("Sender sending: " + name);
    try {
      BytesMessage message = session.createBytesMessage();
      String ior = JtsTransactionImple.getTransactionIOR();

      message.setStringProperty("messagecontrol", ior);
      log.debug("Sender sending IOR: " + ior);
      if (replyTo != null) {
        message.setStringProperty("messagereplyto", (String) replyTo);
      }
      message.setStringProperty("servicename", name);
      message.setStringProperty("messagecorrelationId",
          String.valueOf(correlationId));
      message.setStringProperty("messageflags", String.valueOf(flags));
      message.setStringProperty("messagerval", String.valueOf(rval));
      message.setStringProperty("messagercode", String.valueOf(rcode));
      message.setStringProperty("messagetype", type == null ? "" : type);
      message.setStringProperty("messagesubtype", subtype == null ? ""
          : subtype);

      byte[] toSend = new byte[len + pad];
      if (data != null) {
        int min = Math.min(toSend.length, data.length);
        System.arraycopy(data, 0, toSend, 0, min);
      }
      message.writeBytes(toSend, 0, toSend.length);
      if (ttl > 0) {
        int deliveryMode = message.getJMSDeliveryMode();
        int priority = message.getJMSPriority();

        log.debug("send message with time-to-live " + ttl);
        sender.send(message, deliveryMode, priority, ttl);
      } else {
        sender.send(message);
      }
      log.debug("sent message");
    } catch (Throwable e) {
      throw new ConnectionException(Connection.TPESYSTEM,
          "Could not send the message: " + e.getMessage(), e);
    }
  }
View Full Code Here


    }
  }

  public void close() throws ConnectionException {
    if (closed) {
      throw new ConnectionException(Connection.TPEPROTO,
          "Sender already closed");
    }
    try {
      log.debug("Sender closing: " + name);
      sender.close();
      sender = null;
      closed = true;
      log.debug("Sender closed: " + name);
    } catch (Throwable t) {
      throw new ConnectionException(Connection.TPESYSTEM,
          "Could not send the message", t);
    }
  }
View Full Code Here

      int len, int correlationId, int flags, int ttl, String type,
      String subtype) throws ConnectionException {
    log.debug("Sending the message");
    if (closed) {
      log.error("Sender closed");
      throw new ConnectionException(Connection.TPEPROTO, "Sender closed");
    }
    if (data == null) {
      data = new byte[1];
      len = 1;
    }
    String toReplyTo = (String) replyTo;
    if (toReplyTo == null) {
      log.trace("Reply to set as null");
      toReplyTo = "";
    }
    if (type == null) {
      log.trace("Type set as null");
      type = "";
    }
    if (subtype == null) {
      log.trace("Subtype set as null");
      subtype = "";
    }
    if (len < 1) {
      log.error("Length of buffer must be greater than 0");
      throw new ConnectionException(Connection.TPEINVAL,
          "Length of buffer must be greater than 0");
    }
    byte[] toSend = new byte[len + pad];
    if (data != null) {
      int min = Math.min(toSend.length, data.length);
View Full Code Here

  }

  public void close() throws ConnectionException {
    log.debug("Close called");
    if (closed) {
      throw new ConnectionException(Connection.TPEPROTO,
          "Sender already closed");
    }
    closed = true;
    log.debug("Sender closed: " + name);
  }
View Full Code Here

    log.debug("Close called: " + this);
    if (!closed) {
      try {
        session.close();
      } catch (JMSException e) {
        throw new ConnectionException(
            org.jboss.blacktie.jatmibroker.xatmi.Connection.TPESYSTEM,
            "Could not close the session", e);
      }
      transportFactoryImpl.removeTransport(this);
      closed = true;
View Full Code Here

  }

  public Sender getSender(String serviceName, boolean conversational)
      throws ConnectionException {
    if (closed) {
      throw new ConnectionException(Connection.TPEPROTO, "Already closed");
    }
    log.debug("Get sender: " + serviceName);
    try {
      Destination destination = jmsManagement.lookup(serviceName,
          conversational);
      log.trace("Resolved destination");
      return new JMSSenderImpl(orbManagement, session, destination);
    } catch (NameNotFoundException e) {
      throw new ConnectionException(
          org.jboss.blacktie.jatmibroker.xatmi.Connection.TPENOENT,
          "Could not resolve destination: " + serviceName, e);
    } catch (Throwable t) {
      throw new ConnectionException(
          org.jboss.blacktie.jatmibroker.xatmi.Connection.TPESYSTEM,
          "Could not create a service sender: " + t.getMessage(), t);
    }
  }
View Full Code Here

    }
  }

  public Sender createSender(Object destination) throws ConnectionException {
    if (closed) {
      throw new ConnectionException(Connection.TPEPROTO, "Already closed");
    }
    String callback_ior = (String) destination;
    log.debug("Creating a sender for: " + callback_ior);
    org.omg.CORBA.Object serviceFactoryObject = orbManagement.getOrb()
        .string_to_object(callback_ior);
View Full Code Here

  }

  public Receiver getReceiver(String serviceName, boolean conversational)
      throws ConnectionException {
    if (closed) {
      throw new ConnectionException(Connection.TPEPROTO, "Already closed");
    }
    log.debug("Creating a receiver: " + serviceName);
    try {
      Destination destination = jmsManagement.lookup(serviceName,
          conversational);
      log.debug("Resolved destination");
      return new JMSReceiverImpl(session, destination, properties);
    } catch (NameNotFoundException e) {
      throw new ConnectionException(
          org.jboss.blacktie.jatmibroker.xatmi.Connection.TPENOENT,
          "Could not resolve destination: " + serviceName, e);
    } catch (Throwable t) {
      throw new ConnectionException(
          org.jboss.blacktie.jatmibroker.xatmi.Connection.TPESYSTEM,
          "Could not create the receiver on: " + serviceName, t);
    }

  }
View Full Code Here

  }

  public Receiver createReceiver(int cd, ResponseMonitor responseMonitor)
      throws ConnectionException {
    if (closed) {
      throw new ConnectionException(Connection.TPEPROTO, "Already closed");
    }
    log.debug("Creating a receiver");
    return new CorbaReceiverImpl(orbManagement, properties, cd,
        responseMonitor);
  }
View Full Code Here

  }

  public Receiver createReceiver(EventListener eventListener)
      throws ConnectionException {
    if (closed) {
      throw new ConnectionException(Connection.TPEPROTO, "Already closed");
    }
    log.debug("Creating a receiver with event listener");
    return new CorbaReceiverImpl(eventListener, orbManagement, properties);
  }
View Full Code Here

TOP

Related Classes of org.jboss.blacktie.jatmibroker.xatmi.ConnectionException

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.