hapifhir / hapi-hl7v2

277 stars 138 forks source link

Thread blocking on DefaultEscaping class while retrieving the String #101

Closed namila007 closed 10 months ago

namila007 commented 11 months ago

Hi, I'm using Springboot Camel Hl7 for my application (with netty listener). When I did Jprofiler, I found a blocking method call in ca.uhn.hl7v2.parser.DefaultEscaping. As in the image below, the most blocked method is Synchronized LinkedHashmap ; image

private static Map<EncodingCharacters, EncLookup> variousEncChars = Collections.synchronizedMap(new LinkedHashMap
        <EncodingCharacters, EncLookup>(5, 0.75f, true)

For now, I have introduced a new encoder with ConcurrentMap and attached it with every message as follows;

exchange.getIn().getBody(ORU_R01.class).getParser().getParserConfiguration().setEscaping(customeHl7Escaping)

Is there any way to define a new DefaultHapiContext within the app and use it as a default context? or what is the right way to implement non-blocking encoder;

namila007 commented 10 months ago

for this i created a new escape class based on DefaultEscaping with LinkedHashmap, when there is a put ; i simply synchronize the map and double check the valuse (like double checked singleton) before adding the escape chars to the map