You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by StanZ <st...@eagleriversolutions.com> on 2013/01/25 21:07:28 UTC

HL7 Mina throwing org.apache.mina.filter.codec.ProtocolDecoderException: org.apache.mina.common.BufferDataException

I'm getting the exception below when using the HL7 component and codec 
with mina to receive streamed HL7 messages. The program works find when 
I send it separate messages from a 2nd program using Camel/HL7/Mina and 
receives an ACK successfully. But when testing with our client we're seeing 
this exception. 

The HL7 hex appears to be valid when I reviewed it. It contains the special 
characters for MLLP in the message:     
0x0b (11 decimal) = start marker
0x0d (13 decimal = the \r char) = segment terminators
0x1c (28 decimal) = end 1 marker
0x0d (13 decimal) = end 2 marker

Do I need to set a decoderMaxLineLength like the textline codec? Or am I'm 
missing something else? The only difference I can think of is the client
test 
includes the special characters listed above. And it may be a continuous
stream 
instead of separate messages like my own test program sent successfully. 
Appreciate any help to resolve this issue.

2013-01-25 18:52:08,831 WARN Camel (camel-1) thread #124 - MinaThreadPool
org.apache.camel.component.mina.MinaConsumer$ReceiveHandler -
[/209.149.112.25:7899] EXCEPTION:
org.apache.mina.filter.codec.ProtocolDecoderException:
org.apache.mina.common.BufferDataException: dataLength: 189616968 (Hexdump:
0B 4D 53 48 <...HL7 HEX REMOVED FOR BREVITY...> 0D 1C 0D)
	at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:165)
	at
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
	at
org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
	at
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
	at
org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived(AbstractIoFilterChain.java:499)
	at
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
	at
org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(AbstractIoFilterChain.java:293)
	at
org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.java:228)
	at
org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcessor.java:198)
	at
org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProcessor.java:45)
	at
org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:485)
	at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
	at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.mina.common.BufferDataException: dataLength: 189616968
	at
org.apache.mina.common.ByteBuffer.prefixedDataAvailable(ByteBuffer.java:1631)
	at
org.apache.mina.filter.codec.serialization.ObjectSerializationDecoder.doDecode(ObjectSerializationDecoder.java:88)
	at
org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtocolDecoder.java:133)
	at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:158)
	... 14 more
2013-01-25 18:52:08,832 DEBUG Camel (camel-1) thread #124 - MinaThreadPool
org.apache.camel.component.mina.MinaConsumer - Closing session as an
exception was thrown from MINA
2013-01-25 18:52:08,832 INFO Camel (camel-1) thread #124 - MinaThreadPool
org.apache.camel.component.mina.MinaConsumer$ReceiveHandler -
[/209.149.112.25:7899] CLOSE


Maven dependencies and version:
camel-core  2.10.3
camel-hl7  2.10.3
camel-mina  2.10.3
camel-jms  2.10.3
camel-spring  2.10.3
activemq-camel  5.7.0
activemq-pool  5.7.0
xbean-spring  3.12
hapi-structures-v24  1.2
slf4j-log4j12  1.6.6 

CAMEL ROUTE:
// create CamelContext with HL7 codec registered
SimpleRegistry registry = new SimpleRegistry();
registry.put("hl7codec", new HL7MLLPCodec());
CamelContext inContext = new DefaultCamelContext(registry);

