Official Content

The following example shows how to publish events to Azure Event Grid based on EventGrid Schema, using SendCustomEvents method.

&EventGridSchema is EventGridSchema SDT data type.

    &endpoint = !"https://eventgridcloud.eastus-1.eventgrid.azure.net/api/events"
    &accesskey = !"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    &EventRouter = AzureEventGrid.EventGridRouterProvider.Connect(&endpoint,&accesskey,&errorMessages,&IsSuccess)    

    &employee.name = "ernesto"
    &employee.married = true
    &employee.salary = 40000
    &EventGridSchema.data = &employee.ToJson()  
    &EventGridSchema.eventType = !"Example.EventType1"
    &EventGridSchema.subject = !"ExampleEventSubject1"
    &EventGridSchema.dataVersion = "1.0"
    
    &EventGridSchemaCollection.Add(&EventGridSchema)
    
    &EventGridSchema = new()
    &employee = new()
    &employee.name = "agustin"
    &employee.married = true
    &employee.salary = 40050
    &EventGridSchema.data = &employee.ToJson()
    
    &EventGridSchema.eventType = !"Example.EventType2"
    &EventGridSchema.subject = !"ExampleEventSubject2"
    &EventGridSchema.dataVersion = "1.0"
    &EventGridSchemaCollection.Add(&EventGridSchema)
    
    &isOK = &EventRouter.SendCustomEvents(&EventGridSchemaCollection.ToJson(),false,&errorMessages)

Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant