Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DisruptorCommandBus has a CommandResult of null #1083

Open
e-sen opened this issue May 7, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@e-sen
Copy link

commented May 7, 2019

Hi,User the disruptor command bus I get the CommandResult is Null

This is the Demo

Env

AxonFrameworkVersion: 4.1.1
JDK:Java8

@smcvb smcvb added this to the Release 4.2 milestone May 7, 2019

@smcvb smcvb changed the title Bug: DisruptorCommandBus CommandResult is null DisruptorCommandBus has a CommandResult of null May 7, 2019

@smcvb

This comment has been minimized.

Copy link
Member

commented May 7, 2019

Thanks for filing this bug @e-sen. I've tested this out locally as well and ended up to the same conclusion as you've described.
I'll ensure we'll fix this issue ASAP.

Regarding your demo project by the way, I would encourage to put the @CommandHandler annotation directly on your Aggregate. This will alleviate the necessary boiler plate code to call the Repository yourself.

@smcvb smcvb self-assigned this May 7, 2019

@e-sen

This comment has been minimized.

Copy link
Author

commented May 8, 2019

@smcvb Thanks,Waiting for your good news . :-)

Use the external Command Handlers , Because I want use the common service out of Aggregate.

such as

interface CommonService {

    fun currentTimeMillis(): Long

    fun generateIdentifier(): String

}

@Component
class UserCommandHandler(
        val repository: Repository<User>,
        val commonService:CommonService
) {

    @CommandHandler
    fun handle(command: CreateUserCommand): String {
        repository.newInstance {
            User(userId = command.userId, time = commonService.currentTimeMillis())
        }
        return command.userId
    }

}

if I @Autowired In the Aggregate

@Aggregate
class User {

    @AggregateIdentifier
    lateinit var userId: String

    @JsonIgnore
    @Transient
    @Autowired
    lateinit var commonService:CommonService

    constructor()

    constructor(userId: String) {
        AggregateLifecycle.apply(UserCreatedEvent(userId = userId, time = commonService.currentTimeMillis()))
    }

    @EventHandler
    fun on(event: UserCreatedEvent) {
        this.userId = event.userId
    }

}

That will get error commonService not init ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.