当前位置: 首页>>代码示例>>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;未经允许,请勿转载。