Implementing Trap Receiver in 30 minutes using Apache MINA

Will continues to post articles about MINA, to be updated,

Yes, we are going to implement a SNMP trap receiver in less than 30 minutes. If you have been following my post on Apache MINA, this would be a natural extension to it. In this article, we shall bring together all our components to build the system.

 Pre-requisites:

 Please read through these articles. You can find all these posts on Apache MINA

  • What is Apache MINA
  • Apache MINA based Server Application Architecture
  • Implementing UDP Server using Apache MINA
  • Implementing SNMP4J Decoder for Apache MINA

 To execute the code, you need following jars

  • mina-core-2.0.0-M1.jar
  • slf4j-api-1.5.0.jar
  • slf4j-log4j12-1.5.0.jar
  • log4j-1.2.15.jar
  • SNMP4J.jar

 I am assuming that you have read my previous posts and jumping straight to the implementations. The high level architecture is explained in the post Apache MINA based Server Application Architecture

Architecture 

Let’s understand the flow here and see what all we need to do to process a trap

  • Receive the trap over UDP
  • Decode the Trap
  • Dump the Trap

Lets see how each of the these maps to the code we have already written


It's a now simple to understand that we have reused all the components to create the Server. Let me not write too much, and jump straight to the code J

 The Server Code

The only change that we did to the UDP Server code was to add a Protocol Codec. At line 36, we added our custom ProtocolCodecFiler. The SNMPCodecFactory return the instance of our SNMP4J codec. There is not much code and this construct is fairly simple, and explained very well in MINA’s documentation. From the main method, we just need to call the method initialize() and our trap receiver starts.

References

4 thoughts on “Implementing Trap Receiver in 30 minutes using Apache MINA

Leave a Reply to Dave Web site design Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.