Storing mappings in the database.

566 views
Skip to first unread message

Артём Ульянов

unread,
Jun 16, 2021, 8:05:42 AM6/16/21
to wiremock-user
Hello everyone. I want to ask you whether it is possible to store all the mappings that are added / updated in the database so that they are not deleted after a server restart?

If possible, tell us about it in more detail.


aaron...@willowtreeapps.com

unread,
Jun 16, 2021, 9:37:23 AM6/16/21
to wiremock-user
You can achieve this either in code or by hitting the admin API directly. Read more about it at Saving Stubs and at the API reference.

Tom Akehurst

unread,
Jun 16, 2021, 10:14:04 AM6/16/21
to wiremock-user
You can do this by creating your own implementation of MappingsSource, then supplying this to the config object when you create the WireMock server in code.

Note: this will still keep stubs in memory, but back them up to whatever store you provide so it's fine for persistence but won't work as part of a clustering solution.

Артём Ульянов

unread,
Jun 16, 2021, 11:39:08 AM6/16/21
to wiremock-user
I am using Spring Boot with Tomcat, i don't create wiremock server manually

среда, 16 июня 2021 г. в 17:14:04 UTC+3, t.m.ak...@googlemail.com:

Артём Ульянов

unread,
Jun 16, 2021, 11:43:43 AM6/16/21
to wiremock-user
How can a given MappingSource be specified in Spring Boot?

среда, 16 июня 2021 г. в 18:39:08 UTC+3, Артём Ульянов:

Tom Akehurst

unread,
Jun 16, 2021, 11:44:23 AM6/16/21
to wiremock-user
Unless you're able to pass in a config object to WireMock, then you're out of luck.

You can persist stubs to the file system just be adding a "persistent": true flag to them (or .persistent() in the Java DSL), if that helps at all.

Reply all
Reply to author
Forward
0 new messages