Parsing long message
See original GitHub issueIf I attempt to parse a long message (this one in particular contains large amounts of Base64 encoded data in the form of GIF/PNG/PDF/JPG/TIF, nothing breaks but the parsing is incomplete.
I’ve tried “cheating” a bit and breaking up the message to circumvent any internal length restriction that’s happening during parsing like so:
public bool ParseAllMessage(HL7.Dotnetcore.Message message)
{
try
{
var hl7 = message.HL7Message;
var segments = hl7.Split('\r').ToList();
List<string> hl7SubBlocks = new List<string>();
int counter = 0;
string currentBlock = "";
string msh = "";
List<string> waitingSegments = new List<string>() { "MSH", "MSA", "QAK", "ERQ", "PID", "PV1", "ORC", "OBR", "ZBR", "BLG", "OBX", "ZBX", "NTE", "ZNT" };
foreach (var segment in segments)
{
if (segment.Substring(0, 3) == "MSH") msh = segment;
if (waitingSegments.Contains(segment.Substring(0, 3))) waitingSegments.Remove(segment.Substring(0, 3));
currentBlock += segment + '\r';
if (segment.Substring(0, 3) == "BLG" && waitingSegments.Count == 0) counter++;
if (counter >= 5)
{
hl7SubBlocks.Add(currentBlock);
currentBlock = "";
counter = 0;
}
}
foreach (var hl7SubBlock in hl7SubBlocks)
{
HL7.Dotnetcore.Message tmpMessage = new HL7.Dotnetcore.Message(msh+'\r'+hl7SubBlock);
tmpMessage.ParseMessage();
foreach (var innerSegment in tmpMessage.Segments())
{
message.Segments(innerSegment.Name).Add(innerSegment);
}
}
return true;
}
catch (Exception ex)
{
return false;
}
}
But this doesn’t have the desired effect. I can’t just add the segment data in this way. Is there an internal limit being placed on the parse method? I don’t see it in your code, though stepping through it is in the next step.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7
Top Results From Across the Web
Is this an efficient way to parse a large string in FIX format?
My only suggestion at first glance is to replace string concatenations that are done in loops, such as TagString = TagString + ...
Read more >String to long in Java
The correct way to convert a String to long in Java is to use the parseLong(String x) method of the Long wrapper class....
Read more >Java Long parseLong() Method
The parseLong() method of Java Long class is used to parse the CharSequence argument as a signed long with the specified radix ,...
Read more >Parse a Message
With LogViewPlus log entry messages are parsed separately from log entries. Parsing a log entry message allows you to extract and display the...
Read more >Parsing strategies
Partial parsing (also referred to as On-demand parsing ) improves the performance of message flows, and reduces the amount of parsed data that ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just run into possibly similar issue. The fix was to change to RegexOptions.Singleline:
It is now published in NuGet.org as version 2.7.0