io.fluxcapacitor.axonclient.commandhandling.result.ResultProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axon-client Show documentation
Show all versions of axon-client Show documentation
A Java client library that enables Axonframework components to interact via Flux Capacitor.
Axonframework is a CQRS framework for Java. For more information about Axonframework see
http://axonframework.org
/*
* Copyright (c) 2016-2017 Flux Capacitor.
*
* 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.
*/
package io.fluxcapacitor.axonclient.commandhandling.result;
import io.fluxcapacitor.axonclient.common.serialization.AxonMessageSerializer;
import io.fluxcapacitor.common.Registration;
import io.fluxcapacitor.common.api.SerializedMessage;
import io.fluxcapacitor.javaclient.tracking.client.TrackingClient;
import io.fluxcapacitor.javaclient.tracking.client.TrackingUtils;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class ResultProcessor implements ResultService {
private final AxonMessageSerializer serializer;
private final TrackingClient trackingClient;
private final String name;
private final int threads;
private final Map> outstandingRequests = new ConcurrentHashMap<>();
private volatile Registration registration;
public ResultProcessor(AxonMessageSerializer serializer, TrackingClient trackingClient,
String name) {
this(serializer, trackingClient, name, 1);
}
public ResultProcessor(AxonMessageSerializer serializer,
TrackingClient trackingClient, String name, int threads) {
this.serializer = serializer;
this.trackingClient = trackingClient;
this.name = name;
this.threads = threads;
}
@Override
public CompletableFuture