Hello All, I want to run multiple instances of Wi...
# help
a
Hello All, I want to run multiple instances of Wiremockserver on different ports inside Spring boot application, i am running like below:
Copy code
@Configuration
public class WireMockConfig {

    private final WireMockServer wireMockServerL1;
    private final WireMockServer wireMockServerL2;
    private final WireMockServer wireMockServerL3;

    @Value("${wiremock.root.directory.l1}")
    private String rootDirectoryL1;

    @Value("${wiremock.root.directory.l2}")
    private String rootDirectoryL2;

    @Value("${wiremock.root.directory.l3}")
    private String rootDirectoryL3;

    public WireMockConfig(WireMockServer wireMockServerL1, WireMockServer wireMockServerL2, WireMockServer wireMockServerL3) {
        this.wireMockServerL1 = wireMockServerL1;
        this.wireMockServerL2 = wireMockServerL2;
        this.wireMockServerL3 = wireMockServerL3;
    }

    @EventListener(ApplicationReadyEvent.class)
    public void startWireMockServer(){

        wireMockServerStarter(wireMockServerL1, Integer.parseInt("8082"), rootDirectoryL1);
        wireMockServerStarter(wireMockServerL2, Integer.parseInt("8083"), rootDirectoryL2);
        wireMockServerStarter(wireMockServerL3, Integer.parseInt("8084"), rootDirectoryL3);

    }

    private void wireMockServerStarter(WireMockServer wireMockServer, int port, String rootDirectory){
        wireMockServer = new WireMockServer(
                WireMockConfiguration.options()
                        .port(port)
                        .withRootDirectory(rootDirectory)
                        .notifier(new ConsoleNotifier(true))
        );
        wireMockServer.start();
        System.out.println("WireMock server started on port: " + port);
    }

    @EventListener(ContextClosedEvent.class)
    public void stopWireMockServer() {
        if(null != wireMockServerL1){
            wireMockServerL1.stop();
            System.out.println("WireMock server stopped");
        }
        if(null != wireMockServerL2){
            wireMockServerL2.stop();
            System.out.println("WireMock server stopped");
        }
        if(null != wireMockServerL3){
            wireMockServerL3.stop();
            System.out.println("WireMock server stopped");
        }
    }

}
now, i want make Recording functionality should work on parallel on each instance, i am starting server like below for one instance for example:
Copy code
@Service
public class WireMockService {

    private final WireMockServer wireMockServerL1;

    public WireMockService(WireMockServer wireMockServerL1) {
        this.wireMockServerL1 = wireMockServerL1;
    }

    public void startRecording(String targetUrl, String targetModule) {
        RecordSpec recordSpec = new RecordSpecBuilder()
                .forTarget(targetUrl)
                .makeStubsPersistent(true)
                .build();
        WireMock.configureFor("localhost", 8082);
        wireMockServerL1.startRecording(recordSpec);
        System.out.println("Started Recording");
    }

    public void stopRecording() {
        wireMockServerL1.saveMappings();
        wireMockServerL1.stopRecording();
        System.out.println("Stopped Recording");
    }

    public String getRecordStatus(){
        RecordingStatusResult result = wireMockServerL1.getRecordingStatus();
        return result.getStatus().name();
    }

}
Problem: when i call start recording on targetUrl, it is saying recording started but when i call api to record, it is saying no stub response to server Can you guys please help on this how to procced. @Tom i need your on this to procced I am using this dependency
Copy code
<dependency>
    <groupId>org.wiremock</groupId>
    <artifactId>wiremock-standalone</artifactId>
    <version>3.10.0</version>
</dependency>