Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TH2-3133] Put RawMessage.Metadata.properties to MessageToStore.metadata #33

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version=3.5.1
release_version=3.6.0
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/com/exactpro/th2/mstore/ProtoUtil.java
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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) {
andrew-drobynin marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -43,6 +45,18 @@ public static MessageToStore toCradleMessage(Message protoMessage) {
public static MessageToStore toCradleMessage(RawMessage protoRawMessage) {
RawMessageMetadata metadata = protoRawMessage.getMetadata();
MessageID messageID = metadata.getId();
// 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())
Expand Down