Re: Java interop: dealing with Java implementation instances vs interfaces

2016-10-17 Thread Aaron Cohen
My guess is that you're getting a message related to there being no
overload of the Producer.send method that accepts a String.

In your Java code, you're calling String.getBytes you need to do the same
in you Clojure code.

--Aaron

On Sun, Oct 16, 2016 at 2:42 AM, hiskennyness  wrote:

> Not sure if this is a Java question or Clojure question, but I think it is
> the latter.
>
> I am trying to use the Yahoo pulsar library https://mvnrepository.
> com/artifact/com.yahoo.pulsar/pulsar-client/1.14 from Clojure.
>
> It is going OK in general, but a couple times now trying to replicate Java
> code such as:
>
> Producer producer = client.createProducer("persistent://sample/
> standalone/ns1/my-topic");
>
> ..with:
>
>   (let [prod (.createProducer client "persistent://sample/
> standalone/ns1/ktopic")]
> )
>
> ...all goes well except I end up with prod bound to an instance of
> ProducerImpl.
>
> My Java is zilch but I presume the Java code binding the impl to a var
> type Producer is why the code can then execute:
>
> producer.send("my-message".getBytes());
>
> ...whereas I get an error about send not being defined when I do:
>
> (.send prod "Hi Mom")
>
> I looked around for a way to "cast" the impl to a Producer but came up
> empty.
>
> I did find a public sendAsync on ProducerImpl and that almost worked but
> then I ran into the same impl vs interface issue with another class
> (MessageBuilder) and decided I better figure this issue out once and for
> all.
>
> Any ideas?
>
> -kt
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Java interop: dealing with Java implementation instances vs interfaces

2016-10-16 Thread hiskennyness


On Sunday, October 16, 2016 at 3:35:30 AM UTC-4, Erik Assum wrote:
>
> I think the method you're looking for is sendAsync. 
>

Thx, yeah, I did that then ran into the same issue (I thought) trying to 
deal with the MessageBuilder mechanism so I thought I should come to grips 
with the general case.

Turns out i am a twit: The undefined method error arose because I was 
passing in a string and Producer/send is defined for a byte array.

Sorry for the noise.

-kt
 

>
> As for binding yourself to the implementation, you should stick to 
> whatever interface getProducer says it returns, and you'll be ok. 
>
> Erik. 
> -- 
> i farta
>
> Den 16. okt. 2016 kl. 08.42 skrev hiskennyness  >:
>
> Not sure if this is a Java question or Clojure question, but I think it is 
> the latter.
>
> I am trying to use the Yahoo pulsar library 
> https://mvnrepository.com/artifact/com.yahoo.pulsar/pulsar-client/1.14 
> from Clojure.
>
> It is going OK in general, but a couple times now trying to replicate Java 
> code such as:
>
> Producer producer = client.createProducer(
> "persistent://sample/standalone/ns1/my-topic");
>
> ..with:
>
>   (let [prod (.createProducer client 
> "persistent://sample/standalone/ns1/ktopic")]
> )
>
> ...all goes well except I end up with prod bound to an instance of 
> ProducerImpl.
>
> My Java is zilch but I presume the Java code binding the impl to a var 
> type Producer is why the code can then execute:
>
> producer.send("my-message".getBytes());
>
> ...whereas I get an error about send not being defined when I do:
>
> (.send prod "Hi Mom")
>
> I looked around for a way to "cast" the impl to a Producer but came up 
> empty.
>
> I did find a public sendAsync on ProducerImpl and that almost worked but 
> then I ran into the same impl vs interface issue with another class 
> (MessageBuilder) and decided I better figure this issue out once and for 
> all.
>
> Any ideas?
>
> -kt
>
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com 
> Note that posts from new members are moderated - please be patient with 
> your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com 
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+u...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Java interop: dealing with Java implementation instances vs interfaces

2016-10-16 Thread Erik Assum
I think the method you're looking for is sendAsync. 

As for binding yourself to the implementation, you should stick to whatever 
interface getProducer says it returns, and you'll be ok. 

Erik. 
-- 
i farta

> Den 16. okt. 2016 kl. 08.42 skrev hiskennyness :
> 
> Not sure if this is a Java question or Clojure question, but I think it is 
> the latter.
> 
> I am trying to use the Yahoo pulsar library 
> https://mvnrepository.com/artifact/com.yahoo.pulsar/pulsar-client/1.14 from 
> Clojure.
> 
> It is going OK in general, but a couple times now trying to replicate Java 
> code such as:
> 
> Producer producer = 
> client.createProducer("persistent://sample/standalone/ns1/my-topic");
> 
> ..with:
> 
>   (let [prod (.createProducer client 
> "persistent://sample/standalone/ns1/ktopic")]
> )
> 
> ...all goes well except I end up with prod bound to an instance of 
> ProducerImpl.
> 
> My Java is zilch but I presume the Java code binding the impl to a var type 
> Producer is why the code can then execute:
> 
> producer.send("my-message".getBytes());
> 
> ...whereas I get an error about send not being defined when I do:
> 
> (.send prod "Hi Mom")
> 
> I looked around for a way to "cast" the impl to a Producer but came up empty.
> 
> I did find a public sendAsync on ProducerImpl and that almost worked but then 
> I ran into the same impl vs interface issue with another class 
> (MessageBuilder) and decided I better figure this issue out once and for all.
> 
> Any ideas?
> 
> -kt
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Java interop: dealing with Java implementation instances vs interfaces

2016-10-16 Thread hiskennyness
Not sure if this is a Java question or Clojure question, but I think it is 
the latter.

I am trying to use the Yahoo pulsar 
library https://mvnrepository.com/artifact/com.yahoo.pulsar/pulsar-client/1.14 
from Clojure.

It is going OK in general, but a couple times now trying to replicate Java 
code such as:

Producer producer = client.createProducer(
"persistent://sample/standalone/ns1/my-topic");

..with:

  (let [prod (.createProducer client 
"persistent://sample/standalone/ns1/ktopic")]
)

...all goes well except I end up with prod bound to an instance of 
ProducerImpl.

My Java is zilch but I presume the Java code binding the impl to a var type 
Producer is why the code can then execute:

producer.send("my-message".getBytes());

...whereas I get an error about send not being defined when I do:

(.send prod "Hi Mom")

I looked around for a way to "cast" the impl to a Producer but came up 
empty.

I did find a public sendAsync on ProducerImpl and that almost worked but 
then I ran into the same impl vs interface issue with another class 
(MessageBuilder) and decided I better figure this issue out once and for 
all.

Any ideas?

-kt



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.