Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Question about Java/Scala interface #87

Open
ralphejohnson opened this issue Apr 18, 2017 · 2 comments
Open

Question about Java/Scala interface #87

ralphejohnson opened this issue Apr 18, 2017 · 2 comments

Comments

@ralphejohnson
Copy link

I'm a longtime Java programmer. I've never programmed in Scala, though I have read papers that had short Actor programs using Akka/Scala, and figured it wouldn't be that hard to figure out how to use the JVM EventStore interface. I'm gradually figuring things out, but am not yet successful. The examples don't do anything with the Events that they read, and I couldn't figure out how to get the data out of it. For one kind of message, I have binary data. I eventually figured out that given an event e, I could use e.data().data().value().toArray() to get the binary data back. Not the most intuitive, and maybe not the best way. But my real point is that it would be nice to see some Java examples that actually used the data in events. Events are Scala objects, not Java objects, and it is not trivial for a Java programmer to figure out how to access them.

The ExConnection interface uses EventNumber, which is a Scala definition. How do you make an EventNumber in Java? I tried EventNumber.Exact(_nextTransaction) but it doesn't like any of the types I choose for _nextTransaction. It apparently wants a Scala integer. How do I convert a Java integer into a Scala integer?

EsConnection.readEvent produces a future. However, I want the value of the future. How do I wait til the future "arrives" and get the event? Again, if the examples were just a little more complicated and actually did something with the event then it would probably be obvious.

@t3hnar
Copy link
Contributor

t3hnar commented Apr 19, 2017

Hi @ralphejohnson

But my real point is that it would be nice to see some Java examples that actually used the data in events. Events are Scala objects, not Java objects, and it is not trivial for a Java programmer to figure out how to access them.

Is there concrete Scala example you'd like to see translated in Java?

The ExConnection interface uses EventNumber, which is a Scala definition. How do you make an EventNumber in Java? I tried EventNumber.Exact(_nextTransaction) but it doesn't like any of the types I choose for _nextTransaction. It apparently wants a Scala integer. How do I convert a Java integer into a Scala integer?

have you tried new EventNumber.Exact(_nextTransaction) ?

EsConnection.readEvent produces a future. However, I want the value of the future. How do I wait til the future "arrives" and get the event? Again, if the examples were just a little more complicated and actually did something with the event then it would probably be obvious.

I suppose this might help http://doc.akka.io/docs/akka/2.5.0/java/futures.html

@Mousaka
Copy link

Mousaka commented Apr 20, 2017

I am also having problems instantiating some classes. I cannot manage to use the method createProjection in ProjectionsClient because I cannot create a valid value for the ProjectionMode-parameter. This is my attempt:

final ProjectionsClient client = new ProjectionsClient(settings, system);
final String result = client.createProjection(projectionName, projectionCode, ProjectionsClient.ProjectionMode.OneTime, true);

What does not work here is ProjectionsClient.ProjectionMode.OneTime. I tried looking for constructors, constants or methods that gives a ProjectionMode but I cannot find anything.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants