Open VledicFranco opened 5 years ago
It was found that it is not lambda specific, this will also break it:
val reserveItemsInstance: InteractionInstance = InteractionInstance.unsafeFrom(
new ReserveItems {
def apply(orderId: String, items: List[String]): Future[WebshopRecipeReflection.ReserveItemsOutput] = {
// Http call to the Warehouse service
val response: Future[Either[List[String], List[String]]] =
// This is mocked for the sake of the example
Future.successful(Right(items))
// Build an event instance that Baker understands
response.map {
case Left(unavailableItems) =>
WebshopRecipeReflection.OrderHadUnavailableItems(unavailableItems)
case Right(reservedItems) =>
WebshopRecipeReflection.ItemsReserved(reservedItems)
}
}
}
)
Also in Java interactions must be direct class instances, if they are a reference to other class members or to static attributes, the Interactionmanager can't access them
Not sure if my issue is rooted in same cause but sounds close so posting here first.
Have interaction
s that use SessionId
as ingredient
.
case class SessionId(value: java.util.UUID) extends AnyVal
At runtime am getting "No implementation provided for interaction". Tried to trace in debugger and seems the issue is the mismatch between these
RecordType(WrappedArray(RecordField(mostSigBits,Int64), RecordField(leastSigBits,Int64)))
RecordType(WrappedArray(RecordField(value,RecordType(WrappedArray(RecordField(mostSigBits,Int64), RecordField(leastSigBits,Int64))))))
Sounds like the UUID value
gets unwrapped. :thinking:
Does this make any sense to you?
Is my design of interaction
valid (taking case classes as ingredient
s?
I do use complex case classes as ingredient
s and they do not cause this issue.
UPDATE: Solved. This was caused by SessionId
being an AnyVal
.
Implementing an interaction by creating an interface, instantiating the interface with a lambda, and then using the reflection API to create an
InteractionInstance
blows into a runtime exception WHEN the ingredients have a higher kinded type like List[A]. This is because the lambda instantiation of the interface erases the parametrized type. See example below: