当前位置: 首页>>代码示例>>Java>>正文


Java DeliveryState类代码示例

本文整理汇总了Java中org.apache.qpid.proton.amqp.transport.DeliveryState的典型用法代码示例。如果您正苦于以下问题:Java DeliveryState类的具体用法?Java DeliveryState怎么用?Java DeliveryState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DeliveryState类属于org.apache.qpid.proton.amqp.transport包,在下文中一共展示了DeliveryState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHandleMessageRejectsMalformedMessage

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
/**
 * Verifies that the endpoint rejects malformed request messages.
 */
@Test
public void testHandleMessageRejectsMalformedMessage() {

    Message msg = ProtonHelper.message();
    ProtonConnection con = mock(ProtonConnection.class);
    ProtonDelivery delivery = mock(ProtonDelivery.class);
    RequestResponseEndpoint<ServiceConfigProperties> endpoint = getEndpoint(false);

    // WHEN a malformed message is received
    endpoint.handleMessage(con, receiver, resource, delivery, msg);

    // THEN the link is closed and the message is rejected
    ArgumentCaptor<DeliveryState> deliveryState = ArgumentCaptor.forClass(DeliveryState.class);
    verify(delivery).disposition(deliveryState.capture(), booleanThat(is(Boolean.TRUE)));
    assertThat(deliveryState.getValue(), instanceOf(Rejected.class));
    verify(receiver, never()).close();
}
 
开发者ID:eclipse,项目名称:hono,代码行数:21,代码来源:RequestResponseEndpointTest.java

示例2: testHandleMessageRejectsUnauthorizedRequests

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
/**
 * Verifies that the endpoint rejects request messages for operations the client
 * is not authorized to invoke.
 */
@Test
public void testHandleMessageRejectsUnauthorizedRequests() {

    Message msg = ProtonHelper.message();
    msg.setSubject("unauthorized");
    ProtonConnection con = mock(ProtonConnection.class);
    ProtonDelivery delivery = mock(ProtonDelivery.class);
    AuthorizationService authService = mock(AuthorizationService.class);
    when(authService.isAuthorized(any(HonoUser.class), any(ResourceIdentifier.class), anyString())).thenReturn(Future.succeededFuture(Boolean.FALSE));
    Future<Void> processingTracker = Future.future();
    RequestResponseEndpoint<ServiceConfigProperties> endpoint = getEndpoint(true, processingTracker);
    endpoint.setAuthorizationService(authService);

    // WHEN a request for an operation is received that the client is not authorized to invoke
    endpoint.handleMessage(con, receiver, resource, delivery, msg);

    // THEN the the message is rejected
    ArgumentCaptor<DeliveryState> deliveryState = ArgumentCaptor.forClass(DeliveryState.class);
    verify(delivery).disposition(deliveryState.capture(), booleanThat(is(Boolean.TRUE)));
    assertThat(deliveryState.getValue(), instanceOf(Rejected.class));
    verify(receiver, never()).close();
    verify(authService).isAuthorized(Constants.PRINCIPAL_ANONYMOUS, resource, "unauthorized");
    assertFalse(processingTracker.isComplete());
}
 
开发者ID:eclipse,项目名称:hono,代码行数:29,代码来源:RequestResponseEndpointTest.java

示例3: testHandleMessageProcessesAuthorizedRequests

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
/**
 * Verifies that the endpoint processes request messages for operations the client
 * is authorized to invoke.
 */
@Test
public void testHandleMessageProcessesAuthorizedRequests() {

    Message msg = ProtonHelper.message();
    msg.setSubject("get");
    ProtonConnection con = mock(ProtonConnection.class);
    ProtonDelivery delivery = mock(ProtonDelivery.class);
    AuthorizationService authService = mock(AuthorizationService.class);
    when(authService.isAuthorized(any(HonoUser.class), any(ResourceIdentifier.class), anyString())).thenReturn(Future.succeededFuture(Boolean.TRUE));

    Future<Void> processingTracker = Future.future();
    RequestResponseEndpoint<ServiceConfigProperties> endpoint = getEndpoint(true, processingTracker);
    endpoint.setAuthorizationService(authService);

    // WHEN a request for an operation is received that the client is authorized to invoke
    endpoint.handleMessage(con, receiver, resource, delivery, msg);

    // THEN then the message gets processed
    ArgumentCaptor<DeliveryState> deliveryState = ArgumentCaptor.forClass(DeliveryState.class);
    verify(delivery).disposition(deliveryState.capture(), booleanThat(is(Boolean.TRUE)));
    assertThat(deliveryState.getValue(), instanceOf(Accepted.class));
    verify(receiver, never()).close();
    verify(authService).isAuthorized(Constants.PRINCIPAL_ANONYMOUS, resource, "get");
    assertTrue(processingTracker.isComplete());
}
 
开发者ID:eclipse,项目名称:hono,代码行数:30,代码来源:RequestResponseEndpointTest.java

示例4: disposition

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
void disposition(long sequence, DeliveryState state, int... flags) {
  int flag = flags.length == 1 ? flags[0] : 0;
  boolean cumilative = (flag & CUMULATIVE) != 0;
  boolean settle = (flag & SETTLE) != 0;

  long count = cumilative ? _lastDispositionMark.get() : sequence;
  long end = sequence;

  while (count <= end) {
    Delivery d = _unsettled.get(count);
    if (d != null) {
      d.disposition(state);
    }
    count++;
  }
  _lastDispositionMark.set(end);
  if (settle) {
    settle(sequence, cumilative, false);
  }
  _conn.write();
}
 
开发者ID:vert-x3,项目名称:vertx-amqp-service,代码行数:22,代码来源:SessionImpl.java

示例5: disposition

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
void disposition(InboundMessage msg, DeliveryState state, int... flags) throws NetworkException
{
    int flag = flags.length == 1 ? flags[0] : 0;
    boolean cumilative = (flag & CUMULATIVE) != 0;
    boolean settle = (flag & SETTLE) != 0;

    long count = cumilative ? _lastDispositionMark.get() : msg.getSequence();
    long end = msg.getSequence();

    while (count <= end)
    {
        Delivery d = _unsettled.get(count);
        if (d != null)
        {
            d.disposition(state);
        }
        count++;
    }
    _lastDispositionMark.set(end);
    if (settle)
    {
        settle(msg, cumilative, false);
    }
    _conn.write();
}
 
开发者ID:rajith77,项目名称:splash,代码行数:26,代码来源:SessionImpl.java

