diff --git a/sample/sample-consumer/sample-consumer-service/src/main/java/hu/icellmobilsoft/sampler/sample/comsumerservice/action/PainterAction.java b/sample/sample-consumer/sample-consumer-service/src/main/java/hu/icellmobilsoft/sampler/sample/comsumerservice/action/PainterAction.java index fd99165..45ab131 100644 --- a/sample/sample-consumer/sample-consumer-service/src/main/java/hu/icellmobilsoft/sampler/sample/comsumerservice/action/PainterAction.java +++ b/sample/sample-consumer/sample-consumer-service/src/main/java/hu/icellmobilsoft/sampler/sample/comsumerservice/action/PainterAction.java @@ -92,9 +92,6 @@ public void paint(String carProductionId) throws BaseException { // data query for validation CarProduction carProduction = carProductionService.findById(carProductionId, CarProduction.class); - // prepare the stream message of the next consumer - String streamMessage = carProduction.getId(); - ProductionStatus actualStatus = carProduction.getProductionStatus(); // validate the data based on the state the consumer accepts for processing @@ -109,6 +106,8 @@ public void paint(String carProductionId) throws BaseException { // ===== STEP-2: COLLECT AND PROCESS DATA ===== // ============================================ + // prepare the stream message of the next consumer + // REST call for external data query String color = carOrderRestClient.getColor("carOrderId"); @@ -129,7 +128,7 @@ public void paint(String carProductionId) throws BaseException { // create the process record of the next consumer ProcessCarPaintedToAssembled processCarPaintedToAssembled = new ProcessCarPaintedToAssembled(); processCarPaintedToAssembled.setCarProduction(carProduction); - processCarPaintedToAssembled.setStreamMessage(streamMessage); + processCarPaintedToAssembled.setStreamMessage(carProduction.getId()); // ... create and modify entities @@ -160,7 +159,7 @@ public void paint(String carProductionId) throws BaseException { // fire an async event to publish the stream message to the next redis stream // the consumer execution is successful either if the redish operation fails, the failover solution will retry it later asyncRedisPublishEventDispatcher.fireAsyncRedisPublishEvent( - streamMessage, + processCarPaintedToAssembled.getStreamMessage(), RedisStreamConstant.CarProduction.Assembler.CONFIG_KEY, RedisStreamConstant.CarProduction.Assembler.GROUP); } diff --git a/sample/sample-consumer/sample-consumer-service/src/main/java/hu/icellmobilsoft/sampler/sample/comsumerservice/redis/RedisConsumerStarter.java b/sample/sample-consumer/sample-consumer-service/src/main/java/hu/icellmobilsoft/sampler/sample/comsumerservice/redis/RedisConsumerStarter.java index 143d9f7..d7a3f1f 100644 --- a/sample/sample-consumer/sample-consumer-service/src/main/java/hu/icellmobilsoft/sampler/sample/comsumerservice/redis/RedisConsumerStarter.java +++ b/sample/sample-consumer/sample-consumer-service/src/main/java/hu/icellmobilsoft/sampler/sample/comsumerservice/redis/RedisConsumerStarter.java @@ -1,46 +1,46 @@ -/*- - * #%L - * Sampler - * %% - * Copyright (C) 2022 - 2025 i-Cell Mobilsoft Zrt. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ -package hu.icellmobilsoft.sampler.sample.comsumerservice.redis; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.context.Initialized; -import jakarta.enterprise.event.Observes; - -import hu.icellmobilsoft.coffee.module.redisstream.bootstrap.BaseRedisConsumerStarter; - -/** - * Minden Redis stream consumer indításáért felel - * - * @author attila.kiss - * @since 2.0.0 - */ -@ApplicationScoped -public class RedisConsumerStarter extends BaseRedisConsumerStarter { - - /** - * CDI event observer - * - * @param init - * CDI - */ - public void begin(@Observes @Initialized(ApplicationScoped.class) Object init) { - start(); - } -} +/*- + * #%L + * Sampler + * %% + * Copyright (C) 2022 - 2025 i-Cell Mobilsoft Zrt. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package hu.icellmobilsoft.sampler.sample.comsumerservice.redis; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.Initialized; +import jakarta.enterprise.event.Observes; + +import hu.icellmobilsoft.coffee.module.redisstream.bootstrap.BaseRedisConsumerStarter; + +/** + * Redis consumer starter. + * + * @author attila.kiss + * @since 2.0.0 + */ +@ApplicationScoped +public class RedisConsumerStarter extends BaseRedisConsumerStarter { + + /** + * CDI event observer to start all of the redis stream consumers. + * + * @param init + * CDI + */ + public void begin(@Observes @Initialized(ApplicationScoped.class) Object init) { + start(); + } +}