You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by daniels <ra...@gmail.com> on 2017/03/31 10:22:54 UTC

Stoppin listen for topics in Ignite

How to stop listen for topic in Ignite? 
I'm using https://apacheignite.readme.io/docs/messaging Topic Based
Messaging.
Everything works well,but I cant stop topic listening.

Ignite ignite = Ignition.start("ignite-config.xml");
		IgniteMessaging rmtMsg = ignite.message();

		rmtMsg.localListen("MyOrderedTopic", (nodeId, msg) -> {
			System.out.println("accepted");
			return true;
		});
        rmtMsg.send("MyOrderedTopic", "message");
        rmtMsg.stopLocalListen("MyOrderedTopic", (nodeId, msg) -> {
            System.out.println("stopped");
            return true;
        });
        rmtMsg.send("MyOrderedTopic", "message");



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by daniels <ra...@gmail.com>.
Thank you very much.You helped me a lot. 
p.s. Ignite is very powerfull. :-)



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11762.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by vkulichenko <va...@gmail.com>.
This doesn't make a lot of sense, because "during stop" is not defined. From
your code standpoint, stopListen() is an atomic "immediate" operation, and
any message can be received before of after this operation. You should call
stopListen() only if you don't intend to receive messages anymore.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11747.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by daniels <ra...@gmail.com>.
I mean all  concurrently sending messages . During stop I want to know
wheather there are messages being done in process so let them be done.And i
will execute by hand the ones that just came.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11738.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by dkarachentsev <dk...@gridgain.com>.
What do you mean saying "all messages"? How do you detect that all messages
were sent?

-Dmitry.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11724.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by daniels <ra...@gmail.com>.
Yes, I do it concurrently. I send messages concurrently. And before stopping
I want know whether listener called or not for all messages,if not before
stopping must wait for the working BiPredicate to finish and new coming ones
must collect for executing by hand.




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11708.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by vkulichenko <va...@gmail.com>.
Sorry, I don't understand. Why do you call stopListen if you still can
receive messages? Basically, if you do this concurrently, there is a race
condition and you don't know whether listener will be called or not for all
messages.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11684.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by daniels <ra...@gmail.com>.
Dear vkulichenko,I want to listen ignMessage.send  and IgnitePredicate
execution.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11656.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by Sandeep Malik <sa...@gmail.com>.
unsubscribe

On Sun, 2 Apr 2017 at 11:37 vkulichenko <va...@gmail.com>
wrote:

> Not sure I understood the question correctly, but if you want to listen for
> messages sent via IgniteMessaging API, refer to this documentation:
> https://apacheignite.readme.io/docs/messaging
>
> -Val
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11645.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Re: Stoppin listen for topics in Ignite

Posted by vkulichenko <va...@gmail.com>.
Not sure I understood the question correctly, but if you want to listen for
messages sent via IgniteMessaging API, refer to this documentation:
https://apacheignite.readme.io/docs/messaging

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11645.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by daniels <ra...@gmail.com>.
Thank you,everything works well!

An additional question- can I listen to IgniteMessage based events(such us
beforeExecuting,afterExecuting...),by adding listeners.




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11641.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Stoppin listen for topics in Ignite

Posted by vkulichenko <va...@gmail.com>.
You should provide the same instance of listener to stop method:

listener = (nodeId, msg) -> { ... }
rmtMsg.localListen("MyOrderedTopic", listener)
...
rmtMsg.stopLocalListen("MyOrderedTopic", listener)

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Stoppin-listen-for-topics-in-Ignite-tp11604p11631.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.