org.apache.qpid.proton.amqp.transport.SenderSettleMode Java Examples

The following examples show how to use org.apache.qpid.proton.amqp.transport.SenderSettleMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtonLinkImpl.java    From vertx-proton with Apache License 2.0 6 votes vote down vote up
@Override
public T setQoS(ProtonQoS qos) {
  if (qos == null) {
    throw new IllegalArgumentException("Value must be specified");
  }
  switch (qos) {
  case AT_MOST_ONCE:
    link.setSenderSettleMode(SenderSettleMode.SETTLED);
    link.setReceiverSettleMode(ReceiverSettleMode.FIRST);
    break;
  case AT_LEAST_ONCE:
    link.setSenderSettleMode(SenderSettleMode.UNSETTLED);
    link.setReceiverSettleMode(ReceiverSettleMode.FIRST);
    break;
  }
  return self();
}
 
Example #2
Source File: AmqpSenderTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private void doTestReceiverSettlementModeForcedToFirst(ReceiverSettleMode modeToUse) throws Exception {
   AmqpClient client = createAmqpClient();
   AmqpConnection connection = addConnection(client.connect());
   AmqpSession session = connection.createSession();

   AmqpSender sender = session.createSender("queue://" + getTestName(), SenderSettleMode.UNSETTLED, modeToUse);

   Queue queueView = getProxyToQueue(getQueueName());
   assertNotNull(queueView);
   assertEquals(0, queueView.getMessageCount());

   assertEquals(ReceiverSettleMode.FIRST, sender.getEndpoint().getRemoteReceiverSettleMode());

   sender.close();

   connection.close();
}
 
Example #3
Source File: AmqpTransactionCoordinator.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected void doOpen() {
   Coordinator coordinator = new Coordinator();
   coordinator.setCapabilities(TxnCapability.LOCAL_TXN);
   Source source = new Source();

   String coordinatorName = "qpid-jms:coordinator:" + session.getConnection().getConnectionId();

   Sender sender = session.getEndpoint().sender(coordinatorName);
   sender.setSource(source);
   sender.setTarget(coordinator);
   sender.setSenderSettleMode(SenderSettleMode.UNSETTLED);
   sender.setReceiverSettleMode(ReceiverSettleMode.FIRST);

   setEndpoint(sender);

   super.doOpen();
}
 
Example #4
Source File: AmqpSession.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Create a sender instance using the given address
 *
 * @param address
 *        the address to which the sender will produce its messages.
 * @param senderMode
 *        controls the settlement mode used by the created Sender
 * @param receiverMode
 *        controls the desired settlement mode used by the remote Receiver
 * @param outcomes
 *        specifies the outcomes supported by the sender
 *
 * @return a newly created sender that is ready for use.
 *
 * @throws Exception if an error occurs while creating the sender.
 */
public AmqpSender createSender(final String address,
                               final SenderSettleMode senderMode,
                               ReceiverSettleMode receiverMode, final Symbol[] outcomes) throws Exception {
   checkClosed();

   final AmqpSender sender = new AmqpSender(AmqpSession.this, address, getNextSenderId(), senderMode, receiverMode, outcomes);
   final ClientFuture request = new ClientFuture();

   connection.getScheduler().execute(new Runnable() {

      @Override
      public void run() {
         checkClosed();
         sender.setStateInspector(getStateInspector());
         sender.open(request);
         pumpToProtonTransport(request);
      }
   });

   request.sync();

   return sender;
}
 
Example #5
Source File: AmqpReceiverTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private void doTestReceiverSettlementModeForcedToFirst(ReceiverSettleMode modeToUse) throws Exception {
   AmqpClient client = createAmqpClient();
   AmqpConnection connection = addConnection(client.connect());
   AmqpSession session = connection.createSession();

   AmqpReceiver receiver = session.createReceiver("queue://" + getTestName(), SenderSettleMode.MIXED, modeToUse);

   Queue queueView = getProxyToQueue(getQueueName());
   assertNotNull(queueView);
   assertEquals(0, queueView.getMessageCount());
   assertEquals(1, server.getTotalConsumerCount());

   assertEquals(ReceiverSettleMode.FIRST, receiver.getEndpoint().getRemoteReceiverSettleMode());

   receiver.close();
   connection.close();
}
 
Example #6
Source File: AmqpReceiverTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void doTestSenderSettlementModeIsHonored(SenderSettleMode settleMode) throws Exception {
   AmqpClient client = createAmqpClient();
   AmqpConnection connection = addConnection(client.connect());
   AmqpSession session = connection.createSession();

   AmqpReceiver receiver = session.createReceiver("queue://" + getTestName(), settleMode, ReceiverSettleMode.FIRST);

   Queue queueView = getProxyToQueue(getQueueName());
   assertNotNull(queueView);
   assertEquals(0, queueView.getMessageCount());
   assertEquals(1, server.getTotalConsumerCount());

   assertEquals(settleMode, receiver.getEndpoint().getRemoteSenderSettleMode());

   receiver.close();

   connection.close();
}
 
Example #7
Source File: AmqpSession.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Create a receiver instance using the given address
 *
 * @param address
 *        the address to which the receiver will subscribe for its messages.
 * @param senderMode
 *        controls the desired settlement mode used by the remote Sender
 * @param receiverMode
 *        controls the settlement mode used by the created Receiver
 *
 * @return a newly created receiver that is ready for use.
 *
 * @throws Exception if an error occurs while creating the receiver.
 */
public AmqpReceiver createReceiver(String address, SenderSettleMode senderMode, ReceiverSettleMode receiverMode) throws Exception {
   checkClosed();

   final ClientFuture request = new ClientFuture();
   final AmqpReceiver receiver = new AmqpReceiver(AmqpSession.this, address, getNextReceiverId(), senderMode, receiverMode);

   connection.getScheduler().execute(new Runnable() {

      @Override
      public void run() {
         checkClosed();
         receiver.setStateInspector(getStateInspector());
         receiver.open(request);
         pumpToProtonTransport(request);
      }
   });

   request.sync();

   return receiver;
}
 
Example #8
Source File: AmqpSender.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new sender instance.
 *
 * @param session
 *        The parent session that created the session.
 * @param address
 *        The address that this sender produces to.
 * @param senderId
 *        The unique ID assigned to this sender.
 * @param senderMode
 *        The {@link SenderSettleMode} to use on open.
 * @param receiverMode
 *        The {@link ReceiverSettleMode} to use on open.
 * @param outcomes
 *        The outcomes to use on open
 */
public AmqpSender(AmqpSession session,
                  String address,
                  String senderId,
                  SenderSettleMode senderMode,
                  ReceiverSettleMode receiverMode,
                  Symbol[] outcomes) {

   if (address != null && address.isEmpty()) {
      throw new IllegalArgumentException("Address cannot be empty.");
   }

   this.session = session;
   this.address = address;
   this.senderId = senderId;
   this.userSpecifiedTarget = null;
   this.userSpecifiedSenderSettlementMode = senderMode;
   this.userSpecifiedReceiverSettlementMode = receiverMode;
   this.outcomes = outcomes;
}
 
Example #9
Source File: AmqpTransactionCoordinatorBuilder.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
@Override
protected Sender createEndpoint(JmsSessionInfo resourceInfo) {
    Coordinator coordinator = new Coordinator();
    coordinator.setCapabilities(TxnCapability.LOCAL_TXN);

    Symbol[] outcomes = new Symbol[]{ Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL, Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL };

    Source source = new Source();
    source.setOutcomes(outcomes);

    String coordinatorName = "qpid-jms:coordinator:" + resourceInfo.getId().toString();

    Sender sender = getParent().getSession().getEndpoint().sender(coordinatorName);
    sender.setSource(source);
    sender.setTarget(coordinator);
    sender.setSenderSettleMode(SenderSettleMode.UNSETTLED);
    sender.setReceiverSettleMode(ReceiverSettleMode.FIRST);

    return sender;
}
 
Example #10
Source File: AttachType.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
public int size()
{
    return _attach.getProperties() != null
              ? 14
              : _attach.getDesiredCapabilities() != null
              ? 13
              : _attach.getOfferedCapabilities() != null
              ? 12
              : _attach.getMaxMessageSize() != null
              ? 11
              : _attach.getInitialDeliveryCount() != null
              ? 10
              : _attach.getIncompleteUnsettled()
              ? 9
              : _attach.getUnsettled() != null
              ? 8
              : _attach.getTarget() != null
              ? 7
              : _attach.getSource() != null
              ? 6
              : (_attach.getRcvSettleMode() != null && !_attach.getRcvSettleMode().equals(ReceiverSettleMode.FIRST))
              ? 5
              : (_attach.getSndSettleMode() != null && !_attach.getSndSettleMode().equals(SenderSettleMode.MIXED))
              ? 4
              : 3;

}
 
Example #11
Source File: ProtonLinkImpl.java    From vertx-proton with Apache License 2.0 5 votes vote down vote up
@Override
public ProtonQoS getRemoteQoS() {
  if (link.getRemoteSenderSettleMode() == SenderSettleMode.SETTLED) {
    return ProtonQoS.AT_MOST_ONCE;
  }

  return ProtonQoS.AT_LEAST_ONCE;
}
 
Example #12
Source File: ProtonLinkImpl.java    From vertx-proton with Apache License 2.0 5 votes vote down vote up
@Override
public ProtonQoS getQoS() {
  if (link.getSenderSettleMode() == SenderSettleMode.SETTLED) {
    return ProtonQoS.AT_MOST_ONCE;
  }

  return ProtonQoS.AT_LEAST_ONCE;
}
 
Example #13
Source File: ProtonSenderImpl.java    From vertx-proton with Apache License 2.0 5 votes vote down vote up
@Override
public ProtonDelivery send(byte[] tag, Message message, Handler<ProtonDelivery> onUpdated) {
  if (anonymousSender && message.getAddress() == null) {
    throw new IllegalArgumentException("Message must have an address when using anonymous sender.");
  }
  // TODO: prevent odd combination of onRecieved callback + SenderSettleMode.SETTLED, or just allow it?

  Delivery delivery = sender().delivery(tag); // start a new delivery..
  ProtonWritableBufferImpl buffer = new ProtonWritableBufferImpl();
  MessageImpl msg = (MessageImpl) message;
  msg.encode(buffer);
  ReadableBuffer encoded = new ProtonReadableBufferImpl(buffer.getBuffer());

  sender().sendNoCopy(encoded);

  if (link.getSenderSettleMode() == SenderSettleMode.SETTLED) {
    delivery.settle();
  }
  sender().advance(); // ends the delivery.

  ProtonDeliveryImpl protonDeliveryImpl = new ProtonDeliveryImpl(delivery);
  if (onUpdated != null) {
    protonDeliveryImpl.setAutoSettle(autoSettle);
    protonDeliveryImpl.handler(onUpdated);
  } else {
    protonDeliveryImpl.setAutoSettle(true);
  }

  getSession().getConnectionImpl().flush();

  return protonDeliveryImpl;
}
 
Example #14
Source File: AmqpConnectionSession.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected Receiver createEndpoint(JmsSessionInfo resourceInfo) {
    Receiver receiver = getParent().getEndpoint().receiver(linkName);
    receiver.setTarget(new Target());
    receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
    receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);

    if (!hasClientID) {
      // We are trying to unsubscribe a 'global' shared subs using a 'null source lookup', add link
      // desired capabilities as hints to the peer to consider this when trying to attach the link.
      receiver.setDesiredCapabilities(new Symbol[] { AmqpSupport.SHARED, AmqpSupport.GLOBAL });
    }

    return receiver;
}
 
Example #15
Source File: AmqpTemporaryDestinationBuilder.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected Sender createEndpoint(JmsTemporaryDestination resourceInfo) {
    // Form a link name, use the local generated name with a prefix to aid debugging
    String localDestinationName = resourceInfo.getAddress();
    String senderLinkName = null;
    if (resourceInfo.isQueue()) {
        senderLinkName = "qpid-jms:" + TEMP_QUEUE_CREATOR + localDestinationName;
    } else {
        senderLinkName = "qpid-jms:" + TEMP_TOPIC_CREATOR + localDestinationName;
    }

    // Just use a bare Source, this is a producer which
    // wont send anything and the link name is unique.
    Source source = new Source();

    Target target = new Target();
    target.setDynamic(true);
    target.setDurable(TerminusDurability.NONE);
    target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);

    // Set the dynamic node lifetime-policy
    Map<Symbol, Object> dynamicNodeProperties = new HashMap<Symbol, Object>();
    dynamicNodeProperties.put(DYNAMIC_NODE_LIFETIME_POLICY, DeleteOnClose.getInstance());
    target.setDynamicNodeProperties(dynamicNodeProperties);

    // Set the capability to indicate the node type being created
    if (resourceInfo.isQueue()) {
        target.setCapabilities(AmqpDestinationHelper.TEMP_QUEUE_CAPABILITY);
    } else {
        target.setCapabilities(AmqpDestinationHelper.TEMP_TOPIC_CAPABILITY);
    }

    Sender sender = getParent().getEndpoint().sender(senderLinkName);
    sender.setSource(source);
    sender.setTarget(target);
    sender.setSenderSettleMode(SenderSettleMode.UNSETTLED);
    sender.setReceiverSettleMode(ReceiverSettleMode.FIRST);

    return sender;
}
 
Example #16
Source File: AmqpProducerBuilder.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected Sender createEndpoint(JmsProducerInfo resourceInfo) {
    JmsDestination destination = resourceInfo.getDestination();
    AmqpConnection connection = getParent().getConnection();

    String targetAddress = AmqpDestinationHelper.getDestinationAddress(destination, connection);

    Symbol[] outcomes = new Symbol[]{ Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL, Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL };
    String sourceAddress = resourceInfo.getId().toString();
    Source source = new Source();
    source.setAddress(sourceAddress);
    source.setOutcomes(outcomes);
    // TODO: default outcome. Accepted normally, Rejected for transaction controller?

    Target target = new Target();
    target.setAddress(targetAddress);
    Symbol typeCapability =  AmqpDestinationHelper.toTypeCapability(destination);
    if (typeCapability != null) {
        target.setCapabilities(typeCapability);
    }

    String senderName = "qpid-jms:sender:" + sourceAddress + ":" + targetAddress;

    Sender sender = getParent().getEndpoint().sender(senderName);
    sender.setSource(source);
    sender.setTarget(target);
    if (resourceInfo.isPresettle()) {
        sender.setSenderSettleMode(SenderSettleMode.SETTLED);
    } else {
        sender.setSenderSettleMode(SenderSettleMode.UNSETTLED);
    }
    sender.setReceiverSettleMode(ReceiverSettleMode.FIRST);

    if (!connection.getProperties().isDelayedDeliverySupported()) {
        validateDelayedDeliveryLinkCapability = true;
        sender.setDesiredCapabilities(new Symbol[] { AmqpSupport.DELAYED_DELIVERY });
    }

    return sender;
}
 
Example #17
Source File: AmqpSenderTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testSenderSettlementModeMixedIsHonored() throws Exception {
   doTestSenderSettlementModeIsHonored(SenderSettleMode.MIXED);
}
 
