com.rabbitmq.client.Consumer Java Examples

The following examples show how to use com.rabbitmq.client.Consumer. 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: RabbitMQTopicUtil.java    From wangmarket with Apache License 2.0 6 votes vote down vote up
public void receive() throws IOException, TimeoutException{
      
       // 当声明队列,不加任何参数,产生的将是一个临时队列,getQueue返回的是队列名称
       String queueA = channel.queueDeclare().getQueue();
       System.out.println("临时队列:" + queueA);
       
       // 第三个参数为“绑定建”
       // * 可以代替一个单词。
       // # 可以替代零个或多个单词。
       channel.queueBind(queueA, EXCHANGE_NAME, "com.xnx3.wangmarket.default");
       Consumer consumerA = new DefaultConsumer(channel) {
           @Override
           public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
               String recv = new String(body, "UTF-8");
               System.out.println("Direct-Receive-A:" + recv);
           }
       };
       channel.basicConsume(queueA, true, consumerA);
}
 
Example #2
Source File: ConsumerHandleDeliveryInterceptor.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
private boolean validate(Object target, Object[] args) {
    if (!(target instanceof Consumer)) {
        return false;
    }
    if (args == null || args.length < 2) {
        return false;
    }
    if (!(args[1] instanceof Envelope)) {
        return false;
    }
    if (!(args[1] instanceof AsyncContextAccessor)) {
        if (isDebug) {
            logger.debug("Invalid args[1] object. Need accessor({}).", AsyncContextAccessor.class.getName());
        }
        return false;
    }
    return true;
}
 
Example #3
Source File: MessageSubscriberFactory.java    From Insights with Apache License 2.0 6 votes vote down vote up
public void registerSubscriber(String routingKey, final EngineSubscriberResponseHandler responseHandler) throws Exception {
	Channel channel = connection.createChannel();
	String queueName = routingKey.replace(".", "_");
	channel.queueDeclare(queueName, true, false, false, null);
	channel.queueBind(queueName, MessageConstants.EXCHANGE_NAME, routingKey);
	channel.basicQos(ApplicationConfigProvider.getInstance().getMessageQueue().getPrefetchCount());
	responseHandler.setChannel(channel);
	log.debug("prefetchCount "+ApplicationConfigProvider.getInstance().getMessageQueue().getPrefetchCount() );
	Consumer consumer = new DefaultConsumer(channel) {
		@Override
		public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties,
				byte[] body) throws IOException {
			responseHandler.handleDelivery(consumerTag, envelope, properties, body);
		}
	};
	channel.basicConsume(queueName, false, routingKey, consumer);
}
 
Example #4
Source File: TestStreamSetsMessageConsumer.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerSingleMessage() throws Exception {
  TransferQueue<RabbitMessage> messages = new LinkedTransferQueue<>();

  Channel channel = mock(Channel.class);

  final Consumer consumer = new StreamSetsMessageConsumer(channel, messages);
  final Envelope envelope = new Envelope(1L, false, EXCHANGE_NAME, QUEUE_NAME);

  executor.submit(new Runnable() {
    @Override
    public void run() {
      try {
        consumer.handleDelivery("consumerTag", envelope, null, TEST_MESSAGE_1.getBytes());
      } catch (IOException ignored) {
        // no op
      }
    }
  });

  RabbitMessage message = messages.take();
  assertEquals(TEST_MESSAGE_1, new String(message.getBody(), StandardCharsets.UTF_8));
}
 
Example #5
Source File: RabbitMqConsumer.java    From flowing-retail-old with Apache License 2.0 6 votes vote down vote up
protected void connect() throws Exception {
  ConnectionFactory factory = new ConnectionFactory();
  factory.setHost("localhost");
  Connection connection = factory.newConnection();
  channel = connection.createChannel();

  String queueName = "flowing-retail-" + name;
  channel.queueDeclare(queueName, true, false, false, null);
  channel.exchangeDeclare(EXCHANGE_NAME, "fanout", true); // publish/subscribe model
  channel.queueBind(queueName, EXCHANGE_NAME, "*");

  System.out.println(" [*] Waiting for messages.");

  Consumer consumer = new DefaultConsumer(channel) {
    @Override
    public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
      String message = new String(body, "UTF-8");
      System.out.println(" [x] Received '" + message + "'");
      eventHandler.handleEvent(message);
    }
  };
  channel.basicConsume(queueName, true, consumer);
}
 
Example #6
Source File: ChannelConfigTest.java    From lyra with Apache License 2.0 6 votes vote down vote up
/**
 * Asserts that channel specific configuration overrides global config.
 */
public void shouldOverrideGlobalConfig() throws Throwable {
  mockConnection();
  MockChannel mc = mockChannel(1);
  ((ConfigurableChannel) mc.proxy).withChannelRecoveryPolicy(RecoveryPolicies.recoverNever())
      .withChannelRecoveryPolicy(RecoveryPolicies.recoverNever());

  when(mc.delegate.basicConsume(anyString(), any(Consumer.class))).thenThrow(
      retryableChannelShutdownSignal());

  try {
    mc.proxy.basicConsume("foo", null);
    fail();
  } catch (Exception e) {
    verify(mc.delegate).basicConsume(anyString(), any(Consumer.class));
  }
}
 
