public void notifyInventoryUpdate()

in function-apps/Notify-Inventory/src/main/java/org/inventory/hub/NotifyInventoryUpdate.java [30:48]


    public void notifyInventoryUpdate(
        @CosmosDBTrigger(name = "document", databaseName = "%NOTIFICATIONS_COSMOSDB_DBNAME%",
            collectionName = "%NOTIFICATIONS_COSMOSDB_COLLECTION_NAME%",
            connectionStringSetting = "NOTIFICATIONS_COSMOSDB_CONNECTION_STRING",
            leaseCollectionName = "%NOTIFY_INVENTORY_UPDATE_FUNCTION_APP_NAME%", createLeaseCollectionIfNotExists = true)
            String document,
        @EventHubOutput(name = "dataOutput", eventHubName = "%NOTIFICATIONS_EVENT_HUB_NAME%",
            connection = "NOTIFICATIONS_EVENT_HUB_CONNECTION_STRING") OutputBinding<String> dataOutput,
        final ExecutionContext context) {

        context.getLogger().info("Java CosmosDB Notification trigger processed a request: " + document);

        final Gson gson = new GsonBuilder().setPrettyPrinting().create();
        // We don't want to send the document content as is since it contains some properties we might not want
        List<TransactionEvent> transactionEvents = gson.fromJson(document, new TypeToken<ArrayList<TransactionEvent>>(){}.getType());

        context.getLogger().info("Creating Event Hub notifications: " + gson.toJson(transactionEvents));
        dataOutput.setValue(gson.toJson(transactionEvents));
    }