Package com.trendmicro.mist

Examples of com.trendmicro.mist.Client


        synchronized(allClients) {
            // Check if the client is already mounted, if not, add to the map
            if(allClients.containsKey(new Exchange(clientConfig.getChannel().getName())))
                throw new MistException(MistException.ALREADY_MOUNTED);

            Client c = new Client(clientConfig, sessionConfig);
            if(isAttached()){
                c.openClient(determinedConnection, false, false);
                addClientIfAttached(c);
            }
            allClients.put(c.getExchange(), c);
            return c;
        }
    }
View Full Code Here


        synchronized(allClients) {
            if(allClients.isEmpty())
                throw new MistException(MistException.EMPTY_SESSION);

            Exchange exchange = new Exchange((clientConfig.getChannel().getType() == GateTalk.Channel.Type.QUEUE ? "queue": "topic") + ":" + clientConfig.getChannel().getName());
            Client c = findClient(exchange);
            if(c == null)
                throw new MistException(MistException.exchangeNotFound(exchange.toString()));
            c.closeClient(false, false);
            allClients.remove(exchange);
        }
    }
View Full Code Here

        GateTalk.Client client_config = cl_builder.build();

        if(!Exchange.isValidExchange(client_config.getChannel().getName()))
            throw new MistException(String.format("exchange `%s' not valid", client_config.getChannel().getName()));

        Client client = null;
        try {
            client = addClient(client_config);
            logger.info(String.format("session %d: create exchange `%s:%s'", sessionId, client.isQueue() ? "queue": "topic", client.getChannelName()));
        }
        catch(MistException e) {
            logger.error(e.getMessage());
            throw e;
        }
View Full Code Here

            if(dest.getName().length() == 0)
                continue;

            while(retryDeliver) {
                try {
                    Client c = null;
                    synchronized(allClients) {
                        c = findClient(dest);
                        if(c == null || c.getProducer() == null)
                            c = mountAndAddProducer(dest);
                    }
                    c.getProducer().setTimeToLive(ttl);
                    if(props != null)
                        c.sendMessageBytes(msg, props);
                    else
                        c.sendMessageBytes(msg);

                    ExchangeMetric metric = ExchangeMetric.getExchangeMetric(dest);
                    metric.increaseMessageOut(msg.length);
                    break;
                }
View Full Code Here

        /**
         * Test add normal a queue client and open
         */
        GateTalk.Client clientConfig = genClientConfig("foo.out", true, true);
        Client c = sess.addClient(clientConfig);
        assertEquals(clientConfig, sess.findClient(new Exchange("queue:foo.out")).getConfig());
        sess.open(false);
        MessageProducer producer = sess.findClient(new Exchange("queue:foo.out")).getProducer();
        assertNotNull(producer);

        /**
         * Deliver a message
         */
        BytesMessage msg = c.getJMSSession().createBytesMessage();
        msg.writeBytes("test".getBytes());
        producer.send(msg);
        assertEquals("test", new String(brk.getMessage(true, "foo.out")));

        /**
         * Test add another queue client
         */
        clientConfig = genClientConfig("bar.out", true, true);
        c = sess.addClient(clientConfig);
        assertEquals(clientConfig, sess.findClient(new Exchange("queue:bar.out")).getConfig());
        sess.open(false);
        producer = sess.findClient(new Exchange("queue:bar.out")).getProducer();
        assertNotNull(producer);

        msg = c.getJMSSession().createBytesMessage();
        msg.writeBytes("test_bar".getBytes());
        producer.send(msg);
        assertEquals("test_bar", new String(brk.getMessage(true, "bar.out")));

        brk.stop();
View Full Code Here

TOP

Related Classes of com.trendmicro.mist.Client

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.