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

The following examples show how to use org.apache.qpid.proton.amqp.transport.ReceiverSettleMode. 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: 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 #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: 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 #4
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 #5
Source File: TransferTypeTest.java    From qpid-proton-j with Apache License 2.0 6 votes vote down vote up
@Test
public void testSkipValue() {
    Transfer transfer = new Transfer();
    transfer.setHandle(UnsignedInteger.ONE);
    transfer.setDeliveryTag(new Binary(new byte[] {0, 1}));
    transfer.setMessageFormat(UnsignedInteger.ZERO);
    transfer.setDeliveryId(UnsignedInteger.valueOf(127));
    transfer.setAborted(false);
    transfer.setBatchable(true);
    transfer.setRcvSettleMode(ReceiverSettleMode.SECOND);

    encoder.writeObject(transfer);

    transfer.setHandle(UnsignedInteger.valueOf(2));

    encoder.writeObject(transfer);

    buffer.clear();

    TypeConstructor<?> type = decoder.readConstructor();
    assertEquals(Transfer.class, type.getTypeClass());
    type.skipValue();

    Transfer result = (Transfer) decoder.readObject();
    assertEquals(UnsignedInteger.valueOf(2), result.getHandle());
}
 
Example #6
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 #7
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 #8
Source File: TransferTypeTest.java    From qpid-proton-j with Apache License 2.0 6 votes vote down vote up
@Test
public void testEncodeDecodeTransfers() {
    Transfer transfer = new Transfer();
    transfer.setHandle(UnsignedInteger.ONE);
    transfer.setDeliveryTag(new Binary(new byte[] {0, 1}));
    transfer.setMessageFormat(UnsignedInteger.ZERO);
    transfer.setDeliveryId(UnsignedInteger.valueOf(127));
    transfer.setAborted(false);
    transfer.setBatchable(true);
    transfer.setRcvSettleMode(ReceiverSettleMode.SECOND);

    encoder.writeObject(transfer);
    buffer.clear();
    final Transfer outputValue = (Transfer) decoder.readObject();

    assertEquals(transfer.getHandle(), outputValue.getHandle());
    assertEquals(transfer.getMessageFormat(), outputValue.getMessageFormat());
    assertEquals(transfer.getDeliveryTag(), outputValue.getDeliveryTag());
    assertEquals(transfer.getDeliveryId(), outputValue.getDeliveryId());
    assertEquals(transfer.getAborted(), outputValue.getAborted());
    assertEquals(transfer.getBatchable(), outputValue.getBatchable());
    assertEquals(transfer.getRcvSettleMode(), outputValue.getRcvSettleMode());
}
 
Example #9
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 #10
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 #11
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 #12
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 #13
Source File: FrameWriterTest.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
private Transfer createTransfer() {
    Transfer transfer = new Transfer();
    transfer.setHandle(UnsignedInteger.ONE);
    transfer.setDeliveryTag(new Binary(new byte[] {0, 1}));
    transfer.setMessageFormat(UnsignedInteger.ZERO);
    transfer.setDeliveryId(UnsignedInteger.valueOf(127));
    transfer.setAborted(false);
    transfer.setBatchable(false);
    transfer.setRcvSettleMode(ReceiverSettleMode.SECOND);

    return transfer;
}
 
Example #14
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 #15
Source File: FastPathTransferType.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
private void writeElement(Transfer transfer, int index) {
    switch (index) {
        case 0:
            getEncoder().writeUnsignedInteger(transfer.getHandle());
            break;
        case 1:
            getEncoder().writeUnsignedInteger(transfer.getDeliveryId());
            break;
        case 2:
            getEncoder().writeBinary(transfer.getDeliveryTag());
            break;
        case 3:
            getEncoder().writeUnsignedInteger(transfer.getMessageFormat());
            break;
        case 4:
            getEncoder().writeBoolean(transfer.getSettled());
            break;
        case 5:
            getEncoder().writeBoolean(transfer.getMore());
            break;
        case 6:
            ReceiverSettleMode rcvSettleMode = transfer.getRcvSettleMode();
            getEncoder().writeObject(rcvSettleMode == null ? null : rcvSettleMode.getValue());
            break;
        case 7:
            getEncoder().writeObject(transfer.getState());
            break;
        case 8:
            getEncoder().writeBoolean(transfer.getResume());
            break;
        case 9:
            getEncoder().writeBoolean(transfer.getAborted());
            break;
        case 10:
            getEncoder().writeBoolean(transfer.getBatchable());
            break;
        default:
            throw new IllegalArgumentException("Unknown Transfer value index: " + index);
    }
}
 