// set up activemq jms
ConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
// add jms queue to camel context
inContext.addComponent("hl7-jms",
JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

// add our route to the CamelContext
try 
{
	inContext.addRoutes(new RouteBuilder()
	{
	    public void configure() 
	    {
		getContext().setHandleFault(true);
		onException(Exception.class).continued(true);
		// route from mina endpoint to jms component
		from("mina:tcp://" + hl7Ip + ":" + hl7Port + "?sync=true&minaLogger=" +
minaLogger)
			.to("hl7-jms:queue:hl7");

		// route from jms component to hl7 message handling bean
		from("hl7-jms:queue:hl7")
			.unmarshal()
			.hl7(true)
				// route based on HL7 version to HL7BusinessLogic endpoint to transform
the HL7 message object
				.choice()
					.when(header("CamelHL7VersionId").isEqualTo("2.4"))
					
.to("bean:com.eagleriversolutions.app.erspoc.hl7v2.ProcessHl7V24Message?method=transformHl7Message")
				.end()
			// send ACK/ NAK to HL7 sender
			.marshal()
			.hl7(true);
	    }
	});

// start the route and let it do its work
inContext.start();



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-Mina-throwing-org-apache-mina-filter-codec-ProtocolDecoderException-org-apache-mina-common-Buffen-tp5726292.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 Mina throwing org.apache.mina.filter.codec.ProtocolDecoderException: org.apache.mina.common.BufferDataException

Posted by StanZ <st...@eagleriversolutions.com>.
I confirmed this did in fact automatically wrap the message in the MLLP
characters. 
Our test was successful in receiving the incoming MLLP HL7 data and your
suggestion helped resolved our issue. 

Thanks Christian! Appreciate the help, especially in the area of HL7/HAPI.

Stanley 



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-Mina-throwing-org-apache-mina-filter-codec-ProtocolDecoderException-org-apache-mina-common-Buffen-tp5726292p5726461.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 Mina throwing org.apache.mina.filter.codec.ProtocolDecoderException: org.apache.mina.common.BufferDataException

Posted by StanZ <st...@eagleriversolutions.com>.
Thanks. I will try this. Would this automatically wrap the HL7 message in the
MLLP starting/ending characters? Or would I have to add these characters to
each message myself for the ACK/NAK response?



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-Mina-throwing-org-apache-mina-filter-codec-ProtocolDecoderException-org-apache-mina-common-Buffen-tp5726292p5726458.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 Mina throwing org.apache.mina.filter.codec.ProtocolDecoderException: org.apache.mina.common.BufferDataException

Posted by Christian Ohr <ch...@gmail.com>.
Hi Stan,

try this ((I assume that hl7lp, hl7Port and minaLogger are properly
set somewhere):

from("mina:tcp://" + hl7Ip + ":" + hl7Port +
"?sync=true&codec=#hl7codec&minaLogger=" + minaLogger)
....

Registering the codec in Camel is not enough; you also need to add it
as parameter to the endpoint URI.
If you then still have problems, enable DEBUG logging for
org.apache.camel.component.hl7.

cheers
Christian


2013/1/25 StanZ <st...@eagleriversolutions.com>:
> We're working in asynchronous mode where they send all of the messages and I
> send the response back as each one is processed using ActveMQ for JMS
> queuing. It worked fine in my own testing but is failing here.
>
> What I don't understand is the length of the message: 189616968 bytes
> The hex for the message in the log is for one ADT message with only 6
> segments. It's pretty small so I'm not sure why or how the buffer length was
> reached?
>
> If the sender sends async a continous stream with each message sparated by
> the MLLP special characters, would the HL7MLLPCODEC cut off each one and
> process separately? It may not be doing that. But then again the log HEX
> only contains one HL7 message with starting and ending characters.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HL7-Mina-throwing-org-apache-mina-filter-codec-ProtocolDecoderException-org-apache-mina-common-Buffen-tp5726292p5726296.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 Mina throwing org.apache.mina.filter.codec.ProtocolDecoderException: org.apache.mina.common.BufferDataException

Posted by StanZ <st...@eagleriversolutions.com>.
We're working in asynchronous mode where they send all of the messages and I
send the response back as each one is processed using ActveMQ for JMS
queuing. It worked fine in my own testing but is failing here. 

What I don't understand is the length of the message: 189616968 bytes
The hex for the message in the log is for one ADT message with only 6
segments. It's pretty small so I'm not sure why or how the buffer length was
reached? 

If the sender sends async a continous stream with each message sparated by
the MLLP special characters, would the HL7MLLPCODEC cut off each one and
process separately? It may not be doing that. But then again the log HEX
only contains one HL7 message with starting and ending characters.



--
View this message in context: http://camel.465427.n5.nabble.com/HL7-Mina-throwing-org-apache-mina-filter-codec-ProtocolDecoderException-org-apache-mina-common-Buffen-tp5726292p5726296.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: HL7 Mina throwing org.apache.mina.filter.codec.ProtocolDecoderException: org.apache.mina.common.BufferDataException

Posted by Christian Ohr <ch...@gmail.com>.
189616968 bytes may be simply too much...

The normal ("original") mode of operation in HL7 is to send one
message, receive the response, send the next message, receive the next
response and so on. Much like HTTP, however, instead of defining the
length of a request somewhere, MLLP delimits a request by the marker
bytes you mentioned.
HL7 does not define a streaming mode, so neither the camel-hl7
component nor HAPI do support it.

cheers
Christian

2013/1/25 StanZ <st...@eagleriversolutions.com>:
> I'm getting the exception below when using the HL7 component and codec
> with mina to receive streamed HL7 messages. The program works find when
> I send it separate messages from a 2nd program using Camel/HL7/Mina and
> receives an ACK successfully. But when testing with our client we're seeing
> this exception.
>
> The HL7 hex appears to be valid when I reviewed it. It contains the special
> characters for MLLP in the message:
> 0x0b (11 decimal) = start marker
> 0x0d (13 decimal = the \r char) = segment terminators
> 0x1c (28 decimal) = end 1 marker
> 0x0d (13 decimal) = end 2 marker
>
> Do I need to set a decoderMaxLineLength like the textline codec? Or am I'm
> missing something else? The only difference I can think of is the client
> test
> includes the special characters listed above. And it may be a continuous
> stream
> instead of separate messages like my own test program sent successfully.
> Appreciate any help to resolve this issue.
>
> 2013-01-25 18:52:08,831 WARN Camel (camel-1) thread #124 - MinaThreadPool
> org.apache.camel.component.mina.MinaConsumer$ReceiveHandler -
> [/209.149.112.25:7899] EXCEPTION:
> org.apache.mina.filter.codec.ProtocolDecoderException:
> org.apache.mina.common.BufferDataException: dataLength: 189616968 (Hexdump:
> 0B 4D 53 48 <...HL7 HEX REMOVED FOR BREVITY...> 0D 1C 0D)
>         at
> org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:165)
>         at
> org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
>         at
> org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilterChain.java:53)
>         at
> org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:648)
>         at
> org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived(AbstractIoFilterChain.java:499)
>         at
> org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:299)
>         at
> org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(AbstractIoFilterChain.java:293)
>         at
> org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.java:228)
>         at
> org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcessor.java:198)
>         at
> org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProcessor.java:45)
>         at
> org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:485)
>         at
> org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
>         at java.lang.Thread.run(Thread.java:722)
> Caused by: org.apache.mina.common.BufferDataException: dataLength: 189616968
>         at
> org.apache.mina.common.ByteBuffer.prefixedDataAvailable(ByteBuffer.java:1631)
>         at
> org.apache.mina.filter.codec.serialization.ObjectSerializationDecoder.doDecode(ObjectSerializationDecoder.java:88)
>         at
> org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtocolDecoder.java:133)
>         at
> org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:158)
>         ... 14 more
> 2013-01-25 18:52:08,832 DEBUG Camel (camel-1) thread #124 - MinaThreadPool
> org.apache.camel.component.mina.MinaConsumer - Closing session as an
> exception was thrown from MINA
> 2013-01-25 18:52:08,832 INFO Camel (camel-1) thread #124 - MinaThreadPool
> org.apache.camel.component.mina.MinaConsumer$ReceiveHandler -
> [/209.149.112.25:7899] CLOSE
>
>
> Maven dependencies and version:
> camel-core  2.10.3
> camel-hl7  2.10.3
> camel-mina  2.10.3
> camel-jms  2.10.3
> camel-spring  2.10.3
> activemq-camel  5.7.0
> activemq-pool  5.7.0
> xbean-spring  3.12
> hapi-structures-v24  1.2
> slf4j-log4j12  1.6.6
>
> CAMEL ROUTE:
> // create CamelContext with HL7 codec registered
> SimpleRegistry registry = new SimpleRegistry();
> registry.put("hl7codec", new HL7MLLPCodec());
> CamelContext inContext = new DefaultCamelContext(registry);
>
> // set up activemq jms
> ConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
> // add jms queue to camel context
> inContext.addComponent("hl7-jms",
> JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
>
> // add our route to the CamelContext
> try
> {
>         inContext.addRoutes(new RouteBuilder()
>         {
>             public void configure()
>             {
>                 getContext().setHandleFault(true);
>                 onException(Exception.class).continued(true);
>                 // route from mina endpoint to jms component
>                 from("mina:tcp://" + hl7Ip + ":" + hl7Port + "?sync=true&minaLogger=" +
> minaLogger)
>                         .to("hl7-jms:queue:hl7");
>
>                 // route from jms component to hl7 message handling bean
>                 from("hl7-jms:queue:hl7")
>                         .unmarshal()
>                         .hl7(true)
>                                 // route based on HL7 version to HL7BusinessLogic endpoint to transform
> the HL7 message object
>                                 .choice()
>                                         .when(header("CamelHL7VersionId").isEqualTo("2.4"))
>
> .to("bean:com.eagleriversolutions.app.erspoc.hl7v2.ProcessHl7V24Message?method=transformHl7Message")
>                                 .end()
>                         // send ACK/ NAK to HL7 sender
>                         .marshal()
>                         .hl7(true);
>             }
>         });
>
> // start the route and let it do its work
> inContext.start();
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/HL7-Mina-throwing-org-apache-mina-filter-codec-ProtocolDecoderException-org-apache-mina-common-Buffen-tp5726292.html
> Sent from the Camel - Users mailing list archive at Nabble.com.