You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Devakumar J <ma...@gmail.com> on 2020/07/21 16:21:28 UTC

ContinuousQueryWithTransformer with custom return type

Hi,

I am trying to register CQ with transformer with keep binary option and
trying to return a cutom defined object. I see the transformer properly
creating custom object and returning properly.

But at the same time local listener is not receiving the custom object,
instead i think it received binary object. How can i ensure that local
listener is receiving custom object properly.

ContinuousQueryWithTransformer<BinaryObject, BinaryObject, ListenerEvent>
continuousQueryWithTransformer = new ContinuousQueryWithTransformer<>();

I want local listener to receive ListenerEvent (Custom defined object) as
below:

continuousQueryWithTransformer.setLocalListener(cacheEntryEvents ->
                            cacheEntryEvents.forEach(listenerEvent -> {
LOG.info("Event Received : {}", listenerEvent);}

But local listener throws BinaryObject cant cast to ListenerEvent.




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: ContinuousQueryWithTransformer with custom return type

Posted by Devakumar J <ma...@gmail.com>.
Thanks Denis for the information. That works well for me.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: ContinuousQueryWithTransformer with custom return type

Posted by Denis Magda <dm...@apache.org>.
Both the local listener and remote filter will return BinaryObjects as long
as the continuous query was registered with the "cache.withKeepBinary()"
option set.

However, there is a trick you can use in the implementation of the local
listener. Just call "deserialize()" method on the instance of a received
binary object:
https://github.com/GridGain-Demos/ignite-learning-by-examples/blob/master/complete/src/main/java/org/gridgain/examples/App4ContinousQueries.java#L76

-
Denis


On Tue, Jul 21, 2020 at 9:21 AM Devakumar J <ma...@gmail.com>
wrote:

> Hi,
>
> I am trying to register CQ with transformer with keep binary option and
> trying to return a cutom defined object. I see the transformer properly
> creating custom object and returning properly.
>
> But at the same time local listener is not receiving the custom object,
> instead i think it received binary object. How can i ensure that local
> listener is receiving custom object properly.
>
> ContinuousQueryWithTransformer<BinaryObject, BinaryObject, ListenerEvent>
> continuousQueryWithTransformer = new ContinuousQueryWithTransformer<>();
>
> I want local listener to receive ListenerEvent (Custom defined object) as
> below:
>
> continuousQueryWithTransformer.setLocalListener(cacheEntryEvents ->
>                             cacheEntryEvents.forEach(listenerEvent -> {
> LOG.info("Event Received : {}", listenerEvent);}
>
> But local listener throws BinaryObject cant cast to ListenerEvent.
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: ContinuousQueryWithTransformer with custom return type

Posted by akorensh <al...@gmail.com>.
Hi,
  Looks like you are not correctly setting up your code:
   Take a look at:
https://apacheignite.readme.io/docs/continuous-queries#remote-transformer
  see:  https://github.com/apache/ignite/blob/master/example
s/src/main/java/org/apache/ignite/examples/datagrid/CacheContinuousQueryWithTransformerExample.java

  If you are still having trouble send a full reproducer and I'll take a
look.
Thanks, Alex



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/