aglinxinyuan opened a new issue, #5663:
URL: https://github.com/apache/texera/issues/5663
## Background
`DeadLetterMonitorActor` in
`amber/src/main/scala/org/apache/texera/amber/engine/architecture/messaginglayer/DeadLetterMonitorActor.scala`
currently lacks a dedicated unit-spec. It is a tiny Pekko actor subscribed to
`DeadLetter` events; when a `DeadLetter` carries a
`WorkflowActor.NetworkMessage`, the actor sends `MessageBecomesDeadLetter(msg)`
back to the original `NetworkSenderActor` (which then retries / surfaces the
failure).
```scala
class DeadLetterMonitorActor extends Actor {
override def receive: Receive = {
case d: DeadLetter =>
d.message match {
case msg: NetworkMessage =>
d.sender ! MessageBecomesDeadLetter(msg)
case other =>
// skip for now
}
case _ =>
}
}
```
## Behavior to pin
| Surface | Contract |
| --- | --- |
| `DeadLetter` carrying a `NetworkMessage` | the original sender
(`d.sender`) receives a `MessageBecomesDeadLetter(msg)` |
| The forwarded payload equals `d.message` | the `NetworkMessage` is
reflected back unchanged (no copy / no field drop) |
| `DeadLetter` carrying a non-`NetworkMessage` payload (e.g. `"hello"`,
`Int`, a different case class) | no reply is sent to `d.sender` |
| Non-`DeadLetter` messages | are silently ignored (the catch-all `case _`
branch) |
| Multiple `DeadLetter` events | each is handled independently — no
cross-talk |
## Scope
- New spec file: `DeadLetterMonitorActorSpec.scala` (matches the
`<srcClassName>Spec.scala` convention).
- Use `org.apache.pekko.testkit.{TestKit, TestProbe, TestActorRef}` — the
existing actor specs in this codebase (`NetworkInputGatewaySpec`,
`OutputManagerSpec`) demonstrate the pattern.
- `TestProbe` as the original sender; assert `expectMsg`/`expectNoMessage`
after sending `DeadLetter(...)` to a `TestActorRef[DeadLetterMonitorActor]`.
- No production-code changes.
## Hint
Construct a `DeadLetter` directly:
```scala
val probe = TestProbe()
val ref = TestActorRef(new DeadLetterMonitorActor)
val deadLetter = DeadLetter(message, probe.ref, ref)
ref.tell(deadLetter, probe.ref)
probe.expectMsg(MessageBecomesDeadLetter(...)) // or expectNoMessage()
```
You'll need to construct a real `NetworkMessage` (see `WorkflowActor`
companion) — pick any valid `WorkflowFIFOMessage` payload
(`DataFrame(Array.empty)` is the cheapest).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]