當前位置: 首頁>>代碼示例>>Java>>正文


Java ClientException類代碼示例

本文整理匯總了Java中com.ibm.mqlight.api.ClientException的典型用法代碼示例。如果您正苦於以下問題:Java ClientException類的具體用法?Java ClientException怎麽用?Java ClientException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ClientException類屬於com.ibm.mqlight.api包,在下文中一共展示了ClientException類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: failure

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
@Test
public void failure() {
    MockComponent component = new MockComponent();
    Object expectedContext = new Object();
    NetworkConnectPromiseImpl promise = new NetworkConnectPromiseImpl(component, expectedContext);
    ClientException expectedException = new ClientException("oops");

    promise.setFailure(expectedException);
    
    assertTrue("Promise should have been marked as completed", promise.isComplete());
    assertEquals("Component should have received 1 message", 1, component.getMessages().size());
    assertTrue("Message should have been of type ConnectResponse", component.getMessages().get(0) instanceof ConnectResponse);
    ConnectResponse response = (ConnectResponse)component.getMessages().get(0);
    assertSame("Message should have correct cause cause", expectedException, response.exception);
    assertNull("Message should have null channel", response.channel);
    assertSame("Message should have correct context", expectedContext, response.context);
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:18,代碼來源:TestNetworkConnectPromiseImpl.java

示例2: onRetrying

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
void onRetrying(CallbackService callbackService, final ClientException exception) {
    final String methodName = "onRetrying";
    logger.entry(this, methodName, callbackService, exception);
  
    if (listener != null) {
        callbackService.run(new Runnable() {
            public void run() {
                listener.onRetrying(client, context, exception);
            }
        }, client, new CallbackPromiseImpl(client, true));
    }
    
    logger.exit(this, methodName);
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:15,代碼來源:NonBlockingClientListenerWrapper.java

示例3: onStopped

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
void onStopped(CallbackService callbackService, final ClientException exception) {
    final String methodName = "onStopped";
    logger.entry(this, methodName, callbackService);
  
    if (listener != null) {
        callbackService.run(new Runnable() {
            public void run() {
                listener.onStopped(client, context, exception);
            }
        }, client, new CallbackPromiseImpl(client, true));
    }
    
    logger.exit(this, methodName);
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:15,代碼來源:NonBlockingClientListenerWrapper.java

示例4: getClientException

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
private ClientException getClientException(ErrorCondition errorCondition) {
    final String methodName = "getClientException";
    logger.entry(this, methodName, errorCondition);

    ClientException result = null;

    if (errorCondition != null && errorCondition.getCondition() != null) {
        if (errorCondition.getCondition() == LinkError.STOLEN) {
            result = new ReplacedException(errorCondition.getDescription());
        } else if (errorCondition.getCondition().equals(AmqpError.PRECONDITION_FAILED)
                || errorCondition.getCondition().equals(AmqpError.NOT_ALLOWED)
                || errorCondition.getCondition().equals(AmqpError.NOT_IMPLEMENTED)
                || errorCondition.getDescription().contains("_InvalidSourceTimeout")) {
            result = new NotPermittedException(errorCondition.getDescription());
        }

        if (result == null && errorCondition.getDescription() != null) {
            if (errorCondition.getDescription().contains("sasl ") || errorCondition.getDescription().contains("SSL ")) {
                result = new com.ibm.mqlight.api.SecurityException(errorCondition.getDescription());
            }
        }

        if (result == null) {
            String msg = errorCondition.getCondition().toString();
            if (errorCondition.getDescription() != null) {
                msg += ": " + errorCondition.getDescription();
            }
            result = new NetworkException(msg);
        }
    }

    logger.exit(this, methodName, result);
    return result;
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:35,代碼來源:Engine.java

示例5: run

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
@Override
public void run(Runnable runnable, Object orderingCtx, Promise<Void> promise) {
    try {
        runnable.run();
        promise.setSuccess(null);
    } catch(Exception e) {
        promise.setFailure(new ClientException("Application code threw an exception from within a callback.  See linked exception for more details.", e));
    }
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:10,代碼來源:SameThreadCallbackService.java

示例6: testStopFailsSubscribe

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
@Test
public void testStopFailsSubscribe() {
    MockComponent engine = new MockComponent();
    MockNonBlockingClientListener listener = new MockNonBlockingClientListener(false);
    EngineConnection engineConnection = new EngineConnection();

    NonBlockingClientImpl client = openCommon(engine, listener);
    OpenRequest openRequest = (OpenRequest)engine.getMessages().get(0);
    client.tell(new OpenResponse(openRequest, engineConnection), engine);
    assertEquals(ClientState.STARTED, client.getState());

    MockCompletionListener inflightListener = new MockCompletionListener();
    client.subscribe("inflight/kittens", new DestinationAdapter<Void>() {}, inflightListener, null);

    client.tell(new DisconnectNotification(engineConnection, new ClientException("you got disconnected!")), engine);
    assertEquals(ClientState.RETRYING, client.getState());

    MockCompletionListener queuedListener = new MockCompletionListener();
    client.subscribe("queued/kittens", new DestinationAdapter<Void>() {}, queuedListener, null);

    client.stop(null, null);
    assertEquals(3, engine.getMessages().size());
    assertTrue(engine.getMessages().get(2) instanceof OpenRequest);
    openRequest = (OpenRequest)engine.getMessages().get(2);
    client.tell(new OpenResponse(openRequest, new ClientException("")), engine);
    assertEquals(ClientState.STOPPED, client.getState());

    inflightListener.assertFailure(StoppedException.class);
    queuedListener.assertFailure(StoppedException.class);
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:31,代碼來源:TestNonBlockingClientImpl.java

示例7: ConnectResponse

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
public ConnectResponse(NetworkChannel channel, ClientException exception, Object context) {
    this.channel = channel;
    this.exception = exception;
    this.context = context;
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:6,代碼來源:ConnectResponse.java

示例8: OpenResponse

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
public OpenResponse(OpenRequest request, ClientException exception) {
    this.request = request;
    this.connection = null;
    this.exception = exception;
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:6,代碼來源:OpenResponse.java

示例9: EndpointResponse

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
public EndpointResponse(Endpoint endpoint, ClientException exception) {
    this.endpoint = endpoint;
    this.exception = exception;
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:5,代碼來源:EndpointResponse.java

示例10: onStopped

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
@Override public void onStopped(NonBlockingClient client, Void context, ClientException exception) {
    if (throwAssertionFailures) throw new AssertionFailedError("onStopped should not have been called");
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:4,代碼來源:TestNonBlockingClientImpl.java

示例11: onRetrying

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
@Override public void onRetrying(NonBlockingClient client, Void context, ClientException exception) {
    if (throwAssertionFailures) throw new AssertionFailedError("onRetrying should not have been called");
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:4,代碼來源:TestNonBlockingClientImpl.java

示例12: testStopFailsSends

import com.ibm.mqlight.api.ClientException; //導入依賴的package包/類
@Test
public void testStopFailsSends() {
    MockComponent engine = new MockComponent();
    MockNonBlockingClientListener listener = new MockNonBlockingClientListener(false);
    EngineConnection engineConnection = new EngineConnection();

    NonBlockingClientImpl client = openCommon(engine, listener);
    OpenRequest openRequest = (OpenRequest)engine.getMessages().get(0);
    client.tell(new OpenResponse(openRequest, engineConnection), engine);
    assertEquals(ClientState.STARTED, client.getState());

    MockCompletionListener inflightQos0Listener = new MockCompletionListener();
    client.send("/inflight/qos0", "data", null, SendOptions.builder().setQos(QOS.AT_MOST_ONCE).build(), inflightQos0Listener, null);
    MockCompletionListener inflightQos1Listener = new MockCompletionListener();
    client.send("/inflight/qos1", "data", null, SendOptions.builder().setQos(QOS.AT_LEAST_ONCE).build(), inflightQos1Listener, null);

    client.tell(new DisconnectNotification(engineConnection, new ClientException("you got disconnected!")), engine);
    assertEquals(ClientState.RETRYING, client.getState());

    MockCompletionListener queuedQos0Listener = new MockCompletionListener();
    client.send("/queued/qos0", "data", null, SendOptions.builder().setQos(QOS.AT_MOST_ONCE).build(), queuedQos0Listener, null);
    MockCompletionListener queuedQos1Listener = new MockCompletionListener();
    client.send("/queued/qos1", "data", null, SendOptions.builder().setQos(QOS.AT_LEAST_ONCE).build(), queuedQos1Listener, null);

    client.stop(null, null);
    assertEquals(4, engine.getMessages().size());
    assertTrue(engine.getMessages().get(3) instanceof OpenRequest);
    openRequest = (OpenRequest)engine.getMessages().get(3);
    client.tell(new OpenResponse(openRequest, new ClientException("")), engine);
    assertEquals(ClientState.STOPPED, client.getState());

    // If the client is stopped with messages in-flight (e.g. potentially sent to the server) then expect:
    // a) QOS 0 to be marked as success (as the client delivers them 'at most once' and so is optimistic...)
    // b) QOS 1 to be marked as failure (as the client delivers them 'at least once' and so is pessimistic...)
    inflightQos0Listener.assertSuccess();
    inflightQos1Listener.assertFailure(StoppedException.class);

    // If the client has queued (but never attempted to send) a message then stopping will always result
    // in the application being notified that the operation failed - as the client can be sure that the
    // message has never been sent.
    queuedQos0Listener.assertFailure(StoppedException.class);
    queuedQos1Listener.assertFailure(StoppedException.class);
}
 
開發者ID:mqlight,項目名稱:java-mqlight,代碼行數:44,代碼來源:TestNonBlockingClientImpl.java


注:本文中的com.ibm.mqlight.api.ClientException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。