Example #7
Source File: C.java    From java-study with Apache License 2.0 6 votes vote down vote up
public static void main(String[] argv) throws Exception {
		// 创建连接工厂
		ConnectionFactory factory = new ConnectionFactory();
//		设置RabbitMQ地址
		factory.setHost("127.0.0.1");
//		创建一个新的连接
		Connection connection = factory.newConnection();
//		创建一个频道
		Channel channel = connection.createChannel();
//		声明要关注的队列 -- 在RabbitMQ中,队列声明是幂等性的(一个幂等操作的特点是其任意多次执行所产生的影响均与一次执行的影响相同),也就是说,如果不存在,就创建,如果存在,不会对已经存在的队列产生任何影响。
		channel.queueDeclare(QUEUE_NAME, false, false, false, null);
		System.out.println("C [*] Waiting for messages. To exit press CTRL+C");
//		DefaultConsumer类实现了Consumer接口,通过传入一个频道,告诉服务器我们需要那个频道的消息,如果频道中有消息,就会执行回调函数handleDelivery
		Consumer consumer = new DefaultConsumer(channel) {
			@Override
			public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
				String message = new String(body, "UTF-8");
				System.out.println("C [x] Received '" + message + "'");
			}
		};
//		自动回复队列应答 -- RabbitMQ中的消息确认机制
		channel.basicConsume(QUEUE_NAME, true, consumer);
	}
 
Example #8
Source File: AMQPObservableQueueTest.java    From conductor with Apache License 2.0 6 votes vote down vote up
void runObserve(Channel channel, AMQPObservableQueue observableQueue, String queueName, boolean useWorkingChannel,
		int batchSize) throws IOException {

	final List<Message> found = new ArrayList<>(batchSize);
	TestSubscriber<Message> subscriber = TestSubscriber.create(Subscribers.create(found::add));
	rx.Observable<Message> observable = observableQueue.observe().take(pollTimeMs * 2, TimeUnit.MILLISECONDS);
	assertNotNull(observable);
	observable.subscribe(subscriber);
	subscriber.awaitTerminalEvent();
	subscriber.assertNoErrors();
	subscriber.assertCompleted();
	if (useWorkingChannel) {
		verify(channel, atLeast(1)).basicConsume(eq(queueName), Mockito.anyBoolean(),(Consumer)Mockito.any(Consumer.class));
		Mockito.doNothing().when(channel).basicAck(Mockito.anyLong(), eq(false));
		Mockito.doAnswer(DoesNothing.doesNothing()).when(channel).basicAck(Mockito.anyLong(), eq(false));
		observableQueue.ack(Collections.synchronizedList(found));
	} else {
		assertNotNull(found);
		assertTrue(found.isEmpty());
	}
	observableQueue.close();
}
 
Example #9
Source File: TestChannel.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public String basicConsume(String queue, boolean autoAck, Consumer callback) throws IOException {
    final BlockingQueue<GetResponse> messageQueue = enqueuedMessages.get(queue);
    if (messageQueue == null) {
        throw new IOException("Queue is not defined");
    }

    consumerMap.computeIfAbsent(queue, q -> new ArrayList<>()).add(callback);

    final String consumerTag = UUID.randomUUID().toString();

    GetResponse message;
    while ((message = messageQueue.poll()) != null) {
        callback.handleDelivery(consumerTag, message.getEnvelope(), message.getProps(), message.getBody());
    }

    return consumerTag;
}
 
Example #10
Source File: ChannelHandler.java    From lyra with Apache License 2.0 6 votes vote down vote up
private String handleConsumerDeclare(Method method, Object[] args) throws Exception {
  if (config.isConsumerRecoveryEnabled()) {
    Consumer consumer = (Consumer) args[args.length - 1];
    args[args.length - 1] = new ConsumerDelegate(this, consumer);
    String consumerTag = (String) Reflection.invoke(delegate, method, args);
    String queueName = "".equals(args[0]) ? lastGeneratedQueueName : (String) args[0];
    QueueDeclaration queueDeclaration = connectionHandler.queueDeclarations.get(queueName);
    if (queueDeclaration != null)
      queueName = queueDeclaration.name;
    consumerDeclarations.put(consumerTag, new ConsumerDeclaration(queueDeclaration, method, args));
    log.info("".equals(queueName) ? "Created consumer-{}{} via {}"
      : "Created consumer-{} of {} via {}", consumerTag, queueName, this);
    return consumerTag;
  } else
    return (String) Reflection.invoke(delegate, method, args);
}
 
