Skip to content

Instantly share code, notes, and snippets.

View AndrejGajdos's full-sized avatar

Andrej Gajdos AndrejGajdos

View GitHub Profile
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.activemq.ActiveMQConnectionFactory;
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
# use the following property to configure the default connector
java.naming.provider.url = tcp://localhost:61616
# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.MyTopic = example.MyTopic
@AndrejGajdos
AndrejGajdos / Server.java
Created January 16, 2016 21:05
ActiveMQ Broker
package activemq.test;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.core.config.Configuration;
import org.apache.activemq.core.config.impl.ConfigurationImpl;
import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory;
@AndrejGajdos
AndrejGajdos / MessageController.java
Created January 16, 2016 20:03
MessageController class
package gwt.user.server;
import org.jboss.errai.bus.client.api.base.MessageBuilder;
import org.jboss.errai.bus.client.api.messaging.Message;
import org.jboss.errai.bus.client.api.messaging.MessageBus;
import org.jboss.errai.bus.client.api.messaging.MessageCallback;
import org.jboss.errai.bus.server.annotations.Service;
import org.jboss.errai.bus.server.service.ErraiService;
import org.jboss.errai.bus.server.service.ErraiServiceSingleton;
@Service
@AndrejGajdos
AndrejGajdos / MessageController.java
Created January 16, 2016 19:59
Initializing MessageBus without RequestDispatcher
ErraiService<?> service = ErraiServiceSingleton.getService();
this.bus = service.getBus();
@AndrejGajdos
AndrejGajdos / web.xml
Created January 16, 2016 19:55
Property file definition
<context-param>
<param-name>ErraiApp.properties</param-name>
<param-value>WEB_INF/ErraiApp.properties</param-value>
</context-param>
@AndrejGajdos
AndrejGajdos / ErraiApp.properties
Created January 16, 2016 19:52
Dispatcher definition
#
# Request dispatcher implementation (default is SimpleDispatcher)
#
errai.dispatcher_implementation=org.jboss.errai.bus.server.SimpleDispatcher
@AndrejGajdos
AndrejGajdos / web.xml
Last active January 16, 2016 19:51
ErraiServlet definition
<servlet>
<servlet-name>ErraiServlet</servlet-name>
<servlet-class>org.jboss.errai.bus.server.servlet.DefaultBlockingServlet</servlet-class>
<init-param>
<param-name>auto-discover-services</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
@AndrejGajdos
AndrejGajdos / gwtErraiMessaging.gwt.xml
Created January 16, 2016 19:46
Initializing ErraiBus
<inherits name='org.jboss.errai.bus.ErraiBus' />
@AndrejGajdos
AndrejGajdos / ClientService.java
Created January 16, 2016 19:43
Subscribing message from server
bus.subscribe("ClientService", new MessageCallback() {
public void callback(Message message) {
Window.alert("ClientService message is received. " + message.get(String.class, "text"));
}
});