Skip to main content
Solved

Connector which discards empty messages

  • June 7, 2024
  • 3 replies
  • 114 views

Forum|alt.badge.img+1

Is there a way to discard an empty message?

I have a misbehaving HTTP endpoint which is causing me to get intermittent empty messages going through the flow.

These end up clogging up the logs.

It would be good if I could detect empty messages in the flow and discard them before they affect anything downstream

Best answer by lohith

If the REST connector produces an empty file without any contents, you can use the fileread() operation to check if the file contains content or not with the following script. You can then branch them appropriately using a branch connector based on the header:

<arc:set attr="file.file" value="[filepath]" />
<arc:call op="fileRead" in="file" out="result" >
<arc:if exp="[result.file:data | equals('')]">
<arc:set attr="output.header:Empty" value="Yes" />
<arc:else>
<arc:set attr="output.header:Empty" value="No" />
</arc:else>
</arc:if>
</arc:call>
<arc:set attr="output.FilePath" value="[FilePath]" />
<arc:push item="output" />

Additionally, you can write the script based on file size as well.

This topic has been closed for replies.

3 replies

James B
Forum|alt.badge.img
  • Employee
  • June 7, 2024

There are generally two approaches here:​​​​​​

 

  1. If you have a connector that produces files that you don’t do any processing with, you can connect that connector to a Script connector, and if you don’t create any code in that Script, it will dispose of that file (technically, it’s processing them but doing nothing).
  2. If you’re talking about the REST connector in particular, in later releases of CData Arc, you can set the Advanced->Output Behavior to None to not output a response to the Receive folder

I think Russell needs a script that checks the file length.
If length > 0 continue, if length = 0 ignore and/or send to dead-end-connector.

 


lohith
  • Employee
  • Answer
  • June 10, 2024

If the REST connector produces an empty file without any contents, you can use the fileread() operation to check if the file contains content or not with the following script. You can then branch them appropriately using a branch connector based on the header:

<arc:set attr="file.file" value="[filepath]" />
<arc:call op="fileRead" in="file" out="result" >
<arc:if exp="[result.file:data | equals('')]">
<arc:set attr="output.header:Empty" value="Yes" />
<arc:else>
<arc:set attr="output.header:Empty" value="No" />
</arc:else>
</arc:if>
</arc:call>
<arc:set attr="output.FilePath" value="[FilePath]" />
<arc:push item="output" />

Additionally, you can write the script based on file size as well.