Skip to content

Instantly share code, notes, and snippets.

@patelm5
patelm5 / gist:4e4f82e62ccd230a00cf
Created January 8, 2016 14:12
Gist of forwarding actor test
@Test
public void shouldForwardLookupMessageLookupActor(){
createActorWithPath("lookup-source-"+SOURCE_ID, testProbe);
ActorRef ref = testProbe.ref();
lookupActor.tell(new GetContent(SOURCE_ID, SYSTEM_ENTRY_TIME), ref);
LookupResponse actual = testProbe.expectMsgClass(LookupResponse.class);
@patelm5
patelm5 / jackson-docs
Created February 28, 2014 10:38
Enum deserialization override with some class information stored.
DeserializerFactory withAdditionalDeserializers = BeanDeserializerFactory.instance.withAdditionalDeserializers(setupEnumDeserializer());
DefaultDeserializationContext.Impl dc = new DefaultDeserializationContext.Impl(withAdditionalDeserializers);
ObjectMapper defaultMapper = new ObjectMapper(null, null, dc);
private Deserializers setupEnumDeserializer() {
Deserializers d = new Deserializers.Base() {
@Override
@patelm5
patelm5 / self-signed-trust-cert
Created February 5, 2014 10:31
Example of overridding self signed cert process in spring.
@Component
@Profile("untrusted")
public class SelfSignedTrustCertConfigurer {
private final static Logger logger = LoggerFactory.getLogger(SelfSignedTrustCertConfigurer.class.getName());
@PostConstruct
public void allowUntrustedCerts() {
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
@patelm5
patelm5 / gist:8617580
Created January 25, 2014 14:55
JMeter plugin sample configuration.
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.9.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
@patelm5
patelm5 / gist:4564224
Last active December 11, 2015 07:08
subscribe object example.
function subscriber(){
var socket = $.atmosphere;
var subSocket;
var model = [] ;
var obj = {
getModel : function(){ return model ; },
subscribe : function(){
var request = { url : document.location.toString()+'atmosphere/?channelId=12351',
@patelm5
patelm5 / gist:4531699
Created January 14, 2013 17:27
Broadcast Listener for rabbitmq
@Component("broadcastQueueConsumer")
public class BroadcastListener implements MessageListener{
private final static Logger logger = Logger.getLogger(BroadcastListener.class.getName());
@Autowired
private SimpleMessageConverter messageAdapter ;
@Autowired
private BroadcastService broadcastService;
@patelm5
patelm5 / gist:4531634
Last active December 11, 2015 02:38
pom dependency spring rabbitmq
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
@patelm5
patelm5 / gist:4531624
Last active December 11, 2015 02:38
sample spring rabbit configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.org/schema/rabbit" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host:localhost}" port="${rabbitmq.port:5672}"
username="guest" password="guest" connection-factory="rcf" />
@patelm5
patelm5 / gist:4531571
Last active December 11, 2015 02:38
Simple Broadcast Service for Atmosphere.
@Service
public class BroadcastService {
private final static Logger logger = Logger.getLogger(BroadcastService.class.getName());
private Map<String, Broadcaster> broadcastTokens = new ConcurrentHashMap<String, Broadcaster>();
public void broadcast(String message) {
for (Broadcaster token : broadcastTokens.values()) {
token.broadcast(message);
@patelm5
patelm5 / gist:4531403
Last active December 11, 2015 02:29
atmosphere servlet example
<!-- Atmosphere -->
<servlet>
<description>AtmosphereServlet</description>
<servlet-name>AtmosphereServlet</servlet-name>
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterLifeCyclePolicy</param-name>
<param-value>EMPTY_DESTROY</param-value>