Hi Atol, The use case you described for two-way communication over UDP is understandable, but I recommend taking a different approach for implementation.
The ListenUDP Processor is designed to receive packets without sending a response, so the DatagramChannelDispatcher is not designed for two-way communication. Rather than attempting to build on these internal NiFi classes, I recommend researching and using the Netty framework [1] to build a datagram service and corresponding Processor. Netty is not trivial, but if you are able to follow the architecture, it provides a good foundation for building network services. Going through the Netty User Guide [1] provides a helpful introduction. The NettyEventServerFactory [2] in the nifi-event-transport module provides some low-level bootstrap support, but still requires wiring in custom Netty Channel Handlers. The Netty examples directory has a number of protocol implementations that are useful for understanding the framework. In particular, the quote-of-the-moment [3] example includes a UDP-based server implementation that could be helpful. Although this is not a simple exercise, investing the time in Netty should provide a much better foundation for integration than the purpose-built components that support the current ListenUDP Processor. Regards, David Handermann [1] https://netty.io/wiki/user-guide-for-4.x.html [2] https://github.com/apache/nifi/blob/main/nifi-extension-bundles/nifi-extension-utils/nifi-event-transport/src/main/java/org/apache/nifi/event/transport/netty/NettyEventServerFactory.java [3] https://github.com/netty/netty/tree/4.1/example/src/main/java/io/netty/example/qotm On Thu, Jun 6, 2024 at 9:26 AM Atul Saroha <atul...@gmail.com> wrote: > > Hi, > > We are overriding ListenUDP to support response on the Datagram channel to > support response event. OnTrigger method calls "postProcess(context, > session, allEvents)" method which we can override. > However, DatagramChannelDispatcher is setting StandardEvent with > ChannelResponder as null. Also we are not able to find any example on how > to create ChannelResponder to send udp responses. > > Kindly help us with code references which we can use to create Datagram > ChannelResponder to send UDP response . > > > Thanks and Regards, > Atul Saroha > > > > On Wed, Jun 5, 2024 at 10:59 AM Atul Saroha <atul...@gmail.com> wrote: > > > Hi, > > > > We are using Nifi to listen the UDP packets. However, we also have to send > > UDP packets as a response back to the calling sender IP and port using the > > same receiver port used in NiFi ListenUDP processor > > We are looking to write a custom processor to send UDP packets back. To do > > this, we need the handle of the Datagram socket which is used in ListenUDP. > > > > Please help us with some code snapshots to use the same datagram socket > > object in our custom processor. > > > > Thanks and Regards, > > Atul Saroha > >