com.rabbitmq.client.Method Java Examples

The following examples show how to use com.rabbitmq.client.Method. 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: RabbitMqIOTest.java    From beam with Apache License 2.0 6 votes vote down vote up
@Test(timeout = ONE_MINUTE_MS)
public void testDeclareIncompatibleExchangeFails() throws Exception {
  RabbitMqIO.Read read =
      RabbitMqIO.read().withExchange("IncompatibleExchange", "direct", "unused");
  try {
    doExchangeTest(new ExchangeTestPlan(read, 1), true);
    fail("Expected to have failed to declare an incompatible exchange");
  } catch (Exception e) {
    Throwable cause = Throwables.getRootCause(e);
    if (cause instanceof ShutdownSignalException) {
      ShutdownSignalException sse = (ShutdownSignalException) cause;
      Method reason = sse.getReason();
      if (reason instanceof com.rabbitmq.client.AMQP.Connection.Close) {
        com.rabbitmq.client.AMQP.Connection.Close close =
            (com.rabbitmq.client.AMQP.Connection.Close) reason;
        assertEquals("Expected failure is 530: not-allowed", 530, close.getReplyCode());
      } else {
        fail(
            "Unexpected ShutdownSignalException reason. Expected Connection.Close. Got: "
                + reason);
      }
    } else {
      fail("Expected to fail with ShutdownSignalException. Instead failed with " + cause);
    }
  }
}
 
Example #2
Source File: AMQCommandConstructInterceptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private boolean validate(Object target, Object[] args) {
    if (args == null) {
        if (isDebug) {
            logger.debug("Expected arguments, but found none.");
        }
        return false;
    }
    if (args.length != 3) {
        if (isDebug) {
            logger.debug("Expected 3 arguments, but found {}", args.length);
        }
        return false;
    }
    Object method = args[0];
    if (method == null) {
        // valid, but this won't be null producer side
        return false;
    }
    if (!(method instanceof Method)) {
        if (isDebug) {
            logger.debug("Expected args[0] to be {}, but was {}", Method.class.getName(), method.getClass().getName());
        }
        return false;
    }
    if (!AMQP_METHOD_TO_INTERCEPT.equals(((Method) method).protocolMethodName())) {
        return false;
    }
    Object contentHeader = args[1];
    if (!(contentHeader instanceof AMQP.BasicProperties)) {
        // skip header injection for null, or non AMQP.BasicProperties header
        return false;
    }
    if (!(contentHeader instanceof HeadersFieldSetter)) {
        if (isDebug) {
            logger.debug("Invalid args[1]({}) object. Need field setter({})", contentHeader, HeadersFieldSetter.class.getName());
        }
        return false;
    }
    return true;
}
 
Example #3
Source File: AbstractFunctionalTest.java    From lyra with Apache License 2.0 5 votes vote down vote up
protected void callShutdownListener(RetryableResource resource, ShutdownSignalException e) {
  Method method = e.getReason();
  if (method instanceof AMQP.Connection.Close) {
    if (recoveryChannel != null)
      when(recoveryChannel.isOpen()).thenReturn(false);
    connectionHandler.shutdownListeners.get(0).shutdownCompleted(e);
  } else if (method instanceof AMQP.Channel.Close)
    resource.shutdownListeners.get(0).shutdownCompleted(e);
}
 
Example #4
Source File: Exceptions.java    From lyra with Apache License 2.0 5 votes vote down vote up
private static boolean isRetryable(ShutdownSignalException e) {
  if (e.isInitiatedByApplication())
    return false;
  Method method = e.getReason();
  if (method instanceof AMQP.Connection.Close)
    return isRetryable(((AMQP.Connection.Close) method).getReplyCode());
  if (method instanceof AMQP.Channel.Close)
    return isRetryable(((AMQP.Channel.Close) method).getReplyCode());
  return false;
}
 
Example #5
Source File: TestChannel.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public Command rpc(Method method) throws IOException {
    throw new UnsupportedOperationException(
            "This method is not currently supported as it is not used by current API in testing");
}
 
Example #6
Source File: PoolableChannel.java    From jweb-cms with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void asyncRpc(Method method) throws IOException {
    delegate.asyncRpc(method);
}
 
Example #7
Source File: PoolableChannel.java    From jweb-cms with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Command rpc(Method method) throws IOException {
    return delegate.rpc(method);
}
 
Example #8
Source File: PoolableChannel.java    From jweb-cms with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public CompletableFuture<Command> asyncCompletableRpc(Method method) throws IOException {
    return delegate.asyncCompletableRpc(method);
}
 
Example #9
Source File: TestChannel.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void asyncRpc(Method method) throws IOException {
    throw new UnsupportedOperationException(
            "This method is not currently supported as it is not used by current API in testing");

}
 
Example #10
Source File: MockChannel.java    From rabbitmq-mock with Apache License 2.0 4 votes vote down vote up
@Override
public void asyncRpc(Method method) {
    throw new UnsupportedOperationException();
}
 
Example #11
Source File: TestChannel.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void asyncRpc(Method method) throws IOException {
    throw new UnsupportedOperationException("This method is not currently supported as it is not used by current API in testing");

}
 
Example #12
Source File: TestChannel.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public Command rpc(Method method) throws IOException {
    throw new UnsupportedOperationException("This method is not currently supported as it is not used by current API in testing");
}
 
Example #13
Source File: TestChannel.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<Command> asyncCompletableRpc(Method method) throws IOException {
    throw new UnsupportedOperationException("This method is not currently supported as it is not used by current API in testing");
}
 
Example #14
Source File: MockChannel.java    From rabbitmq-mock with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<Command> asyncCompletableRpc(Method method) {
    throw new UnsupportedOperationException();
}
 
Example #15
Source File: AbstractFunctionalTest.java    From lyra with Apache License 2.0 4 votes vote down vote up
protected ShutdownSignalException nonRetryableChannelShutdownSignal() {
  Method m = new AMQP.Channel.Close.Builder().replyCode(404).build();
  return new ShutdownSignalException(false, false, m, null);
}
 
Example #16
Source File: AbstractFunctionalTest.java    From lyra with Apache License 2.0 4 votes vote down vote up
protected ShutdownSignalException retryableChannelShutdownSignal() {
  Method m = new AMQP.Channel.Close.Builder().replyCode(311).build();
  return new ShutdownSignalException(false, false, m, null);
}
 
Example #17
Source File: AbstractFunctionalTest.java    From lyra with Apache License 2.0 4 votes vote down vote up
protected ShutdownSignalException retryableConnectionShutdownSignal() {
  Method m = new AMQP.Connection.Close.Builder().replyCode(320).build();
  return new ShutdownSignalException(true, false, m, null);
}
 
Example #18
Source File: AbstractFunctionalTest.java    From lyra with Apache License 2.0 4 votes vote down vote up
protected ShutdownSignalException nonRetryableConnectionShutdownSignal() {
  Method m = new AMQP.Connection.Close.Builder().replyCode(530).build();
  return new ShutdownSignalException(true, false, m, null);
}
 
Example #19
Source File: MockChannel.java    From rabbitmq-mock with Apache License 2.0 4 votes vote down vote up
@Override
public Command rpc(Method method) {
    throw new UnsupportedOperationException();
}