- updated eventuateClientVersion

- updated Int128 usage
This commit is contained in:
dartpopikyardo
2016-10-21 21:29:17 +03:00
parent 909ad5fea9
commit fd0a4355a7
3 changed files with 8 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts; package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts;
import com.mongodb.WriteResult; import com.mongodb.WriteResult;
import io.eventuate.Int128;
import net.chrisrichardson.eventstore.javaexamples.banking.common.accounts.AccountChangeInfo; import net.chrisrichardson.eventstore.javaexamples.banking.common.accounts.AccountChangeInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.accounts.AccountTransactionInfo; import net.chrisrichardson.eventstore.javaexamples.banking.common.accounts.AccountTransactionInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.TransferState; import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.TransferState;
@@ -29,7 +30,7 @@ public class AccountInfoUpdateService {
} }
public void create(String accountId, String customerId, String title, BigDecimal initialBalance, String description, String version) { public void create(String accountId, String customerId, String title, BigDecimal initialBalance, String description, Int128 version) {
try { try {
AccountChangeInfo ci = new AccountChangeInfo(); AccountChangeInfo ci = new AccountChangeInfo();
ci.setAmount(toIntegerRepr(initialBalance)); ci.setAmount(toIntegerRepr(initialBalance));
@@ -40,7 +41,7 @@ public class AccountInfoUpdateService {
.set("description", description) .set("description", description)
.set("balance", toIntegerRepr(initialBalance)) .set("balance", toIntegerRepr(initialBalance))
.push("changes", ci) .push("changes", ci)
.set("creationDate", getFromEventId(version)) .set("creationDate", new Date(version.getHi()))
.set("version", version), .set("version", version),
AccountInfo.class); AccountInfo.class);
logger.info("Saved in mongo"); logger.info("Saved in mongo");
@@ -81,12 +82,4 @@ public class AccountInfoUpdateService {
set("transactions." + transactionId + ".status", status), set("transactions." + transactionId + ".status", status),
AccountInfo.class); AccountInfo.class);
} }
private Date getFromEventId(String eventId) {
String[] s = eventId.split("-");
if (s.length != 2) {
return new Date();
}
return new Date(Long.parseUnsignedLong(s[0], 16));
}
} }

View File

@@ -3,6 +3,7 @@ package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.ac
import io.eventuate.DispatchedEvent; import io.eventuate.DispatchedEvent;
import io.eventuate.EventHandlerMethod; import io.eventuate.EventHandlerMethod;
import io.eventuate.EventSubscriber; import io.eventuate.EventSubscriber;
import io.eventuate.Int128;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts.*; import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts.*;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions.CreditRecordedEvent; import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions.CreditRecordedEvent;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions.DebitRecordedEvent; import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions.DebitRecordedEvent;
@@ -34,7 +35,7 @@ public class AccountQueryWorkflow {
public void create(DispatchedEvent<AccountOpenedEvent> de) { public void create(DispatchedEvent<AccountOpenedEvent> de) {
AccountOpenedEvent event = de.getEvent(); AccountOpenedEvent event = de.getEvent();
String id = de.getEntityId(); String id = de.getEntityId();
String eventId = de.getEventId().asString(); Int128 eventId = de.getEventId();
logger.info("**************** account version=" + id + ", " + eventId); logger.info("**************** account version=" + id + ", " + eventId);
BigDecimal initialBalance = event.getInitialBalance(); BigDecimal initialBalance = event.getInitialBalance();
@@ -57,8 +58,8 @@ public class AccountQueryWorkflow {
String moneyTransferId = de.getEntityId(); String moneyTransferId = de.getEntityId();
String fromAccountId = de.getEvent().getDetails().getFromAccountId(); String fromAccountId = de.getEvent().getDetails().getFromAccountId();
String toAccountId = de.getEvent().getDetails().getToAccountId(); String toAccountId = de.getEvent().getDetails().getToAccountId();
logger.info("**************** account version=" + fromAccountId + ", " + de.getEventId().asString()); logger.info("**************** account version=" + fromAccountId + ", " + eventId);
logger.info("**************** account version=" + toAccountId + ", " + de.getEventId().asString()); logger.info("**************** account version=" + toAccountId + ", " + eventId);
AccountTransactionInfo ti = new AccountTransactionInfo(moneyTransferId, AccountTransactionInfo ti = new AccountTransactionInfo(moneyTransferId,
fromAccountId, fromAccountId,

View File

@@ -5,5 +5,5 @@ eventuateMavenRepoUrl=http://mavenrepo.eventuate.io/release
springBootVersion=1.3.5.RELEASE springBootVersion=1.3.5.RELEASE
eventuateClientVersion=0.10.0.RELEASE eventuateClientVersion=0.12.0.RELEASE
eventuateLocalVersion=0.4.0.RELEASE eventuateLocalVersion=0.4.0.RELEASE