From c7e60b99440cd6777775d997b424e50d9749b66b Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Thu, 3 Feb 2022 11:14:19 +0300 Subject: [PATCH 1/4] [TH2-3133] Put RawMessage.Metadata.properties to MessageToStore.metadata --- .../java/com/exactpro/th2/mstore/ProtoUtil.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java b/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java index 5eec826..5558387 100644 --- a/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java +++ b/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java @@ -26,6 +26,8 @@ import static com.exactpro.th2.common.util.StorageUtils.toCradleDirection; import static com.exactpro.th2.common.util.StorageUtils.toInstant; +import static org.apache.commons.lang3.StringUtils.isNotBlank; +import static org.apache.commons.lang3.StringUtils.trimToEmpty; public class ProtoUtil { public static MessageToStore toCradleMessage(Message protoMessage) { @@ -43,12 +45,17 @@ public static MessageToStore toCradleMessage(Message protoMessage) { public static MessageToStore toCradleMessage(RawMessage protoRawMessage) { RawMessageMetadata metadata = protoRawMessage.getMetadata(); MessageID messageID = metadata.getId(); - return new MessageToStoreBuilder() + MessageToStoreBuilder builder = new MessageToStoreBuilder() .streamName(messageID.getConnectionId().getSessionAlias()) .content(protoRawMessage.toByteArray()) .timestamp(toInstant(metadata.getTimestamp())) .direction(toCradleDirection(messageID.getDirection())) - .index(messageID.getSequence()) - .build(); + .index(messageID.getSequence()); + metadata.getPropertiesMap().forEach((key, value) -> { + if (isNotBlank(key) || isNotBlank(value)) { + builder.metadata(trimToEmpty(key), trimToEmpty(value)); + } + }); + return builder.build(); } } From 0dcc0384a3331e992ce71181eb0dc2900e71d7d1 Mon Sep 17 00:00:00 2001 From: Andrey Drobynin Date: Thu, 3 Feb 2022 13:09:05 +0400 Subject: [PATCH 2/4] README and version --- README.md | 6 +++++- gradle.properties | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f00e4c0..0c0b33a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Overview (3.5.1) +# Overview (3.6.0) Message store (mstore) is an important th2 component responsible for storing raw messages into Cradle. Please refer to [Cradle repository] (https://github.com/th2-net/cradleapi/blob/master/README.md) for more details. This component has a pin for listening messages via MQ. @@ -64,6 +64,10 @@ spec: This is a list of supported features provided by libraries. Please see more details about this feature via [link](https://github.com/th2-net/th2-common-j#configuration-formats). +## 3.6.0 + ++ Fill cradle message metadata for `RawMessage` + ## 3.5.1 + Added more detail into logs diff --git a/gradle.properties b/gradle.properties index 39e35e8..70cf8c3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -release_version=3.5.1 +release_version=3.6.0 From 511e8bb214869e09e3d80033c523fc190ed71132 Mon Sep 17 00:00:00 2001 From: Andrey Drobynin Date: Thu, 3 Feb 2022 13:29:17 +0400 Subject: [PATCH 3/4] 2022 in copyright --- src/main/java/com/exactpro/th2/mstore/ProtoUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java b/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java index 5558387..4a87e08 100644 --- a/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java +++ b/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2021 Exactpro (Exactpro Systems Limited) + * Copyright 2021-2022 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 52575b43d0f4d52e2e3e05f5b727fe1e3b0fe318 Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Fri, 18 Feb 2022 14:45:31 +0300 Subject: [PATCH 4/4] [TH2-3133] Commented RawMessage.Metadata.properties to MessageToStore.metadata --- .../th2/mstore/AbstractMessageStore.java | 2 +- .../com/exactpro/th2/mstore/ProtoUtil.java | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/exactpro/th2/mstore/AbstractMessageStore.java b/src/main/java/com/exactpro/th2/mstore/AbstractMessageStore.java index 6a639f9..4b37ea1 100644 --- a/src/main/java/com/exactpro/th2/mstore/AbstractMessageStore.java +++ b/src/main/java/com/exactpro/th2/mstore/AbstractMessageStore.java @@ -197,7 +197,7 @@ public final void handle(T messageBatch) { storeMessages(messages, sessionData.getBatchHolder()); } catch (Exception ex) { if (logger.isErrorEnabled()) { - logger.error("Cannot handle the batch of type {} message id {}", messageBatch.getClass(), shortDebugString(messageBatch), ex); + logger.error("Cannot handle the batch {}", shortDebugString(messageBatch), ex); } } } diff --git a/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java b/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java index 4a87e08..d40ef35 100644 --- a/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java +++ b/src/main/java/com/exactpro/th2/mstore/ProtoUtil.java @@ -45,17 +45,24 @@ public static MessageToStore toCradleMessage(Message protoMessage) { public static MessageToStore toCradleMessage(RawMessage protoRawMessage) { RawMessageMetadata metadata = protoRawMessage.getMetadata(); MessageID messageID = metadata.getId(); - MessageToStoreBuilder builder = new MessageToStoreBuilder() +// MessageToStoreBuilder builder = new MessageToStoreBuilder() +// .streamName(messageID.getConnectionId().getSessionAlias()) +// .content(protoRawMessage.toByteArray()) +// .timestamp(toInstant(metadata.getTimestamp())) +// .direction(toCradleDirection(messageID.getDirection())) +// .index(messageID.getSequence()); +// metadata.getPropertiesMap().forEach((key, value) -> { +// if (isNotBlank(key) || isNotBlank(value)) { +// builder.metadata(trimToEmpty(key), trimToEmpty(value)); +// } +// }); +// return builder.build(); + return new MessageToStoreBuilder() .streamName(messageID.getConnectionId().getSessionAlias()) .content(protoRawMessage.toByteArray()) .timestamp(toInstant(metadata.getTimestamp())) .direction(toCradleDirection(messageID.getDirection())) - .index(messageID.getSequence()); - metadata.getPropertiesMap().forEach((key, value) -> { - if (isNotBlank(key) || isNotBlank(value)) { - builder.metadata(trimToEmpty(key), trimToEmpty(value)); - } - }); - return builder.build(); + .index(messageID.getSequence()) + .build(); } }