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-5073] Ability to send RawMessage directly to conn components. #121

Merged
merged 6 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ Most of them consists of the next steps:
3. Sends the passed business message to Codec via mq pin
4. Waits the specific business message from Codec during specified timeout
5. Returns responded business message with checkpoint

![picture](scheme.png)

### Sending raw messages
It is also possible to send raw messages ( containing metadata and having payload in original format ) directly to conn components without waiting while message will be encoded by codec and then sent to conn component.
For that you need to:
1. Send rpc request using `SendRawMessageRequest` and `sendRawMessage` rpc that is defined in [th2-grpc-act-template](https://github.com/th2-net/th2-grpc-act-template/blob/master/src/main/proto/th2_grpc_act_template/act_template.proto "act_template.proto")
2. Transport group with `RawMessage` will be published to pins with `send_raw` attribute.

## Custom resources for infra-mgr

```yaml
Expand Down Expand Up @@ -60,6 +65,28 @@ spec:
- field-name: session_alias
expected-value: conn2_session_alias
operation: EQUAL
- name: to_conn1_transport
connection-type: mq
attributes:
- publish
- transport-group
- send_raw
filters:
- metadata:
- field-name: session_alias
expected-value: conn1_session_alias
operation: EQUAL
- name: to_conn2_transport
connection-type: mq
attributes:
- publish
- transport-group
- send_raw
filters:
- metadata:
- field-name: session_alias
expected-value: conn1_session_alias
operation: EQUAL
```

## Descriptor gradle plugin
Expand All @@ -73,6 +100,7 @@ the `protobuf-description-base64` label. Such descriptors can be used to interac

### 5.1.0
+ Added RPC to send raw messages.
+ Updated grpc-act-template to `4.2.0`

### 5.0.0

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ dependencies {

implementation 'com.exactpro.th2:common:5.4.0-dev'
implementation 'com.exactpro.th2:common-utils:2.2.0-dev'
implementation 'com.exactpro.th2:grpc-act-template:4.1.0-TH2-5073+'
implementation 'com.exactpro.th2:grpc-act-template:4.2.0-dev'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this was also published as 4.2.0. So, probably we should use release version instead of dev-release

implementation 'com.exactpro.th2:grpc-check1:4.2.0-dev'

implementation "com.fasterxml.jackson.core:jackson-core"
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/exactpro/th2/act/ActHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
import io.grpc.Context;
import io.grpc.Deadline;
import io.grpc.stub.StreamObserver;
import java.nio.charset.StandardCharsets;
import io.netty.buffer.ByteBufUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -611,10 +611,9 @@ private com.exactpro.th2.common.grpc.Event createSendMessageEvent(ParsedMessage
}

private com.exactpro.th2.common.grpc.Event createSendRawMessageEvent(RawMessage message, EventID parentEventId) throws IOException {
String bodyString = message.getBody().toString(StandardCharsets.UTF_8);
Event event = start()
.name("Send '" + bodyString + "' message to connectivity");
com.exactpro.th2.common.event.bean.Message messageBean = EventUtils.createMessageBean(bodyString);
.name("Sent raw message to connectivity");
com.exactpro.th2.common.event.bean.Message messageBean = EventUtils.createMessageBean(ByteBufUtil.hexDump(message.getBody()));
event.status(Status.PASSED);
event.bodyData(messageBean);
event.type("Outgoing message");
Expand Down
Loading