diff --git a/messaging.go b/messaging.go index 17269fe..b13c542 100644 --- a/messaging.go +++ b/messaging.go @@ -6,6 +6,7 @@ import ( "gitea.rebus.ninja/lore/wasm-nats-producer-client/gen/wasmcloud/messaging/types" logger "gitea.rebus.ninja/lore/wasm-nats-producer-client/gen/wasi/logging/logging" //config "gitea.rebus.ninja/lore/wasm-nats-producer-client/gen/wasi/config/runtime" + "time" ) type messagingConsumerAdapter struct { @@ -22,12 +23,13 @@ func loop() cm.Result[string, struct{}, string] { // TODO implement the logic to get the destination topic from the config // dest_topic := config.GetAll() dest_topic := "test.reply" + counter := 0 // TASK - for true { + for { // generate random message - data := []byte("Hello, World!") + data := []byte("Hello, World! " + string(counter)) // Send reply reply := types.BrokerMessage{ @@ -41,6 +43,15 @@ func loop() cm.Result[string, struct{}, string] { return res } + counter++ + + if counter == 1000 { + break + } + + // sleep for 1 second + time.Sleep(1 * time.Second) + } return cm.OK[cm.Result[string, struct{}, string]](struct{}{})