Trouble switching from CatchUp to Live

Hi, I have a feeling this is a real newbee question.

I have a handler/dispatcher that subscribes to $all and writes the events to a view. Pretty simple stuff. I have a console app that modifies an aggregate and publishes a few messages.

When I start the handler it reads all the previous messages and updates my view, but when I run the other app and have it call the aggregate my handler does not seem to receive them.

most of this is jacked directly from dispatcher discussions on this news group and/or the recommended repository. the Start method calls the RecoverSubscription() method as does the HandleSubscriptionDropped.

Any help would be appreciated.

thanks,

R

Here’s my code.

private void RecoverSubscription()

{

_lastProcessedPosition = _mongoRepository.Get(x => x.HandlerType == _handlerType)

?? new LastProcessedPosition {HandlerType = _handlerType, CommitPosition = 0, PreparePosition = 0};

var position = new Position(_lastProcessedPosition.CommitPosition, _lastProcessedPosition.PreparePosition);

_subscription = _gesConnection.SubscribeToAllFrom(position, false, HandleNewEvent, null, HandleSubscriptionDropped, new UserCredentials(“admin”, “changeit”));

}

private void HandleNewEvent(EventStoreCatchUpSubscription subscription, ResolvedEvent @event)

{

if (@event.Event.EventType.StartsWith("$")) { return; }

_rawEvent = @event;

_event = ProcessRawEvent();

if (_event == null) { return; }

HandleEvent(_rawEvent.Event.EventType);

}

protected object ProcessRawEvent()

{

if (_rawEvent.OriginalEvent.Metadata.Length > 0 && _rawEvent.OriginalEvent.Data.Length > 0)

return DeserializeEvent(_rawEvent.OriginalEvent.Metadata, _rawEvent.OriginalEvent.Data);

return null;

}

private static object DeserializeEvent(byte[] metadata, byte[] data)

{

var eventClrTypeName = JObject.Parse(Encoding.UTF8.GetString(metadata)).Property(“EventClrTypeName”).Value;

return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(data), Type.GetType((string)eventClrTypeName));

}

I should add I was using 2.0, and having this trouble, I just upgraded to 3.0 and same store. Clearly it’s me. I just don’t know how.
r

I should include this further diagnostics
a, if I add an onLiveProcessingStarted handler it does fire.

when I look at the console running GES I see this stuff popup. don’t know what it means but it doesn’t look happy.

thx

[15616,03,17:33:17.196] ES TcpConnection closed [17:33:17.196: N127.0.0.1:59916, L127.0.0.1:1113, {2fc57cb7-da16-4873-baff-6128698a07e0}]:

Received bytes: 2484, Sent bytes: 72

Send calls: 2, callbacks: 2

Receive calls: 3, callbacks: 3

Close reason: [ConnectionReset] Socket receive error

[15616,09,17:33:17.196] ES TcpConnection closed [17:33:17.197: N127.0.0.1:59915, L127.0.0.1:1113, {de610a54-2f17-4f8f-a730-92eca0cf3235}]:

Received bytes: 0, Sent bytes: 0

Send calls: 0, callbacks: 0

Receive calls: 1, callbacks: 1

Close reason: [ConnectionReset] Socket receive error

[15616,03,17:33:17.196] Connection ‘external-normal’ [127.0.0.1:59916, {2fc57cb7-da16-4873-baff-6128698a07e0}] closed: ConnectionReset.

[15616,09,17:33:17.196] Connection ‘external-normal’ [127.0.0.1:59915, {de610a54-2f17-4f8f-a730-92eca0cf3235}] closed: ConnectionReset.

This likely is perfectly notmal its just saying your connections were closed (Connection Reset by Peer)

For the original issue the real trick is making sure you pass in a valid position when calling.

btw you normally shouldn’t make new subscriptions on the dropped it will recover itself (keep retrying etc options on connection).

Cheers,

Greg

I think we need a section in documentation on the canonical usage patterns of catch up vs regular subscriptions and how they interact with reconnections etc. I’ve opened up a documentation issue for this: https://github.com/EventStore/EventStore/issues/231

Yes this would be really great. I would really appreciate it
Thanks,

R