Hello Urs/Appccelerate team,
I hope things are well with you all.
I have a small request that would help us out in our product quite a bit. What we would like is to include the assembly version in the Publication/Subscription DescribeTo output.
Our issue is that in our product we often have multiple versions of assemblies loaded in memory and when we get an subscription/publication error such as:
2016-07-11 13:58:57.0974 (431) Error 5775 [EventBroker] Error registering instance Connexion.Device.CustomDevice with the EventBroker. Event Hooks will not function properly for this instance. [EventTopicException] Publication
MModal.FluencyForCoding.Integration.ConnexionDevice.R14.EncounterFilerDevice.EncounterFilerDevice, Event = BeforeClinicalDataStoreCommitHandler, matchers = , EventHandler type = System.EventHandler<MModal.FluencyForCoding.Integration.ConnexionDevice.R14.EncounterFilerDevice.ClinicalDataStoreCommitEventArgs>
does not match with subscription
Connexion.Device.CustomDevice, Handler method = OnBeforeClinicalDataStoreCommit, Handler = Appccelerate.EventBroker.Handlers.OnPublisher, EventArgs type = MModal.FluencyForCoding.Integration.ConnexionDevice.R14.EncounterFilerDevice.ClinicalDataStoreCommitEventArgs, matchers =
It hard to tell, but the actual issue is that in ThrowIfPublisherAndSubscriberEventArgumentsMismatch
The publication and subscription are from 2 different assemblies. This error is difficult to track down because everything looks ok from the DescribeTo information. As such if you could add the version of each EventArgsType in the respective DescribeTo, that would be very helpful. For example in Publish.DescribeTo I have added the last 2 lines of code
public virtual void DescribeTo(TextWriter writer)
{
Ensure.ArgumentNotNull(writer, "writer");
if (!this.publisher.IsAlive)
{
return;
}
writer.Write(this.Publisher.GetType().FullNameToString());
writer.Write(" ");
writer.Write(this.Publisher.GetType().Assembly.GetName().Version);
Otherwise, this could be done in ThrowIfPublisherAndSubscriberEventArgumentsMismatch. Something like:
private static void ThrowIfPublisherAndSubscriberEventArgumentsMismatch(ISubscription subscription, IPublication publication)
{
Type publisherEventArgsType = publication.EventArgsType;
Type subscriberEventArgsType = subscription.EventArgsType;
// check that the T in EventHandler<T> is matching, the IsAssignableFrom method return false event if types can be assigned
// e.g. EventHandler<CustomEventArgs> is not assignable to EventHandler<EventArgs> when using IsAssignableFrom directly on event handler type
// therefore do the check on the event arguments type only.
// subscriberEventArgsType can be null if the handler method has no parameters.
if (subscriberEventArgsType != null && !subscriberEventArgsType.IsAssignableFrom(publisherEventArgsType))
{
using (var writer = new StringWriter(CultureInfo.InvariantCulture))
{
if (publisherEventArgsType.Assembly != subscriberEventArgsType.Assembly)
{
writer.Write("Publisher and Subscriber come from different assemblies. Publisher=");
writer.Write(publication.EventArgsType.AssemblyQualifiedName);
writer.Write("Subscriber=");
writer.Write(subscription.EventArgsType);
}
Or, perhaps add a hook that I can get notified of the error and provide more details myself.
Thank you in advance for any consideration on this.
Jonathan