Example #18
Source File: AmqpFixedProducer.java    From qpid-jms with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isPresettle() {
    return getEndpoint().getSenderSettleMode() == SenderSettleMode.SETTLED;
}
 
Example #19
Source File: AmqpConsumerBuilder.java    From qpid-jms with Apache License 2.0 4 votes vote down vote up
@Override
protected Receiver createEndpoint(JmsConsumerInfo resourceInfo) {
    JmsDestination destination = resourceInfo.getDestination();
    String address = AmqpDestinationHelper.getDestinationAddress(destination, getParent().getConnection());

    Source source = new Source();
    source.setAddress(address);
    Target target = new Target();

    configureSource(source);

    String receiverLinkName = null;
    String subscriptionName = resourceInfo.getSubscriptionName();
    if (subscriptionName != null && !subscriptionName.isEmpty()) {
        AmqpConnection connection = getParent().getConnection();

        if (resourceInfo.isShared() && !connection.getProperties().isSharedSubsSupported()) {
            validateSharedSubsLinkCapability = true;
        }

        AmqpSubscriptionTracker subTracker = connection.getSubTracker();

        // Validate subscriber type allowed given existing active subscriber types.
        if (resourceInfo.isShared() && resourceInfo.isDurable()) {
            if(subTracker.isActiveExclusiveDurableSub(subscriptionName)) {
                // Don't allow shared sub if there is already an active exclusive durable sub
                throw new JMSRuntimeException("A non-shared durable subscription is already active with name '" + subscriptionName + "'");
            }
        } else if (!resourceInfo.isShared() && resourceInfo.isDurable()) {
            if (subTracker.isActiveExclusiveDurableSub(subscriptionName)) {
                // Exclusive durable sub is already active
                throw new JMSRuntimeException("A non-shared durable subscription is already active with name '" + subscriptionName + "'");
            } else if (subTracker.isActiveSharedDurableSub(subscriptionName)) {
                // Don't allow exclusive durable sub if there is already an active shared durable sub
                throw new JMSRuntimeException("A shared durable subscription is already active with name '" + subscriptionName + "'");
            }
        }

        // Get the link name for the subscription. Throws if certain further validations fail.
        receiverLinkName = subTracker.reserveNextSubscriptionLinkName(subscriptionName, resourceInfo);
    }

    if (receiverLinkName == null) {
        receiverLinkName = "qpid-jms:receiver:" + resourceInfo.getId() + ":" + address;
    }

    Receiver receiver = getParent().getEndpoint().receiver(receiverLinkName);
    receiver.setSource(source);
    receiver.setTarget(target);
    if (resourceInfo.isBrowser() || resourceInfo.isPresettle()) {
        receiver.setSenderSettleMode(SenderSettleMode.SETTLED);
    } else {
        receiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);
    }
    receiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);

    if (validateSharedSubsLinkCapability) {
        receiver.setDesiredCapabilities(new Symbol[] { AmqpSupport.SHARED_SUBS });
    }

    return receiver;
}
 
Example #20
Source File: AmqpSenderTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public void doTestSenderSettlementModeIsHonored(SenderSettleMode settleMode) throws Exception {
   AmqpClient client = createAmqpClient();

   AmqpConnection connection = addConnection(client.connect());
   AmqpSession session = connection.createSession();

   AmqpSender sender = session.createSender("queue://" + getTestName(), settleMode, ReceiverSettleMode.FIRST);

   Queue queueView = getProxyToQueue(getQueueName());
   assertNotNull(queueView);
   assertEquals(0, queueView.getMessageCount());

   assertEquals(settleMode, sender.getEndpoint().getRemoteSenderSettleMode());

   AmqpMessage message = new AmqpMessage();
   message.setText("Test-Message");
   sender.send(message);

   sender.close();

   connection.close();
}
 
