Created
August 1, 2013 07:11
-
-
Save nczeczulin/6129089 to your computer and use it in GitHub Desktop.
Splunk Modular Input for MSMQ - Example Message Handler Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.ComponentModel.Composition; | |
using System.Messaging; | |
using MessageHandlerContracts = Splunk.ModularInput.Msmq.MessageHandlerContracts; | |
namespace Example | |
{ | |
[Export("ExampleHandler.Template", typeof(MessageHandlerContracts.IMessageHandler))] | |
[PartCreationPolicy(CreationPolicy.NonShared)] | |
public class ExampleHandlerTemplate : MessageHandlerContracts.IMessageHandler | |
{ | |
public System.Messaging.IMessageFormatter MessageBodyFormatter { get; private set; } | |
public System.Messaging.MessagePropertyFilter MessageReadPropertyFilter { get; private set; } | |
[ImportingConstructor] | |
public ExampleHandlerTemplate() | |
{ | |
MessageReadPropertyFilter = new MessagePropertyFilter(); | |
// Note, both MessageReadPropertyFilter and MessageBodyFormatter _must_ be configured either | |
// here, or during SetConfiguration | |
} | |
/// <summary> | |
/// This method is called after instantiation. | |
/// Also called during external validation if Manager>>Data Inputs>>MSMQ Messaging is used to configure | |
/// the input stanza. | |
/// </summary> | |
/// <param name="handlerArgs"></param> | |
public void SetConfiguration(string handlerArgs) | |
{ | |
// do stuff. | |
// throw an exception if required. | |
} | |
/// <summary> | |
/// This method is called for every msmq message that is processed. | |
/// The returned string will be the "event data" forwarded to splunk. | |
/// </summary> | |
/// <param name="msg"></param> | |
/// <returns></returns> | |
public string GetSplunkEventData(System.Messaging.Message msg) | |
{ | |
// add code | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment