本文整理汇总了Java中org.apache.qpid.proton.amqp.messaging.Rejected.setError方法的典型用法代码示例。如果您正苦于以下问题:Java Rejected.setError方法的具体用法?Java Rejected.setError怎么用?Java Rejected.setError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.qpid.proton.amqp.messaging.Rejected
的用法示例。
在下文中一共展示了Rejected.setError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rejectedDelivery
import org.apache.qpid.proton.amqp.messaging.Rejected; //导入方法依赖的package包/类
/**
* Send a "rejected" delivery to the AMQP remote sender
*
* @param linkName AMQP link name
* @param delivery AMQP delivery
* @param cause exception related to the rejection cause
*/
private void rejectedDelivery(String linkName, ProtonDelivery delivery, Throwable cause) {
Rejected rejected = new Rejected();
rejected.setError(new ErrorCondition(Symbol.valueOf(AmqpBridge.AMQP_ERROR_SEND_TO_KAFKA),
cause.getMessage()));
delivery.disposition(rejected, true);
log.debug("Delivery sent [rejected] on link {}", linkName);
}
示例2: newInstance
import org.apache.qpid.proton.amqp.messaging.Rejected; //导入方法依赖的package包/类
public Rejected newInstance(Object described)
{
List l = (List) described;
Rejected o = new Rejected();
switch(1 - l.size())
{
case 0:
o.setError( (ErrorCondition) l.get( 0 ) );
}
return o;
}
示例3: createRejected
import org.apache.qpid.proton.amqp.messaging.Rejected; //导入方法依赖的package包/类
private Rejected createRejected(Symbol amqpError, String message) {
Rejected rejected = new Rejected();
ErrorCondition condition = new ErrorCondition();
condition.setCondition(amqpError);
condition.setDescription(message);
rejected.setError(condition);
return rejected;
}
示例4: onMessage
import org.apache.qpid.proton.amqp.messaging.Rejected; //导入方法依赖的package包/类
@Override
public void onMessage(Delivery delivery) throws ActiveMQAMQPException {
Receiver receiver;
try {
if (!delivery.isReadable()) {
return;
}
if (delivery.isPartial()) {
return;
}
receiver = ((Receiver) delivery.getLink());
Transaction tx = null;
byte[] data;
data = new byte[delivery.available()];
receiver.recv(data, 0, data.length);
receiver.advance();
if (delivery.getRemoteState() instanceof TransactionalState) {
TransactionalState txState = (TransactionalState) delivery.getRemoteState();
tx = this.sessionSPI.getTransaction(txState.getTxnId(), false);
}
sessionSPI.serverSend(this, tx, receiver, delivery, address, delivery.getMessageFormat(), data);
flow(amqpCredits, minCreditRefresh);
} catch (Exception e) {
log.warn(e.getMessage(), e);
Rejected rejected = new Rejected();
ErrorCondition condition = new ErrorCondition();
if (e instanceof ActiveMQSecurityException) {
condition.setCondition(AmqpError.UNAUTHORIZED_ACCESS);
} else {
condition.setCondition(Symbol.valueOf("failed"));
}
condition.setDescription(e.getMessage());
rejected.setError(condition);
connection.lock();
try {
delivery.disposition(rejected);
delivery.settle();
} finally {
connection.unlock();
}
}
}