Ron,

  I think there is room for improvement there. I opened
https://issues.apache.org/jira/browse/CAMEL-12813 to setup a proposal in
this respect.
Would you like to have a try with a contribution
https://github.com/apache/camel/blob/master/CONTRIBUTING.md ? Or, I could
take over if you prefer.

Alex

On Fri, Sep 14, 2018 at 9:50 PM Ron Cecchini <roncecch...@comcast.net>
wrote:

>
> Ok, last post.  But I just fixed the route, sans "hack.  And since I've
> seen lots of other people having problems with Netty, maybe this will help
> them.
>
>
> Instead of the transform().method(...) call, just do:
>
>
> .convertBodyTo(String.class, “UTF-8”)
>
> Problem solved.
>
> (Holy cow did this take me too long to figure out...)
>
>
> > On September 14, 2018 at 3:38 PM Ron Cecchini wrote:
> >
> >
> >     Hi, Alex. Thank you you for your help.
> >
> >
> >     I had read all of those pages (amongst the million or so I
> scanned...) but your comment made it clearer as to what's possibly going on.
> >
> >
> >     As it turned out, earlier today I accidentally stumbled upon a
> hackish solution (think: Infinite Monkey Theorem) which fixed my Netty4/UDP
> write problems.
> >
> >
> >     I didn't have to use any encoders/decoders. (And OMG, that was a
> Dante-esque trip through Hell ... no offense, Claus; I love Camel).
> >
> >
> >     I just had to do this one transform() (see below) ... which, I'm
> still not sure what's going on, as the bean's method is simply returning
> the passed in JSON string as a String ... and that was all that was needed.
> I guess the method is setting something on the Exchange's OutBody (?) that
> is making everything kosher for Netty?
> >
> >
> >     Of course, a String is serializable, but why couldn't I just go
> directly from the endpoint (which is already returning a string
> representing a JSON array) to Netty?
> >
> >
> >     Anyway, here's the full text of my Server's route builder, along
> with the hack.
> >
> >
> >     I would love to hear how this fixed my route!
> >
> >
> >     Thank you again.
> >
> >
> >     ---------------------------------------------
> >
> >
> >     @Component
> >     public class Route extends RouteBuilder
> >     {
> >     @Override
> >     public void configure () throws Exception
> >     {
> >     restConfiguration()
> >     .host("localhost").port(8080)
> >     .bindingMode(RestBindingMode.json);
> >
> >     from("timer:autos?period={{timer.period}}")
> >     .streamCaching()
> >     .to("rest:get:auto/list")
> >     .to("direct:udp");
> >
> >     from("direct:udp")
> >     .log("*** BEFORE write to UDP: ${body}")
> >     .transform().method("myBean", "foo") // XXX: this one line hack
> fixed it
> >
>  .to("netty4:udp://localhost:40000?udpConnectionlessSending=true&sync=false")
> >     .log("*** AFTER write to UDP: ${body}");
> >     }
> >
> >     @Component("myBean")
> >     public class Encoder
> >     {
> >     public String foo (String val) {
> >     return val;
> >     }
> >     }
> >     }
> >
> >
> >     ---------------------------------------------
> >
> >         > > On September 14, 2018 at 1:23 PM Alex Dettinger wrote:
> > >
> > >
> > >         Hi Ron,
> > >
> > >         By default, camel-netty4 includes default codecs based on java
> > >         serialization. So, it could be that your payload is NOT
> Serializable.
> > >         You would then need to configure codecs matching your case.
> > >
> > >         You may find below links of interest:
> > >
> https://github.com/apache/camel/blob/master/components/camel-netty4/src/main/docs/netty4-component.adoc#using-multiple-codecs
> > >
> https://github.com/apache/camel/blob/master/components/camel-netty4/src/test/resources/org/apache/camel/component/netty4/multiple-codecs.xml
> > >
> https://github.com/apache/camel/blob/master/components/camel-ganglia/src/test/java/org/apache/camel/component/ganglia/GangliaProtocolV31CamelTest.java#L214-L257
> > >
> > >         Hope this help,
> > >         Alex
> > >
> > >         On Fri, Sep 14, 2018 at 12:26 AM Ron Cecchini
> > >         wrote:
> > >         > > I'll try a shorter version of my question:
> > >
> > >             > > > Why does this work:
> > > >
> > > >
> > > >             .to("mina2:udp://localhost:40000?sync=false")
> > > >
> > > >             ...
> > > >
> > > >             from("mina2:udp://localhost:40000?sync=false")
> > > >
> > > >
> > > >             and this doesn't work:
> > > >
> > > >
> > > >             .to("netty4:udp://localhost:40000?sync=false")
> > > >
> > > >             ...
> > > >
> > > >             from("netty4:udp://localhost:40000?sync=false")
> > > >
> > > >
> > > >             In particular, the netty4:udp *write* fails.
> > > >
> > > >
> > > >             Thanks.
> > > >
> > > >
> > > >             p.s. I found something about using the 'encoder/decoder'
> params. But I
> > > >             don't see anything in the docs or book about it being
> necessary. Is it
> > > >             required? All I'm trying to do is write some JSON I got
> from a Rest call.
> > > >             >
> > > >
> > > >         > >
> > >     >
>

Reply via email to