Example #11
Source File: AbstractFunctionalTest.java    From lyra with Apache License 2.0 5 votes vote down vote up
static ArgumentMatcher<Consumer> matcherFor(final Consumer consumer) {
  return new ArgumentMatcher<Consumer>() {
    @Override
    public boolean matches(Object arg) {
      return arg instanceof MockConsumer ? ((MockConsumer) arg).equals(consumer)
          : ((ConsumerDelegate) arg).delegate.equals(consumer);
    }
  };
}
 
Example #12
Source File: MockChannel.java    From rabbitmq-mock with Apache License 2.0 5 votes vote down vote up
@Override
public String basicConsume(String queue, boolean autoAck, String consumerTag, boolean noLocal, boolean exclusive, Map<String, Object> arguments, Consumer callback) {
    if (DIRECT_REPLY_TO_QUEUE.equals(queue)) {
        queue = directReplyToQueue;
        
        if (!autoAck) {
            throw new IllegalStateException("direct reply-to requires autoAck");
        }
    }
    String serverConsumerTag = node.basicConsume(lastGeneratedIfEmpty(queue), autoAck, consumerTag, noLocal, exclusive, nullToEmpty(arguments), callback, this::nextDeliveryTag, mockConnection);
    metricsCollectorWrapper.basicConsume(this, serverConsumerTag, autoAck);
    return serverConsumerTag;
}
 
Example #13
Source File: ChannelHandler.java    From lyra with Apache License 2.0 5 votes vote down vote up
private void notifyConsumerRecoveryCompleted(Consumer consumer) {
  for (ConsumerListener listener : config.getConsumerListeners())
    try {
      listener.onRecoveryCompleted(consumer, proxy);
    } catch (Exception ignore) {
    }
}
 
Example #14
Source File: ChannelHandler.java    From lyra with Apache License 2.0 5 votes vote down vote up
private void notifyConsumerRecoveryFailure(Consumer consumer, Exception e) {
  for (ConsumerListener listener : config.getConsumerListeners())
    try {
      listener.onRecoveryFailure(consumer, proxy, e);
    } catch (Exception ignore) {
    }
}
 
Example #15
Source File: MockQueue.java    From rabbitmq-mock with Apache License 2.0 5 votes vote down vote up
private void doWithUnackedUntil(long maxDeliveryTag, java.util.function.Consumer<Long> doWithRelevantDeliveryTag) {
    if (unackedMessagesByDeliveryTag.containsKey(maxDeliveryTag)) {
        Set<Long> storedDeliveryTagsToRemove = new LinkedHashSet<>();
        for (Long storedDeliveryTag : unackedMessagesByDeliveryTag.keySet()) {
            storedDeliveryTagsToRemove.add(storedDeliveryTag);
            if (Long.valueOf(maxDeliveryTag).equals(storedDeliveryTag)) {
                break;
            }
        }
        storedDeliveryTagsToRemove.forEach(doWithRelevantDeliveryTag);
    }
}
 
Example #16
Source File: MockNode.java    From rabbitmq-mock with Apache License 2.0 5 votes vote down vote up
public String basicConsume(String queueName, boolean autoAck, String consumerTag, boolean noLocal, boolean exclusive, Map<String, Object> arguments, Consumer callback, Supplier<Long> deliveryTagSupplier, MockConnection mockConnection) {
    final String definitiveConsumerTag;
    if ("".equals(consumerTag)) {
        definitiveConsumerTag = consumerTagGenerator.generate();
    } else {
        definitiveConsumerTag = consumerTag;
    }

    getQueueUnchecked(queueName).basicConsume(definitiveConsumerTag, callback, autoAck, deliveryTagSupplier, mockConnection);

    return definitiveConsumerTag;
}
 
Example #17
Source File: MockQueue.java    From rabbitmq-mock with Apache License 2.0 5 votes vote down vote up
ConsumerAndTag(String tag, Consumer consumer, boolean autoAck, Supplier<Long> deliveryTagSupplier, MockConnection mockConnection) {
    this.tag = tag;
    this.consumer = consumer;
    this.autoAck = autoAck;
    this.deliveryTagSupplier = deliveryTagSupplier;
    this.mockConnection = mockConnection;
}
 
Example #18
Source File: ChannelHandler.java    From lyra with Apache License 2.0 5 votes vote down vote up
private void notifyConsumerRecoveryStarted(Consumer consumer) {
  for (ConsumerListener listener : config.getConsumerListeners())
    try {
      listener.onRecoveryStarted(consumer, proxy);
    } catch (Exception ignore) {
    }
}
 
Example #19
Source File: RabbitMQMessageQueue.java    From dropwizard-experiment with MIT License 5 votes vote down vote up
@Override
public Closeable consume(Function<T, Void> processor) {
    Consumer consumer = new FunctionConsumer<>(channel, processor, type, name, metrics);

    try {
        String tag = channel.basicConsume(name, false, consumer);
        log.info("Set up consumer '{}' for queue '{}'.", tag, name);


        return () -> channel.basicCancel(tag);
    } catch (IOException e) {
        throw new MessageQueueException("Unable to set up consumer.", e);
    }
}
 
