标签:
消息很简单,跟其他的mq相仿,关键点:
一,添加监听,订阅主题
二,发送消息
写了一个简单的示例:
Receiver.java
package test.ignite.broadcast; import java.util.UUID; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteMessaging; import org.apache.ignite.Ignition; import org.apache.ignite.lang.IgniteBiPredicate; public class Receiver { public static void main(String[] args) { System.out.println("======================================================"); Ignite ignite = Ignition.start("ignite.xml"); IgniteMessaging msg = ignite.message(); msg.localListen("aaa", new IgniteBiPredicate<UUID, Integer>() { @Override public boolean apply(UUID nodeId, Integer funId) { System.out.println(funId); return true; } }); } }
Sender.java
package test.ignite.broadcast; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCache; import org.apache.ignite.IgniteMessaging; import org.apache.ignite.Ignition; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.transactions.Transaction; public class Sender { public static void main(String[] args) { Ignition.setClientMode(true); Ignite ignite = Ignition.start("ignite.xml"); IgniteMessaging msg = ignite.message(); msg.sendOrdered("aaa", 100,0); } }
see what do we get...
标签:
原文地址:http://www.cnblogs.com/garfieldcgf/p/5664218.html