Example #21
Source File: AmqpSenderTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testSenderSettlementModeUnsettledIsHonored() throws Exception {
   doTestSenderSettlementModeIsHonored(SenderSettleMode.UNSETTLED);
}
 
Example #22
Source File: AmqpSenderTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testSenderSettlementModeSettledIsHonored() throws Exception {
   doTestSenderSettlementModeIsHonored(SenderSettleMode.SETTLED);
}
 
Example #23
Source File: AmqpReceiverTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testSenderSettlementModeMixedIsHonored() throws Exception {
   doTestSenderSettlementModeIsHonored(SenderSettleMode.MIXED);
}
 
Example #24
Source File: AmqpReceiverTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testSenderSettlementModeUnsettledIsHonored() throws Exception {
   doTestSenderSettlementModeIsHonored(SenderSettleMode.UNSETTLED);
}
 
Example #25
Source File: AmqpReceiverTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testSenderSettlementModeSettledIsHonored() throws Exception {
   doTestSenderSettlementModeIsHonored(SenderSettleMode.SETTLED);
}
 
Example #26
Source File: LinkTest.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Test
public void testMaxMessageSizeValue() throws Exception
{
    LOGGER.fine(bold("======== About to create transports"));

    Transport clientTransport = Proton.transport();
    getClient().setTransport(clientTransport);
    ProtocolTracerEnabler.setProtocolTracer(clientTransport, TestLoggingHelper.CLIENT_PREFIX);

    Transport serverTransport = Proton.transport();
    getServer().setTransport(serverTransport);
    ProtocolTracerEnabler.setProtocolTracer(serverTransport, "            " + TestLoggingHelper.SERVER_PREFIX);

    doOutputInputCycle();

    Connection clientConnection = Proton.connection();
    getClient().setConnection(clientConnection);
    clientTransport.bind(clientConnection);

    Connection serverConnection = Proton.connection();
    getServer().setConnection(serverConnection);
    serverTransport.bind(serverConnection);

    LOGGER.fine(bold("======== About to open connections"));
    clientConnection.open();
    serverConnection.open();

    doOutputInputCycle();

    LOGGER.fine(bold("======== About to open sessions"));
    Session clientSession = clientConnection.session();
    getClient().setSession(clientSession);
    clientSession.open();

    pumpClientToServer();

    Session serverSession = serverConnection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
    getServer().setSession(serverSession);

    serverSession.open();

    pumpServerToClient();

    LOGGER.fine(bold("======== About to create receiver"));

    Source clientSource = new Source();
    getClient().setSource(clientSource);
    clientSource.setAddress(_sourceAddress);

    Target clientTarget = new Target();
    getClient().setTarget(clientTarget);
    clientTarget.setAddress(null);

    Receiver clientReceiver = clientSession.receiver("link1");
    getClient().setReceiver(clientReceiver);
    clientReceiver.setTarget(clientTarget);
    clientReceiver.setSource(clientSource);

    clientReceiver.setReceiverSettleMode(ReceiverSettleMode.FIRST);
    clientReceiver.setSenderSettleMode(SenderSettleMode.UNSETTLED);

    // Set the local link max-message-size
    assertNull("Expected no value to be set", clientReceiver.getMaxMessageSize());
    clientReceiver.setMaxMessageSize(CLIENT_MAX_MSG_SIZE);
    assertEquals("Expected value to be set", CLIENT_MAX_MSG_SIZE, clientReceiver.getMaxMessageSize());

    clientReceiver.open();
    pumpClientToServer();

    LOGGER.fine(bold("======== About to set up implicitly created sender"));

    Sender serverSender = (Sender) getServer().getConnection().linkHead(of(UNINITIALIZED), of(ACTIVE));
    getServer().setSender(serverSender);

    serverSender.setReceiverSettleMode(serverSender.getRemoteReceiverSettleMode());
    serverSender.setSenderSettleMode(serverSender.getRemoteSenderSettleMode());

    org.apache.qpid.proton.amqp.transport.Source serverRemoteSource = serverSender.getRemoteSource();
    serverSender.setSource(serverRemoteSource);

    assertEquals("Expected value to be set", CLIENT_MAX_MSG_SIZE, serverSender.getRemoteMaxMessageSize());

    // Set the local link max-message-size
    assertNull("Expected no value to be set", serverSender.getMaxMessageSize());
    serverSender.setMaxMessageSize(SERVER_MAX_MSG_SIZE);
    assertEquals("Expected value to be set", SERVER_MAX_MSG_SIZE, serverSender.getMaxMessageSize());

    serverSender.open();

    assertNull("Expected no value to be present yet", clientReceiver.getRemoteMaxMessageSize());

    pumpServerToClient();

    assertEquals("Expected value to be set", SERVER_MAX_MSG_SIZE, clientReceiver.getRemoteMaxMessageSize());
}
 
Example #27
Source File: AttachType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public Attach newInstance(Object described)
{
    List l = (List) described;

    Attach o = new Attach();

    if(l.size() <= 2)
    {
        throw new DecodeException("The role field cannot be omitted");
    }

    switch(14 - l.size())
    {

        case 0:
            o.setProperties( (Map) l.get( 13 ) );
        case 1:
            Object val1 = l.get( 12 );
            if( val1 == null || val1.getClass().isArray() )
            {
                o.setDesiredCapabilities( (Symbol[]) val1 );
            }
            else
            {
                o.setDesiredCapabilities( (Symbol) val1 );
            }
        case 2:
            Object val2 = l.get( 11 );
            if( val2 == null || val2.getClass().isArray() )
            {
                o.setOfferedCapabilities( (Symbol[]) val2 );
            }
            else
            {
                o.setOfferedCapabilities( (Symbol) val2 );
            }
        case 3:
            o.setMaxMessageSize( (UnsignedLong) l.get( 10 ) );
        case 4:
            o.setInitialDeliveryCount( (UnsignedInteger) l.get( 9 ) );
        case 5:
            Boolean incompleteUnsettled = (Boolean) l.get(8);
            o.setIncompleteUnsettled(incompleteUnsettled == null ? false : incompleteUnsettled);
        case 6:
            o.setUnsettled( (Map) l.get( 7 ) );
        case 7:
            o.setTarget( (Target) l.get( 6 ) );
        case 8:
            o.setSource( (Source) l.get( 5 ) );
        case 9:
            UnsignedByte rcvSettleMode = (UnsignedByte) l.get(4);
            o.setRcvSettleMode(rcvSettleMode == null ? ReceiverSettleMode.FIRST : ReceiverSettleMode.values()[rcvSettleMode.intValue()]);
        case 10:
            UnsignedByte sndSettleMode = (UnsignedByte) l.get(3);
            o.setSndSettleMode(sndSettleMode == null ? SenderSettleMode.MIXED : SenderSettleMode.values()[sndSettleMode.intValue()]);
        case 11:
            o.setRole( Boolean.TRUE.equals( l.get( 2 ) ) ? Role.RECEIVER : Role.SENDER);
        case 12:
            o.setHandle( (UnsignedInteger) l.get( 1 ) );
        case 13:
            o.setName( (String) l.get( 0 ) );
    }


    return o;
}
 
Example #28
Source File: LinkImpl.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public void setRemoteSenderSettleMode(SenderSettleMode remoteSenderSettleMode)
{
    _remoteSenderSettleMode = remoteSenderSettleMode;
}
 
Example #29
Source File: LinkImpl.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public SenderSettleMode getRemoteSenderSettleMode()
{
    return _remoteSenderSettleMode;
}
 
Example #30
Source File: LinkImpl.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public void setSenderSettleMode(SenderSettleMode senderSettleMode)
{
    _senderSettleMode = senderSettleMode;
}