private void addConsumerMetadata(MessageProperties messageProperties, Map<String, Object> headers) { String consumerTag = messageProperties.getConsumerTag(); if (consumerTag != null) { headers.put(AmqpHeaders.CONSUMER_TAG, consumerTag); } String consumerQueue = messageProperties.getConsumerQueue(); if (consumerQueue != null) { headers.put(AmqpHeaders.CONSUMER_QUEUE, consumerQueue); } }
private void addConsumerMetadata(MessageProperties messageProperties, Map<String, Object> headers) { String consumerTag = messageProperties.getConsumerTag(); if (consumerTag != null) { headers.put(AmqpHeaders.CONSUMER_TAG, consumerTag); } String consumerQueue = messageProperties.getConsumerQueue(); if (consumerQueue != null) { headers.put(AmqpHeaders.CONSUMER_QUEUE, consumerQueue); } }
/** * Determine the name of the listener method that will handle the given message. * <p> * The default implementation first consults the * {@link #setQueueOrTagToMethodName(Map) queueOrTagToMethodName} map looking for a * match on the consumer queue or consumer tag; if no match found, it simply returns * the configured default listener method, or "handleMessage" if not configured. * @param originalMessage the Rabbit request message * @param extractedMessage the converted Rabbit request message, to be passed into the * listener method as argument * @return the name of the listener method (never <code>null</code>) * @see #setDefaultListenerMethod * @see #setQueueOrTagToMethodName */ protected String getListenerMethodName(Message originalMessage, Object extractedMessage) { if (this.queueOrTagToMethodName.size() > 0) { MessageProperties props = originalMessage.getMessageProperties(); String methodName = this.queueOrTagToMethodName.get(props.getConsumerQueue()); if (methodName == null) { methodName = this.queueOrTagToMethodName.get(props.getConsumerTag()); } if (methodName != null) { return methodName; } } return getDefaultListenerMethod(); }
/** * Determine the name of the listener method that will handle the given message. * <p> * The default implementation first consults the * {@link #setQueueOrTagToMethodName(Map) queueOrTagToMethodName} map looking for a * match on the consumer queue or consumer tag; if no match found, it simply returns * the configured default listener method, or "handleMessage" if not configured. * @param originalMessage the Rabbit request message * @param extractedMessage the converted Rabbit request message, to be passed into the * listener method as argument * @return the name of the listener method (never <code>null</code>) * @see #setDefaultListenerMethod * @see #setQueueOrTagToMethodName */ protected String getListenerMethodName(Message originalMessage, Object extractedMessage) { if (this.queueOrTagToMethodName.size() > 0) { MessageProperties props = originalMessage.getMessageProperties(); String methodName = this.queueOrTagToMethodName.get(props.getConsumerQueue()); if (methodName == null) { methodName = this.queueOrTagToMethodName.get(props.getConsumerTag()); } if (methodName != null) { return methodName; } } return getDefaultListenerMethod(); }
headers.put(AmqpHeaders.RECEIVED_USER_ID, userId); String consumerTag = amqpMessageProperties.getConsumerTag(); if (StringUtils.hasText(consumerTag)) { headers.put(AmqpHeaders.CONSUMER_TAG, consumerTag);
assertTrue(latch.await(5, TimeUnit.SECONDS)); assertEquals(3, messages.size()); assertEquals(consumerTag, messages.get(0).getMessageProperties().getConsumerTag()); assertEquals("foobar", messages.get(0).getMessageProperties().getConsumerQueue()); Executors.newSingleThreadExecutor().execute(() -> container.stop());