Skip to content

Instantly share code, notes, and snippets.

@jgl-jll
Last active May 29, 2016 06:53
Show Gist options
  • Save jgl-jll/f48a2c0aa58ff8fd0d2fb2f526d618de to your computer and use it in GitHub Desktop.
Save jgl-jll/f48a2c0aa58ff8fd0d2fb2f526d618de to your computer and use it in GitHub Desktop.
Apache Ignite - Queue Configuration
I have a simple main program:
public static void main(String[] args) throws Exception {
System.out.println("STARTING=========>");
Ignite ignite = Ignition.start("example-ignite.xml");
System.out.println("getCollisionSpi:getNodeAttributes" + ignite.configuration().getCollisionSpi().getNodeAttributes());
System.out.println("getCollisionSpi:getFailoverSpi" + ignite.configuration().getFailoverSpi());
IgniteMessaging rmtMsg = ignite.message();
UUID uuid = null;
List<UUID> uuids = new ArrayList<>();
for (int i = 0; i < 5; i++) {
System.out.println("Starting Listen: " + i);
uuid = rmtMsg.remoteListen("QUEUE", (nodeId, msg) -> {
System.out.println("Received unordered message [msg=" + msg + ", from=" + nodeId + ']');
return true; // Return true to continue listening.
});
uuids.add(uuid);
}
// Send unordered messages to remote nodes.
for (int i = 0; i < 1; i++) {
rmtMsg.send("QUEUE", Integer.toString(i));
}
System.out.println("DONE=========>");
uuids.forEach(id -> {
rmtMsg.stopRemoteListen(id);
});
System.out.println("GOOD BYE!");
System.exit(0);
...and the sample Spring configuration files are being used, I added: the JobStealingFailoverSpi and JobStealingCollisionSpi within the IgniteConfiguration bean:
<property name="failoverSpi">
<bean class="org.apache.ignite.spi.failover.jobstealing.JobStealingFailoverSpi">
<property name="maximumFailoverAttempts" value="5"/>
</bean>
</property>
<property name="collisionSpi">
<bean class="org.apache.ignite.spi.collision.jobstealing.JobStealingCollisionSpi">
<property name="activeJobsThreshold" value="100"/>
<property name="waitJobsThreshold" value="0"/>
<property name="messageExpireTime" value="1000"/>
<property name="maximumStealingAttempts" value="10"/>
<property name="stealingEnabled" value="true"/>
<property name="stealingAttributes">
<map>
<entry key="node.segment" value="foobar"/>
</map>
</property>
</bean>
</property>
But my results are that the 5 remote listener threads each get a message, instead only 1:LOGS:
>>> Ignite ver. 1.6.0#20160518-sha1:0b22c45bb9b97692208fd0705ddf8045ff34a031
>>> +----------------------------------------------------------------------+
>>> OS name: Mac OS X 10.11.5 x86_64
>>> CPU(s): 8
>>> Heap: 0.54GB
>>> VM name: 2685@Jacob-Ll-MacBook-Pro.local
>>> Local node [ID=BA0614C6-D6CA-4EDD-B677-85D10F5DAEFE, order=1, clientMode=false]
>>> Local node addresses: [10.1.230.94/0:0:0:0:0:0:0:1, 10.0.0.5/10.0.0.5, /10.1.230.94, /127.0.0.1]
>>> Local ports: TCP:11211 TCP:47100 UDP:47400 TCP:47500 TCP:48100
[19:49:37,265][INFO ][main][GridDiscoveryManager] Topology snapshot [ver=1, servers=1, clients=0, CPUs=8, heap=0.54GB]
getCollisionSpi:getNodeAttributes{JobStealingCollisionSpi.ignite.collision.wait.jobs.threshold=0, JobStealingCollisionSpi.ignite.stealing.max.attempts=10, JobStealingCollisionSpi.ignite.collision.active.jobs.threshold=100, JobStealingCollisionSpi.ignite.stealing.msg.expire.time=1000}
getCollisionSpi:getFailoverSpi[Lorg.apache.ignite.spi.failover.FailoverSpi;@1095f122
Starting Listen: 0
[19:49:37,351][INFO ][main][GridDeploymentLocalStore] Class locally deployed: class com.level11.jms.demo.codesamples.Sample
Starting Listen: 1
Starting Listen: 2
Starting Listen: 3
Starting Listen: 4
Received unordered message [msg=0, from=ba0614c6-d6ca-4edd-b677-85d10f5daefe]
Received unordered message [msg=0, from=ba0614c6-d6ca-4edd-b677-85d10f5daefe]
Received unordered message [msg=0, from=ba0614c6-d6ca-4edd-b677-85d10f5daefe]
Received unordered message [msg=0, from=ba0614c6-d6ca-4edd-b677-85d10f5daefe]
Received unordered message [msg=0, from=ba0614c6-d6ca-4edd-b677-85d10f5daefe]
DONE=========>
GOOD BYE!
[19:49:37,374][INFO ][Thread-3][G] Invoking shutdown hook...
[19:49:37,379][INFO ][Thread-3][GridTcpRestProtocol] Command protocol successfully stopped: TCP binary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment