BEE the Apache ActiveMQ JMS, TomEE/Tomcat JMS wrapper - Page 4
Example 1: initialize BEE

BEE initialize with a single external broadcast channel. The channel is called "ORDERS", probably because it concern the subject of the orders. The types of messages (or conversational words list) are three: "MODIFY", "CREATE", "DELETE".

Beepin beepin = null;
try {
  InitialContext context = new InitialContext();
  beepin = (Beepin)context.lookup("java:global/xxxx/Beepin"); // get a Beepin instance
  beepin.initialize("AppExample", "localhost", "66661", "login", "password"); // initialize BEE
  String[] msgTypes = {"MODIFY","CREATE","DELETE"};
  beepin.addChanel("ORDERS", ChannelType.FOREIGNCHANNEL, msgTypes); // add the foreign broadcast channel
} catch (NamingException | BeeParameterEmptyException e){
} catch (BeeChannelAlreadyExistsException e) {

Example 2: subscribe to listening to a channel

Subscribe to the broadcast channel "ORDERS" created at initialization time (cf. example 1).

1. We declare a class that implements a BeeListener interface:

public class ClientListener implements BeeListener {
  public void onStringMessage(String msg, String sndrID, String msgType) {
    // prosessing when a string message is received
  public void onObjectMessage(Object obj, String sndrID, String msgType) {
    // prosessing when an objet message is received

2. We call the subscribe method of Beepin

private ClientListener clientListener // listener bean declared in 1.
beepin.subscribe("AppExample", "ORDERS", clientListener); // subscribe to listen channel ORDERS