org.apache.qpid.proton.engine.Endpoint Java Examples

The following examples show how to use org.apache.qpid.proton.engine.Endpoint. 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: AmqpSupport.java    From qpid-jms with Apache License 2.0 6 votes vote down vote up
/**
 * Given an ErrorCondition instance create a new Exception that best matches
 * the error type that indicates a non-fatal error usually at the link level
 * such as link closed remotely or link create failed due to security access
 * issues.
 *
 * @param provider
 * 		the AMQP provider instance that originates this exception
 * @param endpoint
 *      The target of the error.
 * @param errorCondition
 *      The ErrorCondition returned from the remote peer.
 *
 * @return a new Exception instance that best matches the ErrorCondition value.
 */
public static ProviderException convertToNonFatalException(AmqpProvider provider, Endpoint endpoint, ErrorCondition errorCondition) {
    ProviderException remoteError = null;

    if (errorCondition != null && errorCondition.getCondition() != null) {
        Symbol error = errorCondition.getCondition();
        String message = extractErrorMessage(errorCondition);

        if (error.equals(AmqpError.UNAUTHORIZED_ACCESS)) {
            remoteError = new ProviderSecurityException(message);
        } else if (error.equals(AmqpError.RESOURCE_LIMIT_EXCEEDED)) {
            remoteError = new ProviderResourceAllocationException(message);
        } else if (error.equals(AmqpError.NOT_FOUND)) {
            remoteError = new ProviderInvalidDestinationException(message);
        } else if (error.equals(TransactionErrors.TRANSACTION_ROLLBACK)) {
            remoteError = new ProviderTransactionRolledBackException(message);
        } else {
            remoteError = new ProviderException(message);
        }
    } else if (remoteError == null) {
        remoteError = new ProviderException("Unknown error from remote peer");
    }

    return remoteError;
}
 
Example #2
Source File: AmqpSupport.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
/**
 * Given an ErrorCondition instance create a new Exception that best matches
 * the error type that indicates the connection creation failed for some reason.
 *
 * @param provider
 * 		the AMQP provider instance that originates this exception
 * @param endpoint
 *      The target of the error.
 * @param errorCondition
 *      The ErrorCondition returned from the remote peer.
 *
 * @return a new Exception instance that best matches the ErrorCondition value.
 */
public static ProviderConnectionRemotelyClosedException convertToConnectionClosedException(AmqpProvider provider, Endpoint endpoint, ErrorCondition errorCondition) {
    ProviderConnectionRemotelyClosedException remoteError = null;

    if (errorCondition != null && errorCondition.getCondition() != null) {
        Symbol error = errorCondition.getCondition();
        String message = extractErrorMessage(errorCondition);

        if (error.equals(AmqpError.UNAUTHORIZED_ACCESS)) {
            remoteError = new ProviderConnectionSecurityException(message);
        } else if (error.equals(AmqpError.RESOURCE_LIMIT_EXCEEDED)) {
            remoteError = new ProviderConnectionResourceAllocationException(message);
        } else if (error.equals(ConnectionError.CONNECTION_FORCED)) {
            remoteError = new ProviderConnectionRemotelyClosedException(message);
        } else if (error.equals(AmqpError.NOT_FOUND)) {
            remoteError = new ProviderConnectionResourceNotFoundException(message);
        } else if (error.equals(ConnectionError.REDIRECT)) {
            remoteError = createRedirectException(provider, error, message, errorCondition);
        } else if (error.equals(AmqpError.INVALID_FIELD)) {
            Map<?, ?> info = errorCondition.getInfo();
            if (info != null && CONTAINER_ID.equals(info.get(INVALID_FIELD))) {
                remoteError = new ProviderInvalidClientIDException(message);
            } else {
                remoteError = new ProviderConnectionRemotelyClosedException(message);
            }
        } else {
            remoteError = new ProviderConnectionRemotelyClosedException(message);
        }
    } else if (remoteError == null) {
        remoteError = new ProviderConnectionRemotelyClosedException("Unknown error from remote peer");
    }

    return remoteError;
}
 
Example #3
Source File: Handshaker.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
private void open(Endpoint endpoint) {
    if (endpoint.getLocalState() == EndpointState.UNINITIALIZED) {
        endpoint.open();
    }
}
 
Example #4
Source File: Handshaker.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
private void close(Endpoint endpoint) {
    if (endpoint.getLocalState() != EndpointState.CLOSED) {
        endpoint.close();
    }
}
 
Example #5
Source File: ConnectionTest.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
private void assertEnpointState(Endpoint endpoint, EndpointState localState, EndpointState remoteState)
{
    assertEquals("Unexpected local state", localState, endpoint.getLocalState());
    assertEquals("Unexpected remote state", remoteState, endpoint.getRemoteState());
}
 
Example #6
Source File: SslTest.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
private void assertEndpointState(Endpoint endpoint, EndpointState localState, EndpointState remoteState)
{
    assertEquals("Unexpected local state", localState, endpoint.getLocalState());
    assertEquals("Unexpected remote state", remoteState, endpoint.getRemoteState());
}
 
Example #7
Source File: EngineTestBase.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
protected void assertEndpointState(Endpoint endpoint, EndpointState localState, EndpointState remoteState)
{
    assertEquals(localState, endpoint.getLocalState());
    assertEquals(remoteState, endpoint.getRemoteState());
}