msemys / esjc

EventStore Java Client
MIT License
108 stars 27 forks source link

Question - List all available streams #48

Closed jselamy closed 5 years ago

jselamy commented 5 years ago

Hey,

Quick question, is there a way to list all available streams ?

msemys commented 5 years ago

hi, try this:

  1. enable projections on eventstore server, run with --run-projections=all
  2. enable system projection $streams via webui, http api or esjc:
    
    ProjectionManager projectionManager = ProjectionManagerBuilder.newBuilder()
        .address("127.0.0.1", 2113)
        .userCredentials("admin", "changeit")
        .operationTimeout(Duration.ofSeconds(20))
        .build();

projectionManager.enable(SystemProjections.STREAMS).join();

3. read `$streams` stream (there are links to the first event of stream):
```java
eventstore.iterateStreamEventsForward(SystemProjections.STREAMS, 0, 500, false)
        .forEachRemaining(e -> {
            String data = new String(e.originalEvent().data);
            String stream = data.substring(data.indexOf('@') + 1);
            System.out.println(stream);
        });
jselamy commented 5 years ago

Thanks!