Problem with UDP (Netty4 vs. Mina2) & RabbitMQ (UDP vs. HTTP?)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Problem with UDP (Netty4 vs. Mina2) & RabbitMQ (UDP vs. HTTP?)

Ron Cecchini

Hi, there. I'm experiencing something weird here and I'm desperate for an answer.

I realize this is a long message, but it's only because I'm verbose.

It's a really straight forward setup, so I'm hoping it's just an obvious configuration issue...

I have a simple Server and Client setup for serving and fetching a list of automobiles.

The Client is an "adapter" that translates the returned JSON list to a Protobuf,

and then writes it to a RabbitMQ bus (port 5672).


I implemented 2 Client-Server approaches -- a simple Pull & Push:

1. Pull: The Client uses a Camel timer to do a periodic GET (using Jetty),
         translates the JSON to a Protobuf, writes it to the bus.

2. Push: The Server uses a Camel timer to do a periodic GET (from itself, using Rest),
         writes the data to a UDP port (using Netty4 or Mina2).
         The write is one-way; i.e. no response is expected, so I set 'sync=false'.
         The Client reads from that UDP port (using Netty4 or Mina2),
         translates the JSON to a Protobuf, writes it to the bus.

Here are the 2 problems I am experiencing:


1. The first problem I'm experiencing is that I simply can not get Netty4 to work.

Whenever I use Netty4 in the Client / Server routes below, no data is written at all.

I don't get an error. I simply get nothing. I turned up logging to DEBUG and don't see anything.

I have a post-write log statement in the route ("... AFTER write to UDP ..."), which never prints.

The Client, of course, doesn't budge as it's not seeing anything.

However, when I use Mina2, I *can* write and read.  Data flows, and it all looks good.

So what's up with that?


(let me sneak in another question here)

I determined that the max size of the data I can send with Mina2 is 2048 bytes.

I'm on a Linux/CentOS machine. I looked around, and I think my system max is >> 2048.

So, is Mina setting something under the hood?  And if so, how would I change it?

For Netty, I see that there is a 'sendBufferSize' and 'receiveBufferSize' which default to 65,536 bytes.
But I don't see any similar send/receive sizes for Mina.

(Of course, if I can figure out how to use Netty4, I won't care about Mina...)


2. I can't write to RabbitMQ if I use UDP.

Ok, this one is *really* weird...

You can see my routes below.

When I set up the "pull" model so that the Client does a periodic GET,

I can connect and write to the bus no problem, and the data is fine.

However, when I set up a "push" model so that the Server does a UDP write,

when the Client then gets the data (and remember, this is only when using Mina2),

when I make the same exact call to write to the RabbitMQ bus -- it hangs.

The connection times out after 20 seconds, goes back and gets the next UDP data -- and hangs again.

Over and over...

So what's up with that?

What in the world can the UDP write/read be messing up that interferes with connecting to RabbitMQ??

Thank you so much for any help.  I'm really in a pickle here.

Thank you, thank you.




// NOTE: if uncommented, we're doing a Server push, and the 'timer' in CLIENT is commented out


     .log("*** from direct:udp: BEFORE write to UDP: ${body}")
//     .to("mina2:udp://localhost:40000?sync=false")
//     .to("netty4:udp://localhost:40000?sync=false&udpConnectionlessSending=true")
     .log("*** from direct:udp: AFTER write to UDP: ${body}");

// --------------------------------------------------------------------------------


// NOTE: if uncommented, we're doing a Client pull, and the 'timer' in SERVER is commented out


     .log("*** got something from REST: ${body}")


// from("mina2:udp://localhost:40000?sync=false")
    .log("*** got something from UDP: ${body}")

// convert the automobile JSON to a protobuf Java object
    .process(new AdapterProcessor())

    .log("*** about to write to RabbitMQ ...")