I just started doing some testing on the mina work with some real data
and I ran into a few issues.
I was continuing to have problems with the MINA codec so dug in to see
what was happening.
First thing I saw looks like just a simple typo. In the
configureDataGramCodecFactory method on the MinaComponent, the last
line adds a new TextLineCodecFactory instead of the codecFactory
created above. This was easily fixed by changing the last line.
Then I ran into issues with it being able to convert from byte[] to
ByteBuffer, none of the built in converters know how to perform that
conversion.That's probably pretty straight forward to create a
converter to handle it. To continue my testing I just performed the
conversion in the MinaComponent, but that's not the right way to do it
long term.
I needed to have multicast support so I ended up writing a new
component that mirrors what the mina component does, but does not use
nio. I'm not done with it yet, but if your interested I could
contribute it when it is complete.
- James
On Nov 16, 2007, at 6:05 AM, James Strachan wrote:
On 14/11/2007, James Chamberlain <[EMAIL PROTECTED]> wrote:
The test case is working for me from home. The caveat is that at
home I
run on Linux and use jdk 1.6.x and before I was running tests at
work on
OSX with 1.5.0_13.
FWIW I'm using OS X on 1.5 too
The problem is that my real cases still don't seem to
work properly. If I took your test case below and removed the portion
that feeds the udp traffic from the file and tried to feed it myself
from another process that is not working for me. Below is some
example
UDP code that I was using to drive it:
DatagramSocket socket = new DatagramSocket();
byte buffer[] = new byte[1500];
buffer = "TEST_STRING".getBytes();
InetAddress address = InetAddress.getByName("127.0.0.1");
DatagramPacket packet = new DatagramPacket(buffer,
buffer.length, address, 9123);
while(true) {
socket.send(packet);
Thread.sleep(2000);
}
Camel never seems to recognize those udp messages. Shouldn't this
work
or am I using it in an improper way?
Great catch! This had me stuck a little while!
It turned out mostly to be that the default codec's (textline and
serialization) don't work that well on UDP/multicast. So I've modified
the MinaComponent to by default use a simple ByteBuffer based codec -
so that the ByteBuffer is currently visible to the consumer in Camel.
I've created a test case pretty much as you describe which now seems
to be working fine. I raised this JIRA to track the issues...
https://issues.apache.org/activemq/browse/CAMEL-225
I've just commit a fix for this, so hopefully using trunk you'll be
able to use it fine to consume UDP messages.
I've also added a more flexible way of configuring the codec if you
wish to supply your own implementation via the registry etc...
http://cwiki.apache.org/CAMEL/mina.html
--
James
-------
http://macstrac.blogspot.com/
Open Source SOA
http://open.iona.com