IDDD_Samples icon indicating copy to clipboard operation
IDDD_Samples copied to clipboard

Can't enable Mysql in EventStoreProvider

Open xxRockOnxx opened this issue 7 years ago • 1 comments

I tried setting FOR_MYSQL to true and FOR_LEVELDB to false but the test would not proceed because of null exception.

If you trace these lines:

  • https://github.com/VaughnVernon/IDDD_Samples/blob/master/iddd_collaboration/src/main/java/com/saasovation/collaboration/port/adapter/event/FollowStoreEventDispatcher.java#L47
  • https://github.com/VaughnVernon/IDDD_Samples/blob/master/iddd_collaboration/src/main/java/com/saasovation/collaboration/port/adapter/persistence/EventStoreProvider.java#L54
  • https://github.com/VaughnVernon/IDDD_Samples/blob/05d95572f2ad6b85357b216d7d617b27359a360d/iddd_common/src/main/java/com/saasovation/common/port/adapter/persistence/eventsourcing/mysql/MySQLJDBCEventStore.java#L50

The instance is not initialized.

I tried putting mysqlJdbcEventStore before followStoreEventDispatcher in applicationContext-collaboration.xml so that the mysql is initialized first but it's not working also.

I am not a java guy so I dont actually know what's happening.

I would like to try MySQL instead of LevelDB.

xxRockOnxx avatar May 08 '19 12:05 xxRockOnxx

I managed to find a solution but again however, I am not a java guy. In the applicationContext-collaboration.xml, I added an attribute to some beans:

<bean id="forumRepository" class="com.saasovation.collaboration.port.adapter.persistence.repository.EventStoreForumRepository" depends-on="mysqlJdbcEventStore" />

<bean id="mysqlJdbcEventStore" class="com.saasovation.common.port.adapter.persistence.eventsourcing.mysql.MySQLJDBCEventStore" depends-on="collaborationDataSource" >

Good thing the Spring used here is v3 which is when the depends-on attribute becomes available according to: https://stackoverflow.com/a/7868418/10975709

xxRockOnxx avatar May 08 '19 12:05 xxRockOnxx