user2808660
user2808660

Reputation: 13

Smooks mediator for web logs

I am trying to use WSO2-ESB to parse a text file containing web logs and put it into a database. I have imported the file using VFS. Now I need to apply smooks mediator on this input and convert into XML. Structure of the input file is as follows

64.242.88.10 - - [07/Mar/2004:16:06:51 -0800] "GET /twiki/bin/rdiff/TWiki/NewUserTemplate?rev1=1.3&rev2=1.2 HTTP/1.1" 200 4523

64.242.88.10 - - [07/Mar/2004:16:10:02 -0800] "GET /mailman/listinfo/hsdivision HTTP/1.1" 200 6291

So I need a custom mediator where in I can parse these type of input and split it at space character and convert it to XML. I know how to use smooks in WSO2 ESB to convert XML to XML, CSV to XML, etc. But I dont know how to create a custom mediator.

Is there any tutorial or link which I can refer for creating a custom mediator?

Upvotes: 0

Views: 109

Answers (3)

krishni andradi
krishni andradi

Reputation: 37

Please refer below article. It explains a similar scenario. https://medium.com/sa-team-blog/reading-files-and-sending-file-content-to-an-api-using-wso2-enterprise-integrator-4118db8e295c?source=friends_link&sk=5242b3c380f100b1bccaadf183f19836

For the above scenario, you do not need a custom mediator, because WSO2 has already introduced a smooks mediator to their ESB solution. Please refer here for more info https://docs.wso2.com/display/ESB481/Smooks+Mediator

In nutshell, you have to do the following.
Drag and drop a smooks mediator to your input message flow. Create a local entry in your ESB solution project, and define smooks properties in that local entry file. Then give that local entry file name as the smooks config key to the smooks mediator.

Upvotes: -1

Ratha
Ratha

Reputation: 9702

i dont think you need a custom mediator for this. Directly use smooks meditator to convert your text records to xml

Upvotes: 0

Vanji
Vanji

Reputation: 1704

Yes there are document and blogs available for creating Custom mediator. Please refer the official document to write a custom mediator or Article series written by one of the WSO2 employee.

In simple words, You have to extend the "AbstractMediator" and overwrite the mediate Method to write your logic.

Writing a Custom Mediator for WSO2 ESB - Part 1 Writing a Custom Mediator for WSO2 ESB - Part 2

Upvotes: 1

Related Questions