Skip to content

Commit 92f6d45

Browse files
committed
GH-1354 Added version header to Metric Message
Resolves #1354 Resolves #1356 polishing
1 parent d459ebd commit 92f6d45

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

spring-cloud-stream-core-docs/src/main/asciidoc/spring-cloud-stream-overview.adoc

+4-1
Original file line numberDiff line numberDiff line change
@@ -2379,7 +2379,7 @@ java -jar time-source.jar \
23792379
--spring.cloud.stream.metrics.meter-filter=spring.integration.*
23802380
----
23812381

2382-
The following example shows data published to the binding destination as a result of the preceding command:
2382+
The following example shows the payload of the data published to the binding destination as a result of the preceding command:
23832383

23842384
[source,javascript]
23852385
----
@@ -2425,6 +2425,9 @@ The following example shows data published to the binding destination as a resul
24252425
}
24262426
----
24272427

2428+
NOTE: Given that the format of the Metric message has slightly changed after migrating to Micrometer, the published message will also have
2429+
a `STREAM_CLOUD_STREAM_VERSION` header set to `2.x` to help distinguish between Metric messages from the older versions of the Spring Cloud Stream.
2430+
24282431
== Samples
24292432

24302433
For Spring Cloud Stream samples, see the https://github.com/spring-cloud/spring-cloud-stream-samples[spring-cloud-stream-samples] repository on GitHub.

spring-cloud-stream/src/main/java/org/springframework/cloud/stream/micrometer/DefaultDestinationPublishingMeterRegistry.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
import org.apache.commons.logging.LogFactory;
5858

5959
import org.springframework.context.SmartLifecycle;
60-
import org.springframework.messaging.support.GenericMessage;
60+
import org.springframework.messaging.Message;
61+
import org.springframework.messaging.support.MessageBuilder;
6162

6263
/**
6364
*
@@ -229,7 +230,8 @@ private static final class MessageChannelPublisher implements Consumer<String> {
229230
@Override
230231
public void accept(String metricData) {
231232
logger.trace(metricData);
232-
this.metersPublisherBinding.applicationMetrics().send(new GenericMessage<String>(metricData));
233+
Message<String> message = MessageBuilder.withPayload(metricData).setHeader("STREAM_CLOUD_STREAM_VERSION", "2.x").build();
234+
this.metersPublisherBinding.applicationMetrics().send(message);
233235
}
234236
}
235237
}

0 commit comments

Comments
 (0)