Example #20
Source File: MockQueue.java    From rabbitmq-mock with Apache License 2.0 5 votes vote down vote up
public void basicCancel(String consumerTag) {
    if (consumersByTag.containsKey(consumerTag)) {
        Consumer consumer = consumersByTag.remove(consumerTag).consumer;
        consumer.handleCancelOk(consumerTag);
        new HashSet<>(unackedDeliveryTagsByConsumerTag.computeIfAbsent(consumerTag, k -> Collections.emptySet()))
            .forEach(deliveryTag -> basicReject(deliveryTag, true));
    }
}
 
Example #21
Source File: AbstractFunctionalTest.java    From lyra with Apache License 2.0 5 votes vote down vote up
protected Consumer mockConsumer(String queueName, int consumerNumber) throws IOException {
  Consumer consumer = consumers.get(consumerNumber);
  if (consumer == null) {
    String consumerTag = String.format("%s-%s", delegate.getChannelNumber(), consumerNumber);
    consumer = new MockConsumer(proxy, consumerNumber);
    when(delegate.basicConsume(eq(queueName), argThat(matcherFor(consumer)))).thenReturn(
        consumerTag);
    proxy.basicConsume(queueName, consumer);
    consumers.put(consumerNumber, consumer);
  }

  return consumer;
}
 
Example #22
Source File: AMQPObservableQueueTest.java    From conductor with Apache License 2.0 5 votes vote down vote up
Channel mockChannelForQueue(Channel channel, boolean isWorking, boolean exists, String name,
		List<GetResponse> queue) throws IOException {
	// queueDeclarePassive
	final AMQImpl.Queue.DeclareOk queueDeclareOK = new AMQImpl.Queue.DeclareOk(name, queue.size(), 1);
	if (exists) {
		Mockito.when(channel.queueDeclarePassive(eq(name))).thenReturn(queueDeclareOK);
	} else {
		Mockito.when(channel.queueDeclarePassive(eq(name))).thenThrow(new IOException("Queue " + name + " exists"));
	}
	// queueDeclare
	OngoingStubbing<AMQP.Queue.DeclareOk> declareOkOngoingStubbing = Mockito.when(channel.queueDeclare(eq(name),
			Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyMap()))
			.thenReturn(queueDeclareOK);
	if (!isWorking) {
		declareOkOngoingStubbing.thenThrow(new IOException("Cannot declare queue " + name),
				new RuntimeException("Not working"));
	}
	// messageCount
	Mockito.when(channel.messageCount(eq(name))).thenReturn(1l * queue.size());
	// basicGet
	OngoingStubbing<String> getResponseOngoingStubbing = Mockito
			.when(channel.basicConsume(eq(name), Mockito.anyBoolean(), (Consumer) Mockito.any(Consumer.class))).thenAnswer(new ReturnsElementsOf(queue));
	if (!isWorking) {
		getResponseOngoingStubbing.thenThrow(new IOException("Not working"), new RuntimeException("Not working"));
	}
	// basicPublish
	if (isWorking) {
		Mockito.doNothing().when(channel).basicPublish(eq(StringUtils.EMPTY), eq(name),
				Mockito.any(AMQP.BasicProperties.class), Mockito.any(byte[].class));
	} else {
		Mockito.doThrow(new IOException("Not working")).when(channel).basicPublish(eq(StringUtils.EMPTY), eq(name),
				Mockito.any(AMQP.BasicProperties.class), Mockito.any(byte[].class));
	}
	return channel;
}
 
Example #23
Source File: RabbitUtil.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 绑定接收方法。一个 routingKey 只能绑定一个 Consumer
 * @param routingKey
 * @param consumer new DefaultConsumer(rabbitUtil.rabbitMQTopicUtil.getChannel())
 * @throws IOException
 * @throws TimeoutException
 */
public static void receive(String routingKey, Consumer consumer) throws IOException, TimeoutException{
	// 当声明队列,不加任何参数,产生的将是一个临时队列,getQueue返回的是队列名称
       String queue = rabbitMQTopicUtil.getChannel().queueDeclare().getQueue();
       Log.info("创建临时队列, routingKey:"+routingKey+" , queue: "+queue);
       
       rabbitMQTopicUtil.getChannel().queueBind(queue, RabbitMQTopicUtil.EXCHANGE_NAME, routingKey);
       rabbitMQTopicUtil.getChannel().basicConsume(queue, true, consumer);
}
 
