Tibco RV Sample Listener

import org.apache.log4j.Logger;

import util.ConfigUtil;
import util.Constants;

import com.barcap.bondscape.monitor.PriceUpdateMonitor;
import com.tibco.tibrv.Tibrv;
import com.tibco.tibrv.TibrvDispatcher;
import com.tibco.tibrv.TibrvException;
import com.tibco.tibrv.TibrvListener;
import com.tibco.tibrv.TibrvMsg;
import com.tibco.tibrv.TibrvMsgCallback;
import com.tibco.tibrv.TibrvQueue;
import com.tibco.tibrv.TibrvRvdTransport;
import com.tibco.tibrv.TibrvTransport;


public class PriceListener implements TibrvMsgCallback, Constants
{
 Logger logger = Logger.getLogger(PriceListener.class);

 
 @Override
 public void onMsg(TibrvListener listener, TibrvMsg message)
 {
  try
  {
   if (message.get("ISIN") == null || message.get("RMDSSERVICE") == null || message.get("RICCODE") == null)
   {
    logger.error("ISIN or RMDSSERVICE or RICCODE is null");
    return;
   }
   String ricCode = message.get("ISIN").toString();
   String price = message.get("HOUSEPRICE").toString();
   logger.debug("ric:" + ricCode);
   logger.debug("housePrice:" + price);
  }
  catch (Exception e)
  {
   logger.error("exception while listening to prices" + e);
  }
 }
 
 public PriceListener()
 {
  String tibcoService = ConfigUtil.getValue(TIBCO_SERVICE);
  String tibcoNetwork = ConfigUtil.getValue(TIBCO_NETWORK);
  String tibcoDaemon = ConfigUtil.getValue(TIBCO_DAEMON);
  String tibcoSubject = ConfigUtil.getValue(TIBCO_SEND_SUBJECT);
  
  try
  {
   Tibrv.open(Tibrv.IMPL_NATIVE);
   TibrvTransport transport = new TibrvRvdTransport(tibcoService, tibcoNetwork, tibcoDaemon);
   TibrvQueue queue = new TibrvQueue();
   new TibrvListener(queue, this, transport, tibcoSubject, null);
   new TibrvDispatcher(queue);
   logger.debug("tibco rv connection successfully constructed!!");
  }
  catch (TibrvException e)
  {
   logger.error("Failed to start up price listener", e);
   System.exit(-1);
  }
 }
}

你可能感兴趣的:(apache,log4j,UP)