Search in sources :

Example 1 with RTopic

use of com.xrtb.jmq.RTopic in project XRTB by benmfaul.

the class Spark method initialize.

/**
	 * Get the message handlers lashed up to handle all the accounting
	 * information.
	 */
public void initialize() throws Exception {
    // Instantiate your own logger if you
    logger = new FileLogger(INTERVAL);
    // don't want to log to files.
    /**
		 * Win Notifications HERE
		 */
    String address = getAddress(zeromq, WINCHANNEL);
    RTopic winners = new RTopic(address);
    winners.addListener(new MessageListener<WinObject>() {

        @Override
        public void onMessage(String channel, WinObject msg) {
            try {
                processWin(msg);
            } catch (Exception error) {
                error.printStackTrace();
            }
        }
    });
    System.out.println("Ok Spark is running!");
    address = getAddress(zeromq, BIDCHANNEL);
    RTopic bidresponse = new RTopic(address);
    bidresponse.addListener(new MessageListener<BidResponse>() {

        @Override
        public void onMessage(String channel, BidResponse msg) {
            try {
                processBid(msg);
            } catch (Exception error) {
                error.printStackTrace();
            }
        }
    });
    address = getAddress(zeromq, CLICKCHANNEL);
    RTopic pixelandclicks = new RTopic(address);
    pixelandclicks.addListener(new MessageListener<Object>() {

        @Override
        public void onMessage(String channel, Object msg) {
            try {
                processClickAndPixel(msg);
            } catch (Exception error) {
                error.printStackTrace();
            }
        }
    });
}
Also used : DataBaseObject(com.xrtb.db.DataBaseObject) WinObject(com.xrtb.pojo.WinObject) WinObject(com.xrtb.pojo.WinObject) RTopic(com.xrtb.jmq.RTopic) BidResponse(com.xrtb.pojo.BidResponse)

Example 2 with RTopic

use of com.xrtb.jmq.RTopic in project XRTB by benmfaul.

the class TestValidBids method testSetup.

@BeforeClass
public static void testSetup() {
    try {
        Config.setup();
        Config.setup();
        System.out.println("******************  TestValidBids");
        RTopic bids = new RTopic("tcp://*:5571&bids");
        bids.addListener(new MessageListener<BidResponse>() {

            @Override
            public void onMessage(String channel, BidResponse br) {
                // System.out.println("<<<<<<<<<<<<<<<<<" + br);
                response = br;
                if (latch == null)
                    return;
                latch.countDown();
            }
        });
    } catch (Exception error) {
        error.printStackTrace();
    }
}
Also used : RTopic(com.xrtb.jmq.RTopic) BidResponse(com.xrtb.pojo.BidResponse) BeforeClass(org.junit.BeforeClass)

Aggregations

RTopic (com.xrtb.jmq.RTopic)2 BidResponse (com.xrtb.pojo.BidResponse)2 DataBaseObject (com.xrtb.db.DataBaseObject)1 WinObject (com.xrtb.pojo.WinObject)1 BeforeClass (org.junit.BeforeClass)1