Example #24
Source File: RabbitmqIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
private void doCap(int rc, Channel channel, Consumer consumer, Method method, Throwable e) {

            if (null == targetServer) {
                Map<String, Object> conn = channel.getConnection().getServerProperties();
                String cluster_name = (null == conn.get("cluster_name")) ? "unknown"
                        : conn.get("cluster_name").toString();
                String version = (null == conn.get("version")) ? "unknown" : conn.get("version").toString();
                targetServer = cluster_name + "@" + version;
            }

            Map<String, Object> params = new HashMap<String, Object>();

            params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, targetServer);
            params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc);

            if (logger.isDebugable()) {
                logger.debug("Invoke END: rc=" + rc + "," + targetServer, null);
            }

            UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT,
                    Monitor.CapturePhase.DOCAP, params);

            if (method.getName().equals("handleDelivery")) {
                params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, url);
                params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId);
                params.put(InvokeChainConstants.CLIENT_IT_CLASS, consumer.getClass().getName());
                // 调用链只关心一个方法
                params.put(InvokeChainConstants.CLIENT_IT_METHOD, "handleDelivery");
                params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc);
                if (rc == -1) {
                    params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, e.toString());
                }

                // invoke chain
                UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap",
                        InvokeChainConstants.CHAIN_APP_SERVICE, InvokeChainConstants.CapturePhase.DOCAP, params,
                        RabbitmqConsumerAdapter.class, null);
            }
        }
 
Example #25
Source File: SpringAmqpRabbit_2_0_0_to_2_0_3_IT.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Test
public void testPullWithTimeout() throws Exception {
    final String remoteAddress = testRunner.getRemoteAddress();

    Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
    // verify queue-initiated traces
    Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
    ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            rabbitTemplateConvertAndSend); // method
    // automatic recovery deliberately disabled as Spring has it's own recovery mechanism
    Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
    Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace channelNBasicPublishTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            channelNBasicPublish, // method
            null, // rpc
            remoteAddress, // endPoint
            "exchange-" + RabbitMQTestConstants.EXCHANGE, // destinationId
            Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE),
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
    ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            "RabbitMQ Consumer Invocation", // method
            "rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // rpc
            null, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
            remoteAddress, // remoteAddress
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
    Class<?> consumerDispatcherClass = Class.forName("com.rabbitmq.client.impl.ConsumerDispatcher");
    Method consumerDispatcherHandleDelivery = consumerDispatcherClass.getDeclaredMethod("handleDelivery", Consumer.class, String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace consumerDispatcherHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            consumerDispatcherHandleDelivery); // method
    ExpectedTrace asynchronousInvocationTrace = Expectations.event(
            ServiceType.ASYNC.getName(),
            "Asynchronous Invocation");
    // RabbitTemplate internal consumer implementation - may change in future versions which will cause tests to
    // fail, in which case the integration test needs to be updated to match code changes
    Class<?> rabbitTemplateInternalConsumerClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate$2");
    Method rabbitTemplateInternalConsumerHandleDelivery = rabbitTemplateInternalConsumerClass.getDeclaredMethod("handleDelivery", String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace rabbitTemplateInternalConsumerHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            rabbitTemplateInternalConsumerHandleDelivery); // method
    Class<?> deliveryClass = Class.forName("org.springframework.amqp.rabbit.support.Delivery");
    Constructor<?> deliveryConstructor = deliveryClass.getDeclaredConstructor(String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace deliveryConstructorTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            deliveryConstructor);

    ExpectedTrace[] producerTraces = {
            rabbitTemplateConvertAndSendTrace,
            channelNBasicPublishTrace
    };
    ExpectedTrace[] consumerTraces = {
            rabbitMqConsumerInvocationTrace,
            consumerDispatcherHandleDeliveryTrace,
            asynchronousInvocationTrace,
            rabbitTemplateInternalConsumerHandleDeliveryTrace,
            deliveryConstructorTrace
    };

    // verify client-initiated traces
    Method rabbitTemplateReceive = rabbitTemplateClass.getDeclaredMethod("receive", String.class, long.class);
    ExpectedTrace rabbitTemplateReceiveTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            rabbitTemplateReceive); // method
    Class<?> propagationMarkerClass = PropagationMarker.class;
    Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
    ExpectedTrace markTrace = Expectations.event(
            ServiceType.INTERNAL_METHOD.getName(),
            propagationMarkerMark);

    ExpectedTrace[] clientInitiatedTraces = {
            rabbitTemplateReceiveTrace,
            markTrace
    };

    final int expectedTraceCount = producerTraces.length + consumerTraces.length + clientInitiatedTraces.length;
    final PluginTestVerifier verifier = testRunner.runPull(expectedTraceCount, 5000L);

    verifier.verifyDiscreteTrace(producerTraces);
    verifier.verifyDiscreteTrace(consumerTraces);
    verifier.verifyDiscreteTrace(clientInitiatedTraces);

    verifier.verifyTraceCount(0);
}
 
Example #26
Source File: DefaultConsumerListener.java    From lyra with Apache License 2.0 4 votes vote down vote up
@Override
public void onRecoveryStarted(Consumer consumer, Channel channel) {
}
 
