Package com.rabbitmq.client

Examples of com.rabbitmq.client.Channel.basicPublish()


        @Override
        public void run() {
            try {
                while (true) {
                    Channel ch = conn.createChannel();
                    ch.basicPublish(EXCHANGE, ROUTING_KEY, null, new byte[1024 * 1024]);
                    ch.basicGet(QUEUE, true);
                    ch.close();
                }
            } catch (Exception e) {
                synchronized (outputSync) {
View Full Code Here


    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put("filename", filename);
    headers.put("length", (int) f.length());
    BasicProperties props = new BasicProperties.Builder().headers(headers).build();
    ch.basicPublish(exchange, routingKey, props, body);
    System.out.println(" done.");
      }

      conn.close();
        } catch (Exception ex) {
View Full Code Here

            int thisTimeCount = 0;
            int allTimeCount = 0;
            long startTime = System.currentTimeMillis();
            long nextSummaryTime = startTime;
            while (true) {
                ch.basicPublish(exchange, topicPrefix + newSuffix(), null, message.getBytes());
                thisTimeCount++;
                allTimeCount++;
                long now = System.currentTimeMillis();
                if (now > nextSummaryTime) {
                    int thisTimeRate = (int)(1.0 * thisTimeCount / (now - nextSummaryTime + SUMMARISE_EVERY) * SUMMARISE_EVERY);
 
View Full Code Here

                ch.queueDeclare(QUEUE_NAME, true, false, false, null);
                ch.confirmSelect();

                // Publish
                for (long i = 0; i < msgCount; ++i) {
                    ch.basicPublish("", QUEUE_NAME,
                                    MessageProperties.PERSISTENT_BASIC,
                                    "nop".getBytes());
                }

                ch.waitForConfirmsOrDie();
View Full Code Here

                            final Channel localChannel = connection.createChannel();
                            if (transactional) {
                                localChannel.txSelect();
                            }
                            for (int j = 0; j < COMMIT_SIZE; j++) {
                                localChannel.basicPublish("", queueName, null, ("message" + t).getBytes("UTF-8"));
                            }
                            if (transactional) {
                                localChannel.txCommit();
                            }
                            localChannel.close();
View Full Code Here

                @Override
                public void run() {
                    try {
                        for (int t = 0; t < COMMIT_COUNT; t++) {
                            for (int j = 0; j < COMMIT_SIZE; j++) {
                                localChannel.basicPublish("", queueName, null, ("message" + t).getBytes("UTF-8"));
                            }
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
View Full Code Here

                            if (localChannel == null) {
                                localChannel = connection.createChannel();
                            }
                            localChannel.txSelect();
                            for (int j = 0; j < COMMIT_SIZE; j++) {
                                localChannel.basicPublish("", queueName, null, ("message" + t).getBytes("UTF-8"));
                            }
                            localChannel.txCommit();
                            if (!channels.offer(localChannel)) {
                                localChannel.close();
                            }
View Full Code Here

     */
    public void publishMessage(byte[] message, BasicProperties props)
            throws IOException {
        Channel channel = channel();
        channel.exchangeDeclare(exchange, "direct", true);
        channel.basicPublish(exchange, routingKey, props, message);
    }
}
View Full Code Here

    }
   
    private void sendTestMessage() throws IOException, InterruptedException {
        Channel producerChannel = connectionFactory.newConnection().createChannel();
        producerChannel.confirmSelect();
        producerChannel.basicPublish("", TestBrokerSetup.TEST_QUEUE, new BasicProperties.Builder().build(), "test".getBytes("UTF-8"));
        producerChannel.waitForConfirmsOrDie();
        brokerAssert.queueNotEmtpy(TestBrokerSetup.TEST_QUEUE);
    }
   
    private class NackingConsumer extends MessageConsumer {
View Full Code Here

        channel.exchangeDeclare(TEST_EXCHANGE, "topic");
        brokerSetup.declareAndBindQueue(TEST_QUEUE, TEST_EXCHANGE, routingKey);
        channel.queueDeclarePassive(TEST_QUEUE);
       
        String body = "test.body";
        channel.basicPublish(TEST_EXCHANGE, routingKey, new BasicProperties(), body.getBytes());
       
        GetResponse response = channel.basicGet(TEST_QUEUE, true);
        Assert.assertNotNull("no message in queue", response);
        Assert.assertEquals("wrong message in queue", new String(response.getBody(), "UTF-8"), body);
       
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.