1

In the Apache PLC4X project I am currently setting up a framework for integration tests. PLC4X 's Java drivers are heavily using Netty. Also have we built a large set of so-called "transports" which provide the Channels Netty uses for communication. One of these transports is the "TestTransport" which uses an EmbeddedChannel. I am struggling to make this transport work in Netty's Bootstrap mechanism. Sort of doesn't matter what I try, I am stuck. If I don't provide an EventLoop, Bootstrap complains that there's no EventLoop. If I get the EventLoop from the EmbeddedChannel by overriding the "init" method, the EmbeddedChannel complains that there is already an EventLoop configured.

Unfortunately in the core of Netty everything I would need to adjust is sort of "private", "package private" and "final". With more recent versions of Java, a lot of the evil reflection stuff is no longer possible.

Is there a way to configure a EmbeddedChannel with the Bootstrap mechanism, as I wouldn't want to tear apart the core of the project and switch to ChannelFactories just for this one feature ... and I wouldn't want to fork a lot of the Netty code just in order to get the job done.

Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34

1 Answers1

0

Unfortunately there is no way to use EmbeddedChannel with Bootstrap. that said I am not sure I understand why you would need to do a lot of changes. Maybe another alternative that is a better fit for you is using LocalChannel and LocalServerChannel ? Both can be used with *Bootstrap.

Norman Maurer
  • 23,104
  • 2
  • 33
  • 31
  • Well I want to write integration-tests for PLC4X drivers by being able to push data in and out on both sides of the pipeline. I thought that was what the EmbeddedChannel was intended for. However I didn't give up and retried several approaches and managed to get the EmbeddedChannel working in Bootstrap: https://github.com/apache/plc4x/commit/4b651798775ee36ae38194b8e1e4615b14c21a02 – Christofer Dutz Feb 27 '20 at 14:19