EPi events with Azure Servicebus event provider

Vote:
 

Hi,

public void ConfigureServices(IServiceCollection services)
 {
   services.AddAzureEventProvider(o =>
            {
                o.ConnectionString = settings.ConnectionString;
                o.TopicName = settings.TopicName;
                o.TopicSize = 1024;
            });
}


public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IContentEvents contentEvents, ICatalogEvents catalogEvents, 
            CatalogKeyEventBroadcaster catalogKeyEventBroadcaster, EpiServerEventsSubscriberService epiServerEventsSubscriberService)
{
            contentEvents.SavingContent += epiServerEventsSubscriberService.SavingContent;
            contentEvents.PublishingContent += epiServerEventsSubscriberService.PublishingContent;
            contentEvents.PublishedContent += epiServerEventsSubscriberService.PublishedContent;
            catalogEvents.RelationUpdated += epiServerEventsSubscriberService.RelationUpdated;
            contentEvents.CreatedContent += epiServerEventsSubscriberService.CreatedContent;
        
            catalogKeyEventBroadcaster.PriceUpdated += epiServerEventsSubscriberService.PriceUpdated;
}            

We're trying to use EPi events with multiple servers. For that, we implemented the Azure event provider to the .NET Core application. With this implementation, we can see some events going through the Azure service bus topic. However, if we try to change some data with one content type, it does not sync on other servers. 

I couldn't find proper documentation on how EPi handled these events. So, my question is, how can we trigger new events that need to run on all the servers on our server farms? Also, How can we trigger some events that need to be run locally on the server? 

Best,
Mehmet

#315521
Jan 12, 2024 15:37
Vote:
 

You should only have a single authoring server, here is some documentation which details the configuration : Episerver load balancing example - Configuring events over WCF with TCP/IP – Support Help Center (optimizely.com)

#315649
Jan 15, 2024 17:13
Vote:
 

Mehmet, try instead to configure the event provider in appsettings.json

"EventProvider" : {

                "Provider" : "EPiServer.Azure.Events.AzureEventProvider,EPiServer.Azure"

              },

              "AzureEventProvider" : {

                "ConnectionString" : "The contention string",

                "TopicName" : "The topic name "

              }

Also remember the provide the connection string against "EPiServerAzureEvents".

#315689
Jan 16, 2024 3:19
Vote:
 

@Minesh Shah (Netcel) Is there any updated version of this documentation? We're using Azure web apps with .Net 6, and applying these settings for the .net core applications is a bit complicated. 

@Surjit Bharath Thanks for the tips. I'll use the way you suggets and keep you updated.

#315702
Jan 16, 2024 13:13
Vote:
 

Hi @Surjit Bharath 

Thanks again for a suggestion for an Azure event provider. It's working as you suggested, but I have one more issue for remote events. I'm getting remote events through CatalogEventBroadcaster and CatalogKeyEventBroadcaster.

Both of them are for product, variant, or package-level information. I need the remote events for CMS, like category content or other pages. 

How can I get this kind of event?

Best,
Mehmet

#316171
Jan 25, 2024 14:40
Vote:
 

Take a look at IContentEvents and ICatalogEvents

#316177
Jan 25, 2024 16:04
Vote:
 

@Surjit Bharath I'm already checking events coming from IContentEvents and ICatalogEvents, but these events are only triggered locally. I need remote events for these. 

For example, PublishedContent event. We have some business logic in this event, but some of them need to run in other instances. I couldn't find how to trigger a remote event for this one. 

#316218
Edited, Jan 26, 2024 8:11
Vote:
 

I believe they are local only Mehmet. Only cache invalidation is raised remotely.

I'll double check this for you at some point today.

#316219
Jan 26, 2024 8:13
Vote:
 

Thank you @Surjit Bharath. I'm looking forward to hearing from you

#316220
Jan 26, 2024 8:25
Vote:
 

@Surjit Bharath  I'm a bit confused. On the document page, it was mentioned that an AzureServiceBus provider needs to be added for remote events. I added it in the way you described. Through this, I am successfully receiving updates for price and stock information.

Now, do I need to add the EPiServer.Events.MassTransit package just for content updates? Or should I delete the AzureServiceBus package and only use the EPiServer.Events.MassTransit package?

#316541
Feb 02, 2024 9:49
Vote:
 

AzureServiceBus provider  is needed only on Azure environment (e.g. DXP). If you are running on premise, you will need a different provider 

#316542
Feb 02, 2024 11:57
Vote:
 

Forget the events packages. You've already setup the service bus on your azure instance.

I sent you the link to show you a second source about only cache invalidation events being remote.

#316543
Feb 02, 2024 12:05
Vote:
 

Surjit is correct, the content events are local - they are raised on same instance when it happens. They are basically event - C# Reference - C# | Microsoft Learn

For an event to be remote, it has to be raised by Event.Raise. Only very few events in CMS use this mechanism. Cache invalidation is one (but not only) 

#316544
Feb 02, 2024 12:23
Vote:
 

@Quan Mai Our website is running on Azure. 

@Surjit Bharath I'm not getting any event for cache invalidations. How can I subscribe for cache invalidation event? 

Here is my current setup for events;

            //Event registration for local only
            contentEvents.SavingContent += epiServerEventsSubscriberService.SavingContent;
            contentEvents.PublishingContent += epiServerEventsSubscriberService.PublishingContent;
            contentEvents.PublishedContent += epiServerEventsSubscriberService.PublishedContent;
            catalogEvents.RelationUpdated += epiServerEventsSubscriberService.RelationUpdated;
            contentEvents.CreatedContent += epiServerEventsSubscriberService.CreatedContent;
            
            catalogKeyEventBroadcaster.PriceUpdated += epiServerEventsSubscriberService.PriceUpdated;
            catalogKeyEventBroadcaster.InventoryUpdated += epiServerEventsSubscriberService.InventoryUpdated;
            
            //Remote event registration
            Event.Get(CatalogEventBroadcaster.CommerceProductUpdated).Raised += epiServerEventsSubscriberService.CommerceProductUpdated;
            Event.Get(CatalogKeyEventBroadcaster.CatalogKeyEventGuid).Raised += epiServerEventsSubscriberService.CatalogKeyEventUpdated;

I'm getting price and stock updates from CatalogKeyEventUpdated. Product and variant-level events from CommerceProductUpdated. 

#316548
Edited, Feb 02, 2024 12:26
Vote:
 

Why do you need to listen to cache invalidation? it's meant to be fully transparent. The framework listens to those event themselves and do the cache invalidation, i.e. you don't need to do anything about it. 

#316549
Feb 02, 2024 12:31
Vote:
 

@Quan Mai When we update the price of the product, it is not updated on other servers. I thought this is related to cache invalidation. If the framework does this automatically, then the problem we are facing is due to another reason. I will investigate this a bit more and let you know.

#316550
Feb 02, 2024 12:43
Vote:
 

Does that happen only to price? If you update a page does it get updated on other instances?

If it is only to price, how do you update it? 

#316551
Feb 02, 2024 13:11
Vote:
 

@Quan Mai Yes, it was just a price update. There was an extra cache that caused this. I deleted it, and that fixed it. 

As for cache invalidation, I did the tests, and as you said, this works without any problems in the CMS.

Thank you for your help.

#316555
Feb 02, 2024 14:39
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.