use of org.apache.qpid.protonj2.client.Session in project qpid-protonj2 by apache.
the class ClientExceptionSupport method convertToSessionClosedException.
/**
* Given an ErrorCondition instance create a new Exception that best matches
* the error type that indicates the session creation failed for some reason.
*
* @param errorCondition
* The ErrorCondition returned from the remote peer.
*
* @return a new Exception instance that best matches the ErrorCondition value.
*/
public static ClientSessionRemotelyClosedException convertToSessionClosedException(ErrorCondition errorCondition) {
final ClientSessionRemotelyClosedException remoteError;
if (errorCondition != null && errorCondition.getCondition() != null) {
String message = extractErrorMessage(errorCondition);
if (message == null) {
message = "Session remotely closed without explanation";
}
remoteError = new ClientSessionRemotelyClosedException(message, new ClientErrorCondition(errorCondition));
} else {
remoteError = new ClientSessionRemotelyClosedException("Session remotely closed without explanation");
}
return remoteError;
}
use of org.apache.qpid.protonj2.client.Session in project qpid-protonj2 by apache.
the class ClientLocalTransactionContext method handleTransactionDischargeFailed.
private void handleTransactionDischargeFailed(Transaction<TransactionController> transaction) {
ClientFuture<Session> future = transaction.getAttachments().get(DISCHARGE_FUTURE_NAME);
LOG.trace("Discharge of transaction:{} failed", transaction);
ClientException cause = ClientExceptionSupport.convertToNonFatalException(transaction.getCondition());
future.failed(new ClientTransactionRolledBackException(cause.getMessage(), cause));
}
use of org.apache.qpid.protonj2.client.Session in project qpid-protonj2 by apache.
the class ClientReceiverBuilder method receiver.
public ClientReceiver receiver(String address, ReceiverOptions receiverOptions) throws ClientException {
final ReceiverOptions rcvOptions = receiverOptions != null ? receiverOptions : getDefaultReceiverOptions();
final String receiverId = nextReceiverId();
final Receiver protonReceiver = createReceiver(address, rcvOptions, receiverId);
protonReceiver.setSource(createSource(address, rcvOptions));
protonReceiver.setTarget(createTarget(address, rcvOptions));
return new ClientReceiver(session, rcvOptions, receiverId, protonReceiver);
}
use of org.apache.qpid.protonj2.client.Session in project qpid-protonj2 by apache.
the class ClientReceiverBuilder method durableReceiver.
public ClientReceiver durableReceiver(String address, String subscriptionName, ReceiverOptions receiverOptions) {
final ReceiverOptions options = receiverOptions != null ? receiverOptions : getDefaultReceiverOptions();
final String receiverId = nextReceiverId();
options.linkName(subscriptionName);
final Receiver protonReceiver = createReceiver(address, options, receiverId);
protonReceiver.setSource(createDurableSource(address, options));
protonReceiver.setTarget(createTarget(address, options));
return new ClientReceiver(session, options, receiverId, protonReceiver);
}
use of org.apache.qpid.protonj2.client.Session in project qpid-protonj2 by apache.
the class ClientReceiverBuilder method dynamicReceiver.
public ClientReceiver dynamicReceiver(Map<String, Object> dynamicNodeProperties, ReceiverOptions receiverOptions) throws ClientException {
final ReceiverOptions options = receiverOptions != null ? receiverOptions : getDefaultReceiverOptions();
final String receiverId = nextReceiverId();
final Receiver protonReceiver = createReceiver(null, options, receiverId);
protonReceiver.setSource(createSource(null, options));
protonReceiver.setTarget(createTarget(null, options));
// Configure the dynamic nature of the source now.
protonReceiver.getSource().setDynamic(true);
protonReceiver.getSource().setDynamicNodeProperties(ClientConversionSupport.toSymbolKeyedMap(dynamicNodeProperties));
return new ClientReceiver(session, options, receiverId, protonReceiver);
}
Aggregations