Catchup subscriptions issue

Hi All,

I’m trying to use catch up subscriptions in a testing scenario to read all the events from a stream that I know exists, as I previously have appended to it in the same test.

I’ve got 3 deligates for subscription dropped, go live and event appeared all with breakpoints on there first lines.

When I call SubscribeFrom specifying my stream, StreamCheckPoint.Start and false to not resolve linked events none of my breakpoints are hit and IsSubscribed on the returned object from SubScribeFrom is false.

I’ve got logs/data files if that would help.

Any help appreciated.

Kind regards

Sean.

Code would be useful :slight_smile:

Hi,

Ok, hereis the code of the test concerned:

///

/// Test that multiple is readable after it has been written.

///

[Test]

public void WhenMultipleEventsAreWrittenToTheSinkTheyAreRetrievableFromTheEventStore()

{

var earlierTimestamp = new DateTimeOffset(2013, 05, 28, 22, 10, 20, 400, TimeSpan.FromHours(10));

var exception = new ArgumentException(“Mládek”);

const LogEventLevel level = LogEventLevel.Information;

const string messageTemplate = “{Song}++”;

var properties = new List

{

new LogEventProperty(“Song”, new ScalarValue(“New Macabre”))

};

var template = new MessageTemplateParser().Parse(messageTemplate);

var earlierLogEvent = new Events.LogEvent(earlierTimestamp, level, exception, template, properties);

//second event.

var laterTimestamp = new DateTimeOffset(2013, 05, 28, 22, 10, 20, 600, TimeSpan.FromHours(10));

var laterLogEvent = new Events.LogEvent(laterTimestamp, level, exception, template, properties);

var readEvents =new List(2);

var actualLogEvents = new List()

{

new LogEntryEmittedEvent(earlierLogEvent, earlierLogEvent.RenderMessage(null)),

new LogEntryEmittedEvent(laterLogEvent, laterLogEvent.RenderMessage(null))

};

IEventStoreConnection connection = null;

using (EventStoreRunner runner = new EventStoreRunner())

{

using (connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113)))

using (EventStoreSink sink = new EventStoreSink(connection, “Logs”, EventStoreSink.DefaultBatchPostingLimit, EventStoreSink.DefaultPeriod))

{

sink.Emit(earlierLogEvent);

}

//write a second event, in a different connection. This tests whether the reading/writing of the last event number
in the stream metadata works.

using (connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113)))

using (EventStoreSink sink = new EventStoreSink(connection, “Logs”, EventStoreSink.DefaultBatchPostingLimit, EventStoreSink.DefaultPeriod))

{

sink.Emit(laterLogEvent);

}

}

//Now, try and read both events using a catchup subscription.

using (EventStoreRunner runner = new EventStoreRunner())

using (connection = EventStoreConnection.Create(new IPEndPoint(IPAddress.Loopback, 1113)))

{

connection.ConnectAsync();

EventStoreCatchUpSubscription sub =connection.SubscribeToStreamFrom(“Logs”, StreamCheckpoint.StreamStart, true,
EventArrived, GoingLive, ConnectionDropped);

}

Assert.That(readEvents, Is.EqualTo(actualLogEvents));

}

private void ConnectionDropped(EventStoreCatchUpSubscription arg1, SubscriptionDropReason arg2, Exception arg3)

{

throw new NotImplementedException();

}

private void GoingLive(EventStoreCatchUpSubscription obj)

{

throw new NotImplementedException();

}

private void EventArrived(EventStoreCatchUpSubscription arg1, ResolvedEvent arg2)

{

throw new NotImplementedException();

}

All the sink is doing is writing essentially doing an append to stream, after accessing some stream metadata.

The EventStoreRunner is just a class to start/stop the eventstore process.

If you need these let me know.

Cheers

Sean.

Just a wild guess here but you probably need to await or block on ConnectAsync

What do you see in the ui if you browse to stream ‘logs’ you don’t connect the connections you write to

Hi Greg,

Connection is made in the link class—I’m in the process of pulling this out though as it’s not the sinks responsibility.

As a side note it would be nice to have the ability to determine whether a connection is connected or not, a Boolean would suffice
for my needs.

I do see events being shown if I look in the ui.

Cheers

Sean.