示例6: processTransportWorkReceiver

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
private boolean processTransportWorkReceiver(DeliveryImpl delivery,
                                             ReceiverImpl rcv)
{
    TransportDelivery tpDelivery = delivery.getTransportDelivery();
    SessionImpl session = rcv.getSession();
    TransportSession tpSession = session.getTransportSession();

    if (tpSession.isLocalChannelSet())
    {
        boolean settled = delivery.isSettled();
        DeliveryState localState = delivery.getLocalState();

        Disposition disposition = new Disposition();
        disposition.setFirst(tpDelivery.getDeliveryId());
        disposition.setLast(tpDelivery.getDeliveryId());
        disposition.setRole(Role.RECEIVER);
        disposition.setSettled(settled);
        disposition.setState(localState);

        if(localState == null && settled) {
            disposition.setState(delivery.getDefaultDeliveryState());
        }

        writeFrame(tpSession.getLocalChannel(), disposition, null, null);
        if (settled)
        {
            tpDelivery.settled();
        }
        return true;
    }

    return false;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:34,代码来源:TransportImpl.java

示例7: disposition

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
@Override
public void disposition(final DeliveryState state)
{
    _deliveryState = state;
    if(!_remoteSettled)
    {
        addToTransportWorkList();
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:10,代码来源:DeliveryImpl.java

示例8: newInstance

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
public Disposition newInstance(Object described)
{
    List l = (List) described;

    Disposition o = new Disposition();

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

    switch(6 - l.size())
    {

        case 0:
            Boolean batchable = (Boolean) l.get(5);
            o.setBatchable(batchable == null ? false : batchable);
        case 1:
            o.setState( (DeliveryState) l.get( 4 ) );
        case 2:
            Boolean settled = (Boolean) l.get(3);
            o.setSettled(settled == null ? false : settled);
        case 3:
            o.setLast( (UnsignedInteger) l.get( 2 ) );
        case 4:
            o.setFirst( (UnsignedInteger) l.get( 1 ) );
        case 5:
            o.setRole( Boolean.TRUE.equals(l.get( 0 )) ? Role.RECEIVER : Role.SENDER );
    }


    return o;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:34,代码来源:DispositionType.java

示例9: disposition

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
@Override
public ProtonDelivery disposition(DeliveryState state, boolean settle) {
  delivery.disposition(state);
  if (settle) {
    settle();
  } else {
    flushConnection();
  }

  return this;
}
 
开发者ID:vert-x3,项目名称:vertx-proton,代码行数:12,代码来源:ProtonDeliveryImpl.java

示例10: settleDelivery

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
protected void settleDelivery(Delivery incoming, DeliveryState state) {
    incoming.disposition(state);
    incoming.settle();
    // TODO: this flows credit, which we might not want, e.g if
    // a drain was issued to stop the link.
    sendFlowIfNeeded();
}
 
开发者ID:apache,项目名称:qpid-jms,代码行数:8,代码来源:AmqpConsumer.java

示例11: processDeliveryUpdates

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
@Override
public void processDeliveryUpdates() {
    List<Delivery> toRemove = new ArrayList<Delivery>();

    for (Delivery delivery : pending) {
        DeliveryState state = delivery.getRemoteState();
        if (state == null) {
            continue;
        }

        @SuppressWarnings("unchecked")
        AsyncResult<Void> request = (AsyncResult<Void>) delivery.getContext();

        if (state instanceof Accepted) {
            toRemove.add(delivery);
            LOG.trace("State of delivery accepted: {}", delivery);
            tagGenerator.returnTag(delivery.getTag());
            if (request != null && !request.isComplete()) {
                request.onSuccess();
            }
        } else if (state instanceof Rejected) {
            Exception remoteError = getRemoteError();
            toRemove.add(delivery);
            tagGenerator.returnTag(delivery.getTag());
            if (request != null && !request.isComplete()) {
                request.onFailure(remoteError);
            } else {
                connection.getProvider().fireProviderException(remoteError);
            }
        } else if (state instanceof TransactionalState) {
            LOG.info("State of delivery is Transacted: {}", state);
        } else {
            LOG.warn("Message send updated with unsupported state: {}", state);
        }
    }

    pending.removeAll(toRemove);
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:39,代码来源:AmqpFixedProducer.java

示例12: getLocalState

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
@Override
public DeliveryState getLocalState()
{
    return _deliveryState;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:6,代码来源:DeliveryImpl.java

示例13: getRemoteState

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
@Override
public DeliveryState getRemoteState()
{
    return _remoteDeliveryState;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:6,代码来源:DeliveryImpl.java

示例14: setRemoteDeliveryState

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
void setRemoteDeliveryState(DeliveryState remoteDeliveryState)
{
    _remoteDeliveryState = remoteDeliveryState;
    _updated = true;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:6,代码来源:DeliveryImpl.java

示例15: setDefaultDeliveryState

import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
@Override
public void setDefaultDeliveryState(DeliveryState state)
{
    _defaultDeliveryState = state;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:6,代码来源:DeliveryImpl.java


注:本文中的org.apache.qpid.proton.amqp.transport.DeliveryState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。