Example #16
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 #17
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 #18
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 #19
Source File: AmqpSenderTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testReceiverSettlementModeSetToSecond() throws Exception {
   doTestReceiverSettlementModeForcedToFirst(ReceiverSettleMode.SECOND);
}
 
Example #20
Source File: AmqpReceiverTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testReceiverSettlementModeSetToSecond() throws Exception {
   doTestReceiverSettlementModeForcedToFirst(ReceiverSettleMode.SECOND);
}
 
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 testReceiverSettlementModeSetToFirst() throws Exception {
   doTestReceiverSettlementModeForcedToFirst(ReceiverSettleMode.FIRST);
}
 
Example #22
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 #23
Source File: AmqpReceiverTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 60000)
public void testReceiverSettlementModeSetToFirst() throws Exception {
   doTestReceiverSettlementModeForcedToFirst(ReceiverSettleMode.FIRST);
}
 
Example #24
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 #25
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 #26
Source File: TransferType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public Transfer newInstance(Object described)
{
    List l = (List) described;

    Transfer o = new Transfer();

    if(l.isEmpty())
    {
        throw new DecodeException("The handle field cannot be omitted");
    }

    switch(11 - l.size())
    {

        case 0:
            Boolean batchable = (Boolean) l.get(10);
            o.setBatchable(batchable == null ? false : batchable);
        case 1:
            Boolean aborted = (Boolean) l.get(9);
            o.setAborted(aborted == null ? false : aborted);
        case 2:
            Boolean resume = (Boolean) l.get(8);
            o.setResume(resume == null ? false : resume);
        case 3:
            o.setState( (DeliveryState) l.get( 7 ) );
        case 4:
            UnsignedByte receiverSettleMode = (UnsignedByte) l.get(6);
            o.setRcvSettleMode(receiverSettleMode == null ? null : ReceiverSettleMode.values()[receiverSettleMode.intValue()]);
        case 5:
            Boolean more = (Boolean) l.get(5);
            o.setMore(more == null ? false : more );
        case 6:
            o.setSettled( (Boolean) l.get( 4 ) );
        case 7:
            o.setMessageFormat( (UnsignedInteger) l.get( 3 ) );
        case 8:
            o.setDeliveryTag( (Binary) l.get( 2 ) );
        case 9:
            o.setDeliveryId( (UnsignedInteger) l.get( 1 ) );
        case 10:
            o.setHandle( (UnsignedInteger) l.get( 0 ) );
    }


    return o;
}
 
Example #27
Source File: FastPathTransferType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
private final Transfer readFields(DecoderImpl decoder, int count) {
    Transfer transfer = new Transfer();

    for (int index = 0; index < count; ++index) {
        switch (index) {
            case 0:
                transfer.setHandle(decoder.readUnsignedInteger(null));
                break;
            case 1:
                transfer.setDeliveryId(decoder.readUnsignedInteger(null));
                break;
            case 2:
                transfer.setDeliveryTag(decoder.readBinary(null));
                break;
            case 3:
                transfer.setMessageFormat(decoder.readUnsignedInteger(null));
                break;
            case 4:
                transfer.setSettled(decoder.readBoolean(null));
                break;
            case 5:
                transfer.setMore(decoder.readBoolean(false));
                break;
            case 6:
                UnsignedByte rcvSettleMode = decoder.readUnsignedByte();
                transfer.setRcvSettleMode(rcvSettleMode == null ? null : ReceiverSettleMode.values()[rcvSettleMode.intValue()]);
                break;
            case 7:
                transfer.setState((DeliveryState) decoder.readObject());
                break;
            case 8:
                transfer.setResume(decoder.readBoolean(false));
                break;
            case 9:
                transfer.setAborted(decoder.readBoolean(false));
                break;
            case 10:
                transfer.setBatchable(decoder.readBoolean(false));
                break;
            default:
                throw new IllegalStateException("To many entries in Transfer encoding");
        }
    }

    return transfer;
}
 
Example #28
Source File: LinkImpl.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
void setRemoteReceiverSettleMode(ReceiverSettleMode remoteReceiverSettleMode)
{
    _remoteReceiverSettleMode = remoteReceiverSettleMode;
}
 
Example #29
Source File: LinkImpl.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public ReceiverSettleMode getRemoteReceiverSettleMode()
{
    return _remoteReceiverSettleMode;
}
 
Example #30
Source File: LinkImpl.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public void setReceiverSettleMode(ReceiverSettleMode receiverSettleMode)
{
    _receiverSettleMode = receiverSettleMode;
}