It's hard to tell what's wrong with your code, as it's not complete and
it won't build at all due to missing declarations of variabe.
Anyway. The doDecode method returns true when the message has been fully
decoded, and false if not. If you get a false, then the following
decoder won't be called at all.
I question the need for you to use CumulativeProtocolDecoder, which will
wait until they have received all the data needed to actually decode a
message...
I advise you to keep it simple as possible.
Le 12/31/13 7:48 AM, Hardik Kubavat a écrit :
> Hii
>
> System.out.println("THIS IS FIRST DECODER");
> out.setAutoExpand(true);
> Listener l = (Listener)is.getAttribute("listener");
> byte[] bytes = new byte[ib.limit()];
> ib.get(bytes);
> if(l.getMessageType().equals("HL7"))
> {
> String s = new String(bytes);
> String hexString = toHexString(bytes);
> if(hexString.trim().startsWith("0B"))
> {
> if(str.equals(""))
> {
> System.out.println("START");
> str=s;
> }else{
> System.out.println("THERE IS BAD MESSAGE");
> str=s;
> }
> }else if(!hexString.trim().startsWith("0B")){
> if(str.equals(""))
> {
> System.out.println("OTHER THAN HL7");
> out.put(bytes);
> out.flip();
> pdo.write(out);
> return false;
> }else{
> System.out.println("MIDDLE");
> str = str + s;
> }
> }
> if(hexString.trim().endsWith("0D")){
> if(!str.equals(""))
> {
> System.out.println("END");
> pdo.write(str);
> str="";
> return false;
> }
> }
> return true;//or false
> }
>
> This is the code for my first decoder. If it is other than HL7 then I
> am forwarding IoBuffer than protocol2 is executed
> my question is what is indicate by return type of doDocode
>
> In This example if return true or false it has same behavior
>
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com