Skip to content

Commit

Permalink
Async Listener Template
Browse files Browse the repository at this point in the history
  • Loading branch information
Li Wang committed Jul 2, 2015
1 parent 32d074d commit e931eb3
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AsyncEventListener/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand Down
1 change: 1 addition & 0 deletions AsyncEventListener/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
4 changes: 2 additions & 2 deletions AsyncEventListener/.project
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.springframework.ide.eclipse.core.springbuilder</name>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
33 changes: 33 additions & 0 deletions AsyncEventListener/config/server-cache.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<!DOCTYPE cache PUBLIC
"-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN"
"http://www.gemstone.com/dtd/cache8_0.dtd">

<cache>
<async-event-queue id="sampleQueue" batch-size="10"
batch-time-interval="20000" parallel="true" dispatcher-threads="5">
<async-event-listener>
<class-name>io.pivotal.listener.MyEventListener</class-name>
</async-event-listener>
</async-event-queue>

<pdx read-serialized="true">
<pdx-serializer>
<class-name>com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer</class-name>
<parameter name="classes">
<string>io.pivotal.domain.*</string>
</parameter>
</pdx-serializer>
</pdx>

<region name="Customer">
<region-attributes data-policy="partition"
statistics-enabled="true" concurrency-level="16"
async-event-queue-ids="sampleQueue">
<partition-attributes redundant-copies="1"
total-num-buckets="113" />
</region-attributes>
</region>

</cache>

Binary file added AsyncEventListener/lib/EventListener.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
package io.pivotal.listener;

import io.pivotal.domain.Customer;

import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.gemstone.gemfire.cache.Declarable;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEvent;
import com.gemstone.gemfire.cache.asyncqueue.AsyncEventListener;
import com.gemstone.gemfire.pdx.PdxInstance;

public class MyEventListener implements AsyncEventListener, Declarable {

@Override
public boolean processEvents(List<AsyncEvent> arg0) {
// TODO Auto-generated method stub
return false;
public boolean processEvents(@SuppressWarnings("rawtypes") List<AsyncEvent> entries) {
for (@SuppressWarnings("rawtypes") AsyncEvent ge : entries) {

PdxInstance pdxInstance = (PdxInstance) ge.getDeserializedValue();
Customer cus = (Customer) pdxInstance.getObject();

System.out.println(cus.toString());
}

return true;
}

@Override
Expand Down
22 changes: 22 additions & 0 deletions AsyncEventListener/src/main/resources/config/cache.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!DOCTYPE cache PUBLIC
"-//GemStone Systems, Inc.//GemFire Declarative Caching 8.0//EN"
"http://www.gemstone.com/dtd/cache8_0.dtd">

<cache>

<pdx read-serialized="false">
<pdx-serializer>
<class-name>com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer</class-name>
<parameter name="classes">
<string>io.pivotal.domain.*</string>
</parameter>
</pdx-serializer>
</pdx>

<region name="Customer">
<region-attributes refid="REPLICATE" />
</region>

</cache>

Binary file not shown.

0 comments on commit e931eb3

Please sign in to comment.