示例#1
0
  @Override
  public org.eris.messaging.Sender createSender(String address, SenderMode mode)
      throws org.eris.messaging.TransportException, org.eris.messaging.SessionException {
    checkPreConditions();
    Sender sender;
    Source source = new Source();
    Target target = new Target();
    if (address == null || address.isEmpty() || address.equals("#")) {
      String temp = UUID.randomUUID().toString();
      sender = _session.sender(temp);
      target.setDynamic(true);
    } else {
      sender = _session.sender(address);
      target.setAddress(address);
    }
    sender.setTarget(target);
    sender.setSource(source);
    sender.setSenderSettleMode(
        mode == SenderMode.AT_MOST_ONCE ? SenderSettleMode.SETTLED : SenderSettleMode.UNSETTLED);
    sender.open();

    SenderImpl senderImpl = new SenderImpl(address, this, sender);
    senderImpl.setDynamicAddress(target.getDynamic());
    _senders.put(sender, senderImpl);
    sender.setContext(senderImpl);
    _conn.write();
    return senderImpl;
  }
示例#2
0
 @Override
 public void onConnectionInit(Event event) {
   Connection conn = event.getConnection();
   Session ssn = conn.session();
   Sender snd = ssn.sender("sender");
   conn.open();
   ssn.open();
   snd.open();
 }
示例#3
0
  @Override
  public org.eris.messaging.Receiver createReceiver(
      String address, ReceiverMode mode, CreditMode creditMode)
      throws org.eris.messaging.TransportException, org.eris.messaging.SessionException {
    checkPreConditions();
    Receiver receiver;
    Source source = new Source();
    Target target = new Target();
    if (address == null || address.isEmpty() || address.equals("#")) {
      String temp = UUID.randomUUID().toString();
      receiver = _session.receiver(temp);
      source.setDynamic(true);
    } else {
      receiver = _session.receiver(address);
      source.setAddress(address);
    }
    receiver.setSource(source);
    receiver.setTarget(target);
    switch (mode) {
      case AT_MOST_ONCE:
        receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
        receiver.setSenderSettleMode(SenderSettleMode.SETTLED);
        break;
      case AT_LEAST_ONCE:
        receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
        receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
        break;
      case EXACTLY_ONCE:
        receiver.setReceiverSettleMode(ReceiverSettleMode.SECOND);
        receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
        break;
    }
    receiver.open();

    ReceiverImpl receiverImpl = new ReceiverImpl(address, this, receiver, creditMode);
    receiverImpl.setDynamicAddress(source.getDynamic());
    _receivers.put(receiver, receiverImpl);
    receiver.setContext(receiverImpl);
    _conn.write();
    return receiverImpl;
  }
示例#4
0
 void checkPreConditions() throws org.eris.messaging.SessionException {
   if (_session.getLocalState() != EndpointState.ACTIVE) {
     throw new org.eris.messaging.SessionException("Session is closed");
   }
 }