Skip to content

Commit

Permalink
MessageProcessors must be instantiated per processing thread (#2231)
Browse files Browse the repository at this point in the history
When introducing the MessageProcessor interface, the processing threads accidentally shared the instances (and by induction the MessageFilter instances as well).
That posed no problem for most of the filters, because they do not rely on shared state, but the Drools filter does and could skip messages (because of Drools itself returning early)

This change uses a Provider to get the OrderedMessageProcessor instances explicitly and those do not get shared across threads.

Fixes #2119, fixes #2188

(cherry picked from commit 507814a)
  • Loading branch information
kroepke authored and bernd committed May 17, 2016
1 parent d2f071d commit ca59a00
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -16,14 +16,15 @@
*/
package org.graylog2.messageprocessors;

import com.google.inject.Scopes;
import org.graylog2.plugin.PluginModule;

public class MessageProcessorModule extends PluginModule {
@Override
protected void configure() {
addMessageProcessor(MessageFilterChainProcessor.class, MessageFilterChainProcessor.Descriptor.class);

bind(OrderedMessageProcessors.class).asEagerSingleton();
// must not be a singleton, because each thread should get an isolated copy of the processors
bind(OrderedMessageProcessors.class).in(Scopes.NO_SCOPE);
}

}

0 comments on commit ca59a00

Please sign in to comment.