本文整理汇总了Java中org.apache.qpid.proton.amqp.transport.DeliveryState类的典型用法代码示例。如果您正苦于以下问题:Java DeliveryState类的具体用法?Java DeliveryState怎么用?Java DeliveryState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeliveryState类属于org.apache.qpid.proton.amqp.transport包,在下文中一共展示了DeliveryState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getDefaultDeliveryState
import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
@Override
public DeliveryState getDefaultDeliveryState()
{
return _defaultDeliveryState;
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:6,代码来源:DeliveryImpl.java
示例17: readValue
import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
@Override
public Transfer readValue() {
DecoderImpl decoder = getDecoder();
byte typeCode = decoder.getByteBuffer().get();
@SuppressWarnings("unused")
int size = 0;
int count = 0;
switch (typeCode) {
case EncodingCodes.LIST0:
// TODO - Technically invalid however old decoder also allowed this.
break;
case EncodingCodes.LIST8:
size = ((int)decoder.getByteBuffer().get()) & 0xff;
count = ((int)decoder.getByteBuffer().get()) & 0xff;
break;
case EncodingCodes.LIST32:
size = decoder.getByteBuffer().getInt();
count = decoder.getByteBuffer().getInt();
break;
default:
throw new DecodeException("Incorrect type found in Transfer encoding: " + typeCode);
}
Transfer transfer = new Transfer();
for (int index = 0; index < count; ++index) {
switch (index) {
case 0:
transfer.setHandle(decoder.readUnsignedInteger());
break;
case 1:
transfer.setDeliveryId(decoder.readUnsignedInteger());
break;
case 2:
transfer.setDeliveryTag(decoder.readBinary());
break;
case 3:
transfer.setMessageFormat(decoder.readUnsignedInteger());
break;
case 4:
transfer.setSettled(decoder.readBoolean());
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;
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:71,代码来源:FastPathTransferType.java
示例18: newInstance
import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
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;
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:47,代码来源:TransferType.java
示例19: readValue
import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
@Override
public Disposition readValue() {
DecoderImpl decoder = getDecoder();
byte typeCode = decoder.getByteBuffer().get();
@SuppressWarnings("unused")
int size = 0;
int count = 0;
switch (typeCode) {
case EncodingCodes.LIST0:
// TODO - Technically invalid however old decoder also allowed this.
break;
case EncodingCodes.LIST8:
size = ((int)decoder.getByteBuffer().get()) & 0xff;
count = ((int)decoder.getByteBuffer().get()) & 0xff;
break;
case EncodingCodes.LIST32:
size = decoder.getByteBuffer().getInt();
count = decoder.getByteBuffer().getInt();
break;
default:
throw new DecodeException("Incorrect type found in Disposition encoding: " + typeCode);
}
Disposition disposition = new Disposition();
for (int index = 0; index < count; ++index) {
switch (index) {
case 0:
disposition.setRole(Boolean.TRUE.equals(decoder.readBoolean()) ? Role.RECEIVER : Role.SENDER);
break;
case 1:
disposition.setFirst(decoder.readUnsignedInteger());
break;
case 2:
disposition.setLast(decoder.readUnsignedInteger());
break;
case 3:
disposition.setSettled(decoder.readBoolean(false));
break;
case 4:
disposition.setState((DeliveryState) decoder.readObject());
break;
case 5:
disposition.setBatchable(decoder.readBoolean(false));
break;
default:
throw new IllegalStateException("To many entries in Disposition encoding");
}
}
return disposition;
}
开发者ID:apache,项目名称:qpid-proton-j,代码行数:55,代码来源:FastPathDispositionType.java
示例20: settle
import org.apache.qpid.proton.amqp.transport.DeliveryState; //导入依赖的package包/类
private void settle(final Delivery delivery, final int ackType) throws Exception {
byte[] tag = delivery.getTag();
if (tag != null && tag.length > 0 && delivery.remotelySettled()) {
checkinTag(tag);
}
if (ackType == -1) {
// we are going to settle, but redeliver.. we we won't yet ack to ActiveMQ
delivery.settle();
onMessageDispatch((MessageDispatch) delivery.getContext());
} else {
MessageDispatch md = (MessageDispatch) delivery.getContext();
MessageAck ack = new MessageAck();
ack.setConsumerId(consumerId);
ack.setFirstMessageId(md.getMessage().getMessageId());
ack.setLastMessageId(md.getMessage().getMessageId());
ack.setMessageCount(1);
ack.setAckType((byte) ackType);
ack.setDestination(md.getDestination());
DeliveryState remoteState = delivery.getRemoteState();
if (remoteState != null && remoteState instanceof TransactionalState) {
TransactionalState s = (TransactionalState) remoteState;
long txid = toLong(s.getTxnId());
LocalTransactionId localTxId = new LocalTransactionId(connectionId, txid);
ack.setTransactionId(localTxId);
// Store the message sent in this TX we might need to re-send on rollback
md.getMessage().setTransactionId(localTxId);
dispatchedInTx.addFirst(md);
}
LOG.trace("Sending Ack to ActiveMQ: {}", ack);
sendToActiveMQ(ack, new ResponseHandler() {
@Override
public void onResponse(IAmqpProtocolConverter converter, Response response) throws IOException {
if (response.isException()) {
if (response.isException()) {
Throwable exception = ((ExceptionResponse) response).getException();
exception.printStackTrace();
sender.close();
}
} else {
delivery.settle();
}
pumpProtonToSocket();
}
});
}
}
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:52,代码来源:AmqpProtocolConverter.java
注:本文中的org.apache.qpid.proton.amqp.transport.DeliveryState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论