I created a subject like this
val subject: Subject = Subject.SubjectBuilder()
Where seeker.subjectId is a string.
This is the client I’m using.
val client = OkHttpClient.Builder()
val adapter: HttpClientAdapter = OkHttpClientAdapter.builder()
where ‘collector’ is my collector’s URL. also string.
This is my emitter
val emitter: Emitter = BatchEmitter.builder()
This is the tracker
val tracker: Tracker = Tracker.TrackerBuilder(emitter, “AF003”, “cf”)
I’m trying to use an Unstructured event with this code
If this is a simple console application, then the BatchEmitter works asynchronously, meaning the app might quit before the event ever sends. The SimpleEmitter blocks until the event sends which perhaps explains why it is working now.
One thing to try with the BatchEmitter is to close it when you’re done (Only do this once though, you shouldn’t do this everytime you send an event, it should be called on application shutdown).
This is the OkHttpClientAdapter.java. We are using Kotlin. What could be the issue? Is this Kotlin compatible? In our okhttp3 package, there is no create method with that input types. (string, media type) is always the other way around (media type, string).
This is our payload (We are using a BufferSize of 2 for testing purposes)
So digging a little deeper, it looks like we’re actually already using the new companion object method as the OkHttp docs suggest. The line which you’re seeing an error on is what OkHttp marks as the current API as far as I can see.
Could you comfirm the version of OkHttp you’re using? This switch of API was introduced in OkHttp3 v4, you’ll need to be on at least v4 but I assume it’d work with OkHttp3 v4.
Thanks for your help Paul,
We updated our okhttp3 to version 4, that fixed the issue.
But, we still get an error in the okHttpClientAdapter.java
I’ve been trying to fix the import myself but nothing works, What could be the issue now?
I think you’ve found a missing dependency there. Older versions of OkHttp3 used to include Apache HttpComponents HttpClient which would have pulled in this dependency.
When we upgraded to v4 of OkHttp3, it looks like this has been missed. We have an optional Apache Http support so it doesn’t fail in our builds. In reality we don’t need this at all any more so I’ve opened an issue on our GitHub repo to address this.