TibPublisher

package publisher;

import com.tibco.tibrv.Tibrv;
import com.tibco.tibrv.TibrvException;
import com.tibco.tibrv.TibrvMsg;
import com.tibco.tibrv.TibrvRvdTransport;

import constants.Constants;

public class TibPublisher implements Constants
{

  private TibrvRvdTransport transport = null;

  public TibPublisher()
  {
    try
    {
      Tibrv.open(Tibrv.IMPL_NATIVE);
      transport = new TibrvRvdTransport(tibcoService, tibcoNetwork, tibcoDaemon);
    }
    catch (TibrvException e)
    {
      e.printStackTrace();
    }
  }

  public void publish(String sendMessage)
  {
    try
    {
      TibrvMsg msg = new TibrvMsg();
      msg.setSendSubject(tibcoSubject);
      msg.add("msg", sendMessage);
      transport.send(msg);
    }
    catch (TibrvException e)
    {
      e.printStackTrace();
    }
  }

  public static void main(String[] args)
  {
    TibPublisher tibPublisher = new TibPublisher();
    tibPublisher.publish("Hello, World");
  }
}

你可能感兴趣的:(sh)