Hi,

You should use the users mailing group, since the intention of this group is to 
discuss the further development on mina itself.

Seems like you need different decoders for different messages, so try using a 
MessageDecoder. You can specify multiple MessageDecoders at a 
DemuxingProtocolDecoder, that iterates through the decodable methods of the 
MDs, until any of them says OK. Then decode is called at that MD.

Some annotations to your code inside..

> Hardik Kubavat [mailto:[email protected]] wrote:
>
> 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);

At least provide a charset, since the Charset used depends on the system 
(German system -> ISO-8859-15, US System -> US-ASCII, most linux systems -> 
utf-8)

>              String hexString = toHexString(bytes);
>              if(hexString.trim().startsWith("0B"))

Are you formatting your bytes as a hex string just to ask for a hex value? why 
don't you ask for:
if (bytes.lentgh > 0 && bytes[0] != 0x0B)

>              {
>                  if(str.equals(""))

I would recommend str.isEmpty(), just for the looks

>                  {
>                      System.out.println("START");
>                      str=s;
>                  }else{
>                      System.out.println("THERE IS BAD MESSAGE");
>                      str=s;
>                  }
>              }else if(!hexString.trim().startsWith("0B")){

You ask the exact negative from the if above, so it will return true all the 
time. the if from the else-if is completly superflous

>                  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
>



Reply via email to