Example #27
Source File: SpringAmqpRabbit_1_4_2_to_1_7_0_IT.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Test
public void testPush() throws Exception {
    final String remoteAddress = testRunner.getRemoteAddress();

    Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
    Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
    ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            rabbitTemplateConvertAndSend); // method
    // automatic recovery deliberately disabled as Spring has it's own recovery mechanism
    Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
    Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace channelNBasicPublishTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            channelNBasicPublish, // method
            null, // rpc
            remoteAddress, // endPoint
            "exchange-" + RabbitMQTestConstants.EXCHANGE, // destinationId
            Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE),
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
    ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            "RabbitMQ Consumer Invocation", // method
            "rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // rpc
            null, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
            remoteAddress, // remoteAddress
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
    Class<?> consumerDispatcherClass = Class.forName("com.rabbitmq.client.impl.ConsumerDispatcher");
    Method consumerDispatcherHandleDelivery = consumerDispatcherClass.getDeclaredMethod("handleDelivery", Consumer.class, String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace consumerDispatcherHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            consumerDispatcherHandleDelivery); // method
    ExpectedTrace asynchronousInvocationTrace = Expectations.event(
            ServiceType.ASYNC.getName(),
            "Asynchronous Invocation");
    Class<?> blockingQueueConsumerInternalConsumerClass = Class.forName("org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$InternalConsumer");
    Method blockingQueueConsumerInternalConsumerHandleDelivery = blockingQueueConsumerInternalConsumerClass.getDeclaredMethod("handleDelivery", String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace blockingQueueConsumerInternalConsumerHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            blockingQueueConsumerInternalConsumerHandleDelivery);
    Class<?> deliveryClass = Class.forName("org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$Delivery");
    Constructor<?> deliveryConstructor = deliveryClass.getDeclaredConstructor(String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace deliveryConstructorTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            deliveryConstructor);
    Class<?> abstractMessageListenerContainerClass = Class.forName("org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer");
    Method abstractMessageListenerContainerExecuteListener = abstractMessageListenerContainerClass.getDeclaredMethod("executeListener", Channel.class, Message.class);
    ExpectedTrace abstractMessageListenerContainerExecuteListenerTrace = Expectations.event(
            ServiceType.INTERNAL_METHOD.getName(),
            abstractMessageListenerContainerExecuteListener);
    Class<?> propagationMarkerClass = PropagationMarker.class;
    Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
    ExpectedTrace markTrace = Expectations.event(
            ServiceType.INTERNAL_METHOD.getName(),
            propagationMarkerMark);

    ExpectedTrace[] producerTraces = {
            rabbitTemplateConvertAndSendTrace,
            channelNBasicPublishTrace
    };
    ExpectedTrace[] consumerTraces = {
            rabbitMqConsumerInvocationTrace,
            consumerDispatcherHandleDeliveryTrace,
            asynchronousInvocationTrace,
            blockingQueueConsumerInternalConsumerHandleDeliveryTrace,
            deliveryConstructorTrace,
            asynchronousInvocationTrace,
            abstractMessageListenerContainerExecuteListenerTrace,
            markTrace
    };

    final int expectedTraceCount = producerTraces.length + consumerTraces.length;
    final PluginTestVerifier verifier = testRunner.runPush(expectedTraceCount);

    verifier.verifyDiscreteTrace(producerTraces);
    verifier.verifyDiscreteTrace(consumerTraces);
    verifier.verifyTraceCount(0);
}
 
Example #28
Source File: SpringAmqpRabbit_1_7_0_to_1_7_7_IT.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Test
public void testPush() throws Exception {
    final String remoteAddress = testRunner.getRemoteAddress();

    Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
    Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
    ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            rabbitTemplateConvertAndSend); // method
    // automatic recovery deliberately disabled as Spring has it's own recovery mechanism
    Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
    Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace channelNBasicPublishTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            channelNBasicPublish, // method
            null, // rpc
            remoteAddress, // endPoint
            "exchange-" + RabbitMQTestConstants.EXCHANGE, // destinationId
            Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE),
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
    ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            "RabbitMQ Consumer Invocation", // method
            "rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // rpc
            null, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
            remoteAddress, // remoteAddress
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
    Class<?> consumerDispatcherClass = Class.forName("com.rabbitmq.client.impl.ConsumerDispatcher");
    Method consumerDispatcherHandleDelivery = consumerDispatcherClass.getDeclaredMethod("handleDelivery", Consumer.class, String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace consumerDispatcherHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            consumerDispatcherHandleDelivery); // method
    ExpectedTrace asynchronousInvocationTrace = Expectations.event(
            ServiceType.ASYNC.getName(),
            "Asynchronous Invocation");
    Class<?> blockingQueueConsumerInternalConsumerClass = Class.forName("org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$InternalConsumer");
    Method blockingQueueConsumerInternalConsumerHandleDelivery = blockingQueueConsumerInternalConsumerClass.getDeclaredMethod("handleDelivery", String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace blockingQueueConsumerInternalConsumerHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            blockingQueueConsumerInternalConsumerHandleDelivery);
    Class<?> deliveryClass = Class.forName("org.springframework.amqp.rabbit.support.Delivery");
    Constructor<?> deliveryConstructor = deliveryClass.getDeclaredConstructor(String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace deliveryConstructorTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            deliveryConstructor);
    Class<?> abstractMessageListenerContainerClass = Class.forName("org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer");
    Method abstractMessageListenerContainerExecuteListener = abstractMessageListenerContainerClass.getDeclaredMethod("executeListener", Channel.class, Message.class);
    ExpectedTrace abstractMessageListenerContainerExecuteListenerTrace = Expectations.event(
            ServiceType.INTERNAL_METHOD.getName(),
            abstractMessageListenerContainerExecuteListener);
    Class<?> propagationMarkerClass = PropagationMarker.class;
    Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
    ExpectedTrace markTrace = Expectations.event(
            ServiceType.INTERNAL_METHOD.getName(),
            propagationMarkerMark);

    ExpectedTrace[] producerTraces = {
            rabbitTemplateConvertAndSendTrace,
            channelNBasicPublishTrace
    };
    ExpectedTrace[] consumerTraces = {
            rabbitMqConsumerInvocationTrace,
            consumerDispatcherHandleDeliveryTrace,
            asynchronousInvocationTrace,
            blockingQueueConsumerInternalConsumerHandleDeliveryTrace,
            deliveryConstructorTrace,
            asynchronousInvocationTrace,
            abstractMessageListenerContainerExecuteListenerTrace,
            markTrace
    };

    final int expectedTraceCount = producerTraces.length + consumerTraces.length;
    final PluginTestVerifier verifier = testRunner.runPush(expectedTraceCount);

    verifier.verifyDiscreteTrace(producerTraces);
    verifier.verifyDiscreteTrace(consumerTraces);
    verifier.verifyTraceCount(0);
}
 
