當前位置: 首頁>>代碼示例>>Java>>正文


Java SagaEventHandler類代碼示例

本文整理匯總了Java中org.axonframework.saga.annotation.SagaEventHandler的典型用法代碼示例。如果您正苦於以下問題:Java SagaEventHandler類的具體用法?Java SagaEventHandler怎麽用?Java SagaEventHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SagaEventHandler類屬於org.axonframework.saga.annotation包,在下文中一共展示了SagaEventHandler類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handle

import org.axonframework.saga.annotation.SagaEventHandler; //導入依賴的package包/類
@StartSaga
@SagaEventHandler(associationProperty = "userId")
public void handle(UserRegistered event) {

    System.out.println("A new user " + event.getPrefferedUsername() + " registered with the unconfirmed email  " + event.getEmailAddress() + ".");

    // compose and send out welcome and confirm email
    System.out.println("Sending out a confirmation email with email verification code: " + event.getEmailVerificationCode());
    ApplicationServiceRegistry.mailService().sendSignUpActivationMessage(
            event.getEmailAddress(),
            event.getPrefferedUsername(),
            event.getEmailVerificationCode()
    );

    // HACK: FIXME: TODO: 
    // auto-confirm users that fulfil some criteria
    autoConfirmTestUsersEmailAddress_HACK(event.getUserId(), event.getEmailAddress(), event.getEmailVerificationCode());
}
 
開發者ID:dma-graveyard,項目名稱:MaritimeCloudPortalTestbed,代碼行數:19,代碼來源:ConfirmEmailAddressSaga.java

示例2: handle

import org.axonframework.saga.annotation.SagaEventHandler; //導入依賴的package包/類
@StartSaga
@SagaEventHandler(associationProperty = "itemId")
public void handle(ProductPurchasedEvent event) {
    // identifiers
    String deliveryId = createDeliveryId();
    String invoiceId = createInvoiceId();
    // associate the Saga with these values, before sending the commands
    associateWith("shipmentId", deliveryId);
    associateWith("invoiceId", invoiceId);
    // send the commands
    commandGateway.send(new PrepareDeliveryCommand(deliveryId));
    commandGateway.send(new CreateInvoiceCommand(invoiceId));
}
 
開發者ID:feliciatucci,項目名稱:cqrs-sample,代碼行數:14,代碼來源:PurchaseManagementSaga.java

示例3: handle

import org.axonframework.saga.annotation.SagaEventHandler; //導入依賴的package包/類
@StartSaga
@SagaEventHandler(associationProperty = "bookId")
public void handle(BorrowEvent event) {
	popularityCount++;
	if (popularityCount == 5) {
		cmdGateway.send(new MarkBookHotCommand(event.getLibraryId(), event.getBookId()));
		end();
	}
}
 
開發者ID:yizhuan,項目名稱:library-saga,代碼行數:10,代碼來源:BookAdminSaga.java

示例4: handle

import org.axonframework.saga.annotation.SagaEventHandler; //導入依賴的package包/類
@StartSaga
@SagaEventHandler(associationProperty = "organizationId")
public void handle(OrganizationCreated event) {
    alias = event.getPrimaryAlias();
    System.out.println("AttachOrganizationAliasSaga: Emitted AddOrganizationAlias with alias " + alias + " for the organization " + event.getOrganizationId().identifier());
    commandGateway.send(new AddOrganizationAlias(event.getOrganizationId(), event.getPrimaryAlias()));
}
 
開發者ID:dma-graveyard,項目名稱:MaritimeCloudPortalTestbed,代碼行數:8,代碼來源:AttachOrganizationAliasSaga.java

示例5: handle

import org.axonframework.saga.annotation.SagaEventHandler; //導入依賴的package包/類
@StartSaga
@SagaEventHandler(associationProperty = "userId")
public void handle(ResetPasswordKeyGenerated event) {

    System.out.println("User " + event.getUsername() + " has requested to reset password using " + event.getEmailAddress() + ".");

    // compose and send out welcome and confirm email
    System.out.println("Sending out reset password instruction email with the reset password key: " + event.getResetPasswordKey());

    mailService().sendResetPasswordMessage(event.getEmailAddress(), event.getUsername(), event.getResetPasswordKey());

    // HACK: FIXME: TODO: 
    // auto-confirm users that fulfil some criteria
    autoResetTestUsersPassword_HACK(event.getUserId(), event.getEmailAddress(), event.getResetPasswordKey());
}
 
開發者ID:dma-graveyard,項目名稱:MaritimeCloudPortalTestbed,代碼行數:16,代碼來源:ResetPasswordSaga.java

示例6: handle

import org.axonframework.saga.annotation.SagaEventHandler; //導入依賴的package包/類
@StartSaga
@SagaEventHandler(associationProperty = "organizationId")
public void handle(OrganizationCreated event, @MetaData(UserMetaData.USERNAME) String username) {
    commandGateway.send(new AuthorizeMembershipToOrganizationCreator(event.getOrganizationId(), new MembershipId(event.getOrganizationId().identifier()), username));
    end();
}
 
開發者ID:dma-graveyard,項目名稱:MaritimeCloudPortalTestbed,代碼行數:7,代碼來源:SetupOrganizationOwnerMemberSaga.java


注:本文中的org.axonframework.saga.annotation.SagaEventHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。