[ 
https://issues.apache.org/jira/browse/CAMEL-26181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18136886#comment-18136886
 ] 

Claus Ibsen commented on CAMEL-26181:
-------------------------------------

Fix in PR https://github.com/apache/camel/pull/29015

1. tahu-host: each message is now passed to the consumer from onMessage only, 
so the route gets one exchange per message. Before it got two, and three for an 
NDATA, because Tahu 1.0.21 calls onNodeDataArrived twice. The same consumer 
also lost CamelTahuMessageType and the other message headers when a message had 
metrics, because setHeaders replaced them. That is fixed in the PR too.
2. tahu-edge: a body that is not a SparkplugBPayload is now the payload body, 
converted to bytes. The metrics still come from the headers. A body that does 
not convert to bytes fails with InvalidPayloadException.

The per-metric exchanges are kept and now documented. Open question in the PR: 
keep them, or add an option to turn them off later?

_Claude Code on behalf of Claus Ibsen (davsclaus)_

> camel-tahu - tahu-host delivers each Sparkplug message twice, and tahu-edge 
> can never set the payload body from the message body
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26181
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26181
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-tahu
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 4.24.0
>
>
> Found while adding the catalog body types of tahu-edge and tahu-host 
> (CAMEL-24961, PR #28411).
> h4. 1. tahu-host gives two identical exchanges for each Sparkplug message
> {{MultiTahuHostApplicationEventHandler}} passes each message to the consumer 
> from its specific callback ({{onNodeBirthArrived}}, {{onNodeDataArrived}}, 
> {{onDeviceDataArrived}} and the others, main 2a465aa4814c, lines 42 to 87) 
> and again from {{onMessage}} (lines 110 to 115), so 
> {{TahuHostConsumer.onMessageConsumer}} runs twice and the route gets two 
> identical exchanges per message. On top, {{onMetricConsumer}} 
> (TahuHostConsumer line 167) sends one more exchange per metric. Checked on 
> 4.24.0-SNAPSHOT end to end with the test-infra HiveMQ container.
> Proposed: forward a message from one of the two paths only, and document 
> whether the per-metric exchanges are meant.
> h4. 2. tahu-edge can never take the payload body from the message body
> {{TahuEdgeProducer.process}} (main 2a465aa4814c, lines 114 to 117) converts 
> the message to a {{SparkplugBPayload}} only when the body is null, by setting 
> the message itself as the body. 
> {{TahuEdgePayloadConverter.messageToSparkplugBPayload}} (line 61) then skips 
> the body because it is the message ({{body != message}}), so the payload body 
> is never set. A text or bytes body has no converter to {{SparkplugBPayload}} 
> and fails with an {{InvalidPayloadException}}. The 
> {{TahuEdgeProducerRouteBuilder}} test passes only because the simulator's 
> payload body is null. Checked on 4.24.0-SNAPSHOT end to end with the 
> test-infra HiveMQ container.
> Proposed: for a body that is not a {{SparkplugBPayload}}, build the payload 
> from the headers and set the body converted to {{byte[]}} as the payload 
> body, and test it with a non-null body.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to