Example #29
Source File: SpringAmqpRabbit_1_7_7_to_2_0_0_IT.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Test
public void testPush() throws Exception {
    final String remoteAddress = testRunner.getRemoteAddress();

    Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
    Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
    ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            rabbitTemplateConvertAndSend); // method
    // automatic recovery deliberately disabled as Spring has it's own recovery mechanism
    Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
    Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace channelNBasicPublishTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            channelNBasicPublish, // method
            null, // rpc
            remoteAddress, // endPoint
            "exchange-" + RabbitMQTestConstants.EXCHANGE, // destinationId
            Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE),
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
    ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            "RabbitMQ Consumer Invocation", // method
            "rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // rpc
            null, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
            remoteAddress, // remoteAddress
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PUSH));
    Class<?> consumerDispatcherClass = Class.forName("com.rabbitmq.client.impl.ConsumerDispatcher");
    Method consumerDispatcherHandleDelivery = consumerDispatcherClass.getDeclaredMethod("handleDelivery", Consumer.class, String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace consumerDispatcherHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            consumerDispatcherHandleDelivery); // method
    ExpectedTrace asynchronousInvocationTrace = Expectations.event(
            ServiceType.ASYNC.getName(),
            "Asynchronous Invocation");
    Class<?> blockingQueueConsumerConsumerDecoratorClass = Class.forName("org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$ConsumerDecorator");
    Method blockingQueueConsumerConsumerDecoratorHandleDelivery = blockingQueueConsumerConsumerDecoratorClass.getDeclaredMethod("handleDelivery", String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace blockingQueueConsumerConsumerDecoratorHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            blockingQueueConsumerConsumerDecoratorHandleDelivery);
    Class<?> deliveryClass = Class.forName("org.springframework.amqp.rabbit.support.Delivery");
    Constructor<?> deliveryConstructor = deliveryClass.getDeclaredConstructor(String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace deliveryConstructorTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            deliveryConstructor);
    Class<?> abstractMessageListenerContainerClass = Class.forName("org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer");
    Method abstractMessageListenerContainerExecuteListener = abstractMessageListenerContainerClass.getDeclaredMethod("executeListener", Channel.class, Message.class);
    ExpectedTrace abstractMessageListenerContainerExecuteListenerTrace = Expectations.event(
            ServiceType.INTERNAL_METHOD.getName(),
            abstractMessageListenerContainerExecuteListener);
    Class<?> propagationMarkerClass = PropagationMarker.class;
    Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
    ExpectedTrace markTrace = Expectations.event(
            ServiceType.INTERNAL_METHOD.getName(),
            propagationMarkerMark);

    ExpectedTrace[] producerTraces = {
            rabbitTemplateConvertAndSendTrace,
            channelNBasicPublishTrace
    };
    ExpectedTrace[] consumerTraces = {
            rabbitMqConsumerInvocationTrace,
            consumerDispatcherHandleDeliveryTrace,
            asynchronousInvocationTrace,
            blockingQueueConsumerConsumerDecoratorHandleDeliveryTrace,
            deliveryConstructorTrace,
            asynchronousInvocationTrace,
            abstractMessageListenerContainerExecuteListenerTrace,
            markTrace
    };

    final int expectedTraceCount = producerTraces.length + consumerTraces.length;
    final PluginTestVerifier verifier = testRunner.runPush(expectedTraceCount);

    verifier.verifyDiscreteTrace(producerTraces);
    verifier.verifyDiscreteTrace(consumerTraces);
    verifier.verifyTraceCount(0);
}
 
