Sorry about that, I should have tested it before posting. A ruby instance variable is specific to the filter instance, so you cannot set it in one and use it in the other. You have two options. You can use a class variable instead of an instance variable.
if [ID2] == "000003" {
ruby { code => "@@save_the_date = event.get('DATE_BATCH')" }
} else {
ruby { code => "event.set('DATE_BATCH', @@save_the_date)" }
}
Or you can do everything in a single filter instance
ruby {
code => "
if event.get('ID2') == '000003'
@save_the_date = event.get('DATE_BATCH')
else
event.set('DATE_BATCH', @save_the_date)
end
"
}
Note that this kind of thing can be fragile. It assumes lines are processed in order. That is why you are restricted to a single pipeline worker. But note that with the new execution engine in 6.3.0 that is no longer true even for a single worker -- stuff gets re-ordered.