seanyinx commented on a change in pull request #120: SCB-234 fail fast at SagaStart if all alpha clusters are down URL: https://github.com/apache/incubator-servicecomb-saga/pull/120#discussion_r161683808
########## File path: omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/RetryableMessageSender.java ########## @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.servicecomb.saga.omega.connector.grpc; + +import static org.apache.servicecomb.saga.common.EventType.SagaStartedEvent; + +import java.util.concurrent.BlockingQueue; + +import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; +import org.apache.servicecomb.saga.omega.transaction.MessageSender; +import org.apache.servicecomb.saga.omega.transaction.OmegaException; +import org.apache.servicecomb.saga.omega.transaction.TxEvent; + +public class RetryableMessageSender implements MessageSender { + private final BlockingQueue<MessageSender> availableMessageSenders; + + public RetryableMessageSender(BlockingQueue<MessageSender> availableMessageSenders) { + this.availableMessageSenders = availableMessageSenders; + } + + @Override + public AlphaResponse send(TxEvent event) { + if (event.type() == SagaStartedEvent) { + throw new OmegaException("Failed to process subsequent requests because no alpha server is available"); Review comment: this exception needs to be caught by saga annotation processor and rethrow as TransactionalException ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
