You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by milltj <mi...@drop-tank.com> on 2013/08/13 18:10:07 UTC
Mina Synchronous Communication
I have a client application that sends messages via a socket. For each
message it sends it requires a response. I have setup the Mina2 component
with a custom decoder to receive the messages. This works when I have the
following in my camel-context.xml
<camel:route>
<camel:from uri="mina2:tcp://10.5.60.60:9000?codec=#myDecoder"
/>
<camel:bean ref="OutputProcessor"/>
</camel:route>
However, if I change the from route to include sync=true I get an error.
<camel:route>
<camel:from
uri="mina2:tcp://10.5.60.60:9000?sync=true;codec=#myDecoder" />
<camel:bean ref="OutputProcessor"/>
</camel:route>
Error:
org.apache.mina.filter.codec.ProtocolDecoderException:
org.apache.mina.core.buffer.BufferDataException: dataLength: 1347375948
Not sure why exactly it is doing this. Am I doing something wrong?
- Tim
--
View this message in context: http://camel.465427.n5.nabble.com/Mina-Synchronous-Communication-tp5737223.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Mina BufferDataException when using disconnectOnNoReply option
Posted by Christian Müller <ch...@gmail.com>.
Good catch!
mina2:tcp://10.5.60.60:9000?disconnectOnNoReply=false;codec=#gilbarcoDecodershould
be mina2:tcp://
10.5.60.60:9000?disconnectOnNoReply=false&codec=#gilbarcoDecoder
Best,
Christian
-----------------
Software Integration Specialist
Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html
https://www.linkedin.com/pub/christian-mueller/11/551/642
On Fri, Aug 23, 2013 at 12:19 AM, Pontus Ullgren <ul...@gmail.com> wrote:
> I have never used the mina component so I could be out on thin ice here.
> But I am not sure about the ';' to separate the parameters. Should it not
> be '&'?
>
> Best regards
> Pontus
> Den 21 aug 2013 17:58 skrev "milltj" <mi...@drop-tank.com>:
>
> > Ok, So I decided to go back to the drawing board and decided to run some
> > tests.
> >
> > First, I implemented a very simple decoder that contains the following
> > code:
> >
> > @Override
> > protected boolean doDecode(IoSession is, IoBuffer ib,
> > ProtocolDecoderOutput pdo) throws Exception {
> >
> > System.out.println("IoBuffer hasRemaining: " + ib.hasRemaining());
> > System.out.println("IoBuffer remaining: " + ib.remaining());
> > byte[] data = new byte[ib.remaining()];
> > ib.get(data);
> > System.out.println("IoBuffer read: " + new String(data));
> >
> > return true;
> >
> > }
> >
> > Then I implemented my route in the camel-context as...
> >
> > <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
> > <camel:route>
> > <camel:from
> > uri="mina2:tcp://10.5.60.60:9000?codec=#gilbarcoDecoder" />
> > <camel:bean ref="testBean"/>
> > </camel:route>
> > </camel:camelContext>
> >
> > When I run this it will successfully read the input and output the
> received
> > message to the console. However when I change the route to..
> >
> > <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
> > <camel:route>
> > <camel:from
> > uri="mina2:tcp://
> > 10.5.60.60:9000?disconnectOnNoReply=false;codec=#gilbarcoDecoder"
> > />
> > <camel:bean ref="testBean"/>
> > </camel:route>
> > </camel:camelContext>
> >
> > Then I get the following error message and it never calls the doDecode
> > method..
> > org.apache.camel.CamelException:
> > org.apache.mina.filter.codec.ProtocolDecoderException:
> > org.apache.mina.core.buffer.BufferDataException: dataLength: 1347375948
> > (Hexdump: REMOVED FOR BREVITY)
> > at
> >
> >
> org.apache.camel.component.mina2.Mina2Consumer$ReceiveHandler.exceptionCaught(Mina2Consumer.java:312)
> > at
> >
> >
> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.exceptionCaught(DefaultIoFilterChain.java:672)
> > at
> >
> >
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextExceptionCaught(DefaultIoFilterChain.java:461)
> > at
> >
> >
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1100(DefaultIoFilterChain.java:47)
> > at
> >
> >
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.exceptionCaught(DefaultIoFilterChain.java:760)
> > at
> >
> org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:93)
> > at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)
> > at
> >
> >
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:769)
> > at
> >
> >
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:761)
> > at
> >
> >
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:703)
> > at java.lang.Thread.run(Thread.java:722)
> >
> >
> > Not sure exactly why this is occurring. Is it the way I have configured
> my
> > route? Or is this a bug in the Mina2 2.11.1 component?
> >
> > - Tim
> >
> >
> >
> > --
> > View this message in context:
> >
> http://camel.465427.n5.nabble.com/Mina-Synchronous-Communication-tp5737223p5737692.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
Re: disconnectOnNoReply not working...
Posted by "itsavvy.ankur" <ia...@gmail.com>.
milltj wrote
> Pontus:
>
> You are correct. I realized it was incorrect it should be...
>
>
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
>
>
> <camel:route>
>
>
> <camel:from uri="mina2:tcp://
> 10.5.60.60:9000?disconnectOnNoReply=false&codec=#gilbarcoDecoder"
> />
>
>
> <camel:bean ref="testBean"/>
>
>
> </camel:route>
>
>
> </camel:camelContext>
> That corrects the datalength error, but unfortunately it is still
> disconnecting when a response is not sent back to the client.
Hi, did you manage to get around your problem of the disconnecting when no
response is sent ? I think I have run into a similar issue where some
messages(requests) in my protocol do not have a response back. More info
here
<http://camel.465427.n5.nabble.com/Apache-Camel-Mina2-ExchangePattern-td5765184.html>
--
View this message in context: http://camel.465427.n5.nabble.com/Mina-Synchronous-Communication-tp5737223p5765257.html
Sent from the Camel - Users mailing list archive at Nabble.com.
disconnectOnNoReply not working...
Posted by milltj <mi...@drop-tank.com>.
Pontus:
You are correct. I realized it was incorrect it should be...
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:route>
<camel:from uri="mina2:tcp://
10.5.60.60:9000?disconnectOnNoReply=false<b>&*codec=#gilbarcoDecoder"
/>
<camel:bean ref="testBean"/>
</camel:route>
</camel:camelContext>
That corrects the datalength error, but unfortunately it is still
disconnecting when a response is not sent back to the client.
--
View this message in context: http://camel.465427.n5.nabble.com/Mina-Synchronous-Communication-tp5737223p5737792.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Mina BufferDataException when using disconnectOnNoReply option
Posted by Pontus Ullgren <ul...@gmail.com>.
I have never used the mina component so I could be out on thin ice here.
But I am not sure about the ';' to separate the parameters. Should it not
be '&'?
Best regards
Pontus
Den 21 aug 2013 17:58 skrev "milltj" <mi...@drop-tank.com>:
> Ok, So I decided to go back to the drawing board and decided to run some
> tests.
>
> First, I implemented a very simple decoder that contains the following
> code:
>
> @Override
> protected boolean doDecode(IoSession is, IoBuffer ib,
> ProtocolDecoderOutput pdo) throws Exception {
>
> System.out.println("IoBuffer hasRemaining: " + ib.hasRemaining());
> System.out.println("IoBuffer remaining: " + ib.remaining());
> byte[] data = new byte[ib.remaining()];
> ib.get(data);
> System.out.println("IoBuffer read: " + new String(data));
>
> return true;
>
> }
>
> Then I implemented my route in the camel-context as...
>
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
> <camel:route>
> <camel:from
> uri="mina2:tcp://10.5.60.60:9000?codec=#gilbarcoDecoder" />
> <camel:bean ref="testBean"/>
> </camel:route>
> </camel:camelContext>
>
> When I run this it will successfully read the input and output the received
> message to the console. However when I change the route to..
>
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
> <camel:route>
> <camel:from
> uri="mina2:tcp://
> 10.5.60.60:9000?disconnectOnNoReply=false;codec=#gilbarcoDecoder"
> />
> <camel:bean ref="testBean"/>
> </camel:route>
> </camel:camelContext>
>
> Then I get the following error message and it never calls the doDecode
> method..
> org.apache.camel.CamelException:
> org.apache.mina.filter.codec.ProtocolDecoderException:
> org.apache.mina.core.buffer.BufferDataException: dataLength: 1347375948
> (Hexdump: REMOVED FOR BREVITY)
> at
>
> org.apache.camel.component.mina2.Mina2Consumer$ReceiveHandler.exceptionCaught(Mina2Consumer.java:312)
> at
>
> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.exceptionCaught(DefaultIoFilterChain.java:672)
> at
>
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextExceptionCaught(DefaultIoFilterChain.java:461)
> at
>
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1100(DefaultIoFilterChain.java:47)
> at
>
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.exceptionCaught(DefaultIoFilterChain.java:760)
> at
> org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:93)
> at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)
> at
>
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:769)
> at
>
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:761)
> at
>
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:703)
> at java.lang.Thread.run(Thread.java:722)
>
>
> Not sure exactly why this is occurring. Is it the way I have configured my
> route? Or is this a bug in the Mina2 2.11.1 component?
>
> - Tim
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Mina-Synchronous-Communication-tp5737223p5737692.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Mina BufferDataException when using disconnectOnNoReply option
Posted by milltj <mi...@drop-tank.com>.
Ok, So I decided to go back to the drawing board and decided to run some
tests.
First, I implemented a very simple decoder that contains the following code:
@Override
protected boolean doDecode(IoSession is, IoBuffer ib,
ProtocolDecoderOutput pdo) throws Exception {
System.out.println("IoBuffer hasRemaining: " + ib.hasRemaining());
System.out.println("IoBuffer remaining: " + ib.remaining());
byte[] data = new byte[ib.remaining()];
ib.get(data);
System.out.println("IoBuffer read: " + new String(data));
return true;
}
Then I implemented my route in the camel-context as...
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:route>
<camel:from
uri="mina2:tcp://10.5.60.60:9000?codec=#gilbarcoDecoder" />
<camel:bean ref="testBean"/>
</camel:route>
</camel:camelContext>
When I run this it will successfully read the input and output the received
message to the console. However when I change the route to..
<camel:camelContext xmlns="http://camel.apache.org/schema/spring">
<camel:route>
<camel:from
uri="mina2:tcp://10.5.60.60:9000?disconnectOnNoReply=false;codec=#gilbarcoDecoder"
/>
<camel:bean ref="testBean"/>
</camel:route>
</camel:camelContext>
Then I get the following error message and it never calls the doDecode
method..
org.apache.camel.CamelException:
org.apache.mina.filter.codec.ProtocolDecoderException:
org.apache.mina.core.buffer.BufferDataException: dataLength: 1347375948
(Hexdump: REMOVED FOR BREVITY)
at
org.apache.camel.component.mina2.Mina2Consumer$ReceiveHandler.exceptionCaught(Mina2Consumer.java:312)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.exceptionCaught(DefaultIoFilterChain.java:672)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextExceptionCaught(DefaultIoFilterChain.java:461)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1100(DefaultIoFilterChain.java:47)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.exceptionCaught(DefaultIoFilterChain.java:760)
at
org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:93)
at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)
at
org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:769)
at
org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:761)
at
org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:703)
at java.lang.Thread.run(Thread.java:722)
Not sure exactly why this is occurring. Is it the way I have configured my
route? Or is this a bug in the Mina2 2.11.1 component?
- Tim
--
View this message in context: http://camel.465427.n5.nabble.com/Mina-Synchronous-Communication-tp5737223p5737692.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Mina Synchronous Communication
Posted by Willem jiang <wi...@gmail.com>.
From the stack trace, it looks like the decoder cannot interpret the data length rightly.
Can you double check it with your application?
--
Willem Jiang
Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem
On Wednesday, August 21, 2013 at 12:55 AM, milltj wrote:
> I am currently using Mina2 V2.11.1.
>
> My decoder looks like....
>
> @Override
> protected boolean doDecode(IoSession is, IoBuffer ib,
> ProtocolDecoderOutput pdo) throws Exception {
> int headerSize=28;
> byte[] header = new byte[headerSize];
> byte[] xmlBuffer = null;
> byte[] fullMessage = null;
>
> int xmlLength = -1;
> ib.get(header);
>
> xmlLength = convertBytesToInt(Arrays.copyOfRange(header, 16, 20));
>
> xmlBuffer = new byte[xmlLength];
> ib.get(xmlBuffer);
>
> pdo.write(xmlc.convertXmlToObject(xmlBuffer));
>
> return true;
>
> }
>
> I am finding that I get that error message no matter what options I add to
> the url. I discovered that my clients have a number of different requests
> that will be sent, some require a response, others do not. When I don't
> return a response it closes the connection, which I do not want, I want the
> connection to remain open at all times. So I tried to set the url to
>
>
> <camel:from
> uri="mina2:tcp://10.5.60.60:9000?disconnectOnNoReply=false;codec=#gilbarcoDecoder"
> />
>
> But I still get the same error.
> Error:
> org.apache.mina.filter.codec.ProtocolDecoderException:
> org.apache.mina.core.buffer.BufferDataException: dataLength: 1347375948
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Mina-Synchronous-Communication-tp5737223p5737612.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
Re: Mina Synchronous Communication
Posted by milltj <mi...@drop-tank.com>.
I am currently using Mina2 V2.11.1.
My decoder looks like....
@Override
protected boolean doDecode(IoSession is, IoBuffer ib,
ProtocolDecoderOutput pdo) throws Exception {
int headerSize=28;
byte[] header = new byte[headerSize];
byte[] xmlBuffer = null;
byte[] fullMessage = null;
int xmlLength = -1;
ib.get(header);
xmlLength = convertBytesToInt(Arrays.copyOfRange(header, 16, 20));
xmlBuffer = new byte[xmlLength];
ib.get(xmlBuffer);
pdo.write(xmlc.convertXmlToObject(xmlBuffer));
return true;
}
I am finding that I get that error message no matter what options I add to
the url. I discovered that my clients have a number of different requests
that will be sent, some require a response, others do not. When I don't
return a response it closes the connection, which I do not want, I want the
connection to remain open at all times. So I tried to set the url to
<camel:from
uri="mina2:tcp://10.5.60.60:9000?disconnectOnNoReply=false;codec=#gilbarcoDecoder"
/>
But I still get the same error.
Error:
org.apache.mina.filter.codec.ProtocolDecoderException:
org.apache.mina.core.buffer.BufferDataException: dataLength: 1347375948
--
View this message in context: http://camel.465427.n5.nabble.com/Mina-Synchronous-Communication-tp5737223p5737612.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Mina Synchronous Communication
Posted by Christian Müller <ch...@gmail.com>.
Can you share your decoder?
What version do you use?
Best,
Christian
Am 14.08.2013 08:14 schrieb "milltj" <mi...@drop-tank.com>:
> I have a client application that sends messages via a socket. For each
> message it sends it requires a response. I have setup the Mina2 component
> with a custom decoder to receive the messages. This works when I have the
> following in my camel-context.xml
>
> <camel:route>
> <camel:from uri="mina2:tcp://10.5.60.60:9000?codec=#myDecoder"
> />
> <camel:bean ref="OutputProcessor"/>
> </camel:route>
>
> However, if I change the from route to include sync=true I get an error.
>
> <camel:route>
> <camel:from
> uri="mina2:tcp://10.5.60.60:9000?sync=true;codec=#myDecoder" />
> <camel:bean ref="OutputProcessor"/>
> </camel:route>
>
>
> Error:
> org.apache.mina.filter.codec.ProtocolDecoderException:
> org.apache.mina.core.buffer.BufferDataException: dataLength: 1347375948
>
> Not sure why exactly it is doing this. Am I doing something wrong?
>
> - Tim
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Mina-Synchronous-Communication-tp5737223.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>