Example #30
Source File: SpringAmqpRabbit_1_7_7_to_2_0_0_IT.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Test
public void testPullWithTimeout() throws Exception {
    final String remoteAddress = testRunner.getRemoteAddress();

    Class<?> rabbitTemplateClass = Class.forName("org.springframework.amqp.rabbit.core.RabbitTemplate");
    // verify queue-initiated traces
    Method rabbitTemplateConvertAndSend = rabbitTemplateClass.getDeclaredMethod("convertAndSend", String.class, String.class, Object.class);
    ExpectedTrace rabbitTemplateConvertAndSendTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            rabbitTemplateConvertAndSend); // method
    // automatic recovery deliberately disabled as Spring has it's own recovery mechanism
    Class<?> channelNClass = Class.forName("com.rabbitmq.client.impl.ChannelN");
    Method channelNBasicPublish = channelNClass.getDeclaredMethod("basicPublish", String.class, String.class, boolean.class, boolean.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace channelNBasicPublishTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            channelNBasicPublish, // method
            null, // rpc
            remoteAddress, // endPoint
            "exchange-" + RabbitMQTestConstants.EXCHANGE, // destinationId
            Expectations.annotation("rabbitmq.exchange", RabbitMQTestConstants.EXCHANGE),
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
    ExpectedTrace rabbitMqConsumerInvocationTrace = Expectations.root(
            RabbitMQTestConstants.RABBITMQ_CLIENT, // serviceType
            "RabbitMQ Consumer Invocation", // method
            "rabbitmq://exchange=" + RabbitMQTestConstants.EXCHANGE, // rpc
            null, // endPoint (collected but API to retrieve local address is not available in all versions, so skip)
            remoteAddress, // remoteAddress
            Expectations.annotation("rabbitmq.routingkey", RabbitMQTestConstants.ROUTING_KEY_PULL));
    Class<?> consumerDispatcherClass = Class.forName("com.rabbitmq.client.impl.ConsumerDispatcher");
    Method consumerDispatcherHandleDelivery = consumerDispatcherClass.getDeclaredMethod("handleDelivery", Consumer.class, String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace consumerDispatcherHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            consumerDispatcherHandleDelivery); // method
    ExpectedTrace asynchronousInvocationTrace = Expectations.event(
            ServiceType.ASYNC.getName(),
            "Asynchronous Invocation");
    Class<?> queueingConsumerClass = Class.forName("com.rabbitmq.client.QueueingConsumer");
    Method queueingConsumerHandleDelivery = queueingConsumerClass.getDeclaredMethod("handleDelivery", String.class, Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace queueingConsumerHandleDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            queueingConsumerHandleDelivery);
    Class<?> queueingConsumerDeliveryClass = Class.forName("com.rabbitmq.client.QueueingConsumer$Delivery");
    Constructor queueingConsumerDeliveryConstructor = queueingConsumerDeliveryClass.getDeclaredConstructor(Envelope.class, AMQP.BasicProperties.class, byte[].class);
    ExpectedTrace queueingConsumerDeliveryConstructorTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL,
            queueingConsumerDeliveryConstructor);

    ExpectedTrace[] producerTraces = {
            rabbitTemplateConvertAndSendTrace,
            channelNBasicPublishTrace
    };
    ExpectedTrace[] consumerTraces = {
            rabbitMqConsumerInvocationTrace,
            consumerDispatcherHandleDeliveryTrace,
            asynchronousInvocationTrace,
            queueingConsumerHandleDeliveryTrace,
            queueingConsumerDeliveryConstructorTrace
    };

    // verify client-initiated traces
    Method rabbitTemplateReceive = rabbitTemplateClass.getDeclaredMethod("receive", String.class, long.class);
    ExpectedTrace rabbitTemplateReceiveTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL, // serviceType
            rabbitTemplateReceive); // method
    Method queueingConsumerNextDelivery = queueingConsumerClass.getDeclaredMethod("nextDelivery", long.class);
    ExpectedTrace queueingConsumerNextDeliveryTrace = Expectations.event(
            RabbitMQTestConstants.RABBITMQ_CLIENT_INTERNAL,
            queueingConsumerNextDelivery);
    Class<?> propagationMarkerClass = PropagationMarker.class;
    Method propagationMarkerMark = propagationMarkerClass.getDeclaredMethod("mark");
    ExpectedTrace markTrace = Expectations.event(
            ServiceType.INTERNAL_METHOD.getName(),
            propagationMarkerMark);

    ExpectedTrace[] clientInitiatedTraces = {
            rabbitTemplateReceiveTrace,
            queueingConsumerNextDeliveryTrace,
            markTrace
    };

    final int expectedTraceCount = producerTraces.length + consumerTraces.length + clientInitiatedTraces.length;
    final PluginTestVerifier verifier = testRunner.runPull(expectedTraceCount, 5000L);

    verifier.verifyDiscreteTrace(producerTraces);
    verifier.verifyDiscreteTrace(consumerTraces);
    verifier.verifyDiscreteTrace(clientInitiatedTraces);

    verifier.verifyTraceCount(0);
}