In openfire how to create plugin to push message to a api based on the message type

In openfire I am sending a custom attribute type like m_type="route1", m_type="route2" while sending message, I wanted to create a plugin in openfire which will push the data to REST API by listening to all chatrooms. How can we create plugin for this?

That seems to be best approached by using a PacketInterceptor, as explained in the Openfire Plugin Developer Guide.

Does PacketInterceptor works for muc and 1 to 1 message also. I wanted to recieve only message for a particular user for both muc and 1 to 1 chat.

It will work for every stanza, including those. You will need to understand the basics of XMPP addressing to be able to filter the data that you want, but this is clearly documented in the XMPP specifications.