AsyncTransactionApiImpl.java

  1. /*
  2.  * Copyright 2005-2025 the original author or authors.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  * http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16. package org.openwms.common.spi.transactions.commands;

  17. import org.ameba.annotation.Measured;
  18. import org.openwms.core.SpringProfiles;
  19. import org.springframework.amqp.core.AmqpTemplate;
  20. import org.springframework.beans.factory.annotation.Value;
  21. import org.springframework.context.annotation.Profile;
  22. import org.springframework.stereotype.Component;

  23. /**
  24.  * A AsyncTransactionApiImpl.
  25.  *
  26.  * @author Heiko Scherrer
  27.  */
  28. @Profile(SpringProfiles.ASYNCHRONOUS_PROFILE)
  29. @Component
  30. class AsyncTransactionApiImpl implements AsyncTransactionApi {

  31.     private final AmqpTemplate template;
  32.     private final String exchangeName;

  33.     AsyncTransactionApiImpl(AmqpTemplate template,
  34.             @Value("${owms.commands.transactions.tx.exchange-name}") String exchangeName) {
  35.         this.template = template;
  36.         this.exchangeName = exchangeName;
  37.     }

  38.     /**
  39.      * {@inheritDoc}
  40.      */
  41.     @Override
  42.     @Measured
  43.     public void process(TransactionCommand command) {
  44.         template.convertAndSend(exchangeName, "common.tx.command.in.create", command);
  45.     }
  46. }