Package com.rabbitmq.client.AMQP

Examples of com.rabbitmq.client.AMQP.BasicProperties


   */
  public static BasicProperties getBasicProperties() {
    if (isDurable() == false) {
      return null;
    }
    BasicProperties b = MessageProperties.PERSISTENT_TEXT_PLAIN;
    return b;
  }
View Full Code Here


      channel.basicConsume(RPC_QUEUE_NAME, false, consumer);
      System.out.println(" [x] Awaiting RPC requests");
      while (true) {
        String response = null;
        QueueingConsumer.Delivery delivery = consumer.nextDelivery();
        BasicProperties props = delivery.getProperties();
        BasicProperties replyProps = new BasicProperties.Builder()
            .correlationId(props.getCorrelationId()).build();
        try {
          String message = new String(delivery.getBody(), "UTF-8");
          int n = Integer.parseInt(message);
          System.out.println(" [.] fib(" + message + ")");
View Full Code Here

  }

  public String call(String message) throws Exception {
    String response = null;
    String corrId = UUID.randomUUID().toString();
    BasicProperties props = new BasicProperties.Builder()
        .correlationId(corrId).replyTo(replyQueueName).build();
    channel.basicPublish("", requestQueueName, props, message.getBytes());
    while (true) {
      QueueingConsumer.Delivery delivery = consumer.nextDelivery();
      if (delivery.getProperties().getCorrelationId().equals(corrId)) {
View Full Code Here

        }
    }

    protected BasicProperties colorForward(BasicProperties orgProps, final Operation op) {
        Field headersField = getMessageHeadersField();
        BasicProperties props = orgProps;
        if (headersField == null) {
            return props;
        }

        try {
            final Map<String, Object> map = new HashMap<String, Object>();
            Map<String, Object> old = (props != null) ? props.getHeaders() : null;
            if (MapUtil.size(old) > 0) {
                map.putAll(old);
            }

            colorForward(new ColorParams() {
View Full Code Here

    public void testHandleDelivery() throws IOException {
        MockConsumer consumer = new MockConsumer();

        String consumerTag = "1";
        Envelope envelope = new Envelope(1l, false, "exchange", "routingKey");
        BasicProperties props = create();
        byte[] body = new byte[25];
        assertTrue(RabbitMQConsumerCollectionAspect.opHolder.isEmpty());
        consumer.handleDelivery(consumerTag, envelope, props, body);
        assertTrue(RabbitMQConsumerCollectionAspect.opHolder.isEmpty());
        assertOperation(envelope, props, body, AbstractRabbitMQResourceAnalyzer.RABBIT + "-" + RabbitMQConsumerCollectionAspect.LABEL_PREFIX + "null (exchange#routingKey)");
View Full Code Here

    @Test
    public void testBasicGet() throws IOException {

        Envelope envelope = new Envelope(1l, false, "exchange", "routingKey");
        BasicProperties props = create();
        byte[] body = new byte[25];

        MockChannel channel = new MockChannel(envelope, props, body);
        assertTrue(RabbitMQConsumerCollectionAspect.opHolder.isEmpty());
        channel.basicGet("rk", false);
View Full Code Here

        String exchange = "exchange";
        String routingKey = "routingKey";
        boolean mandatory = false;
        boolean immediate = false;
        BasicProperties props = create();
        byte[] body = new byte[25];

        MockChannel channel = new MockChannel();

        channel.basicPublish(exchange, routingKey, mandatory, immediate, props, body);
View Full Code Here

        fieldArray.add(123);
        table.put("A", fieldArray);
        //roundtrip of content headers
        AMQP.Queue.DeclareOk ok = channel.queueDeclare();
        String q = ok.getQueue();
        BasicProperties props = new BasicProperties(null, null, table, null,
                                                    null, null, null, null,
                                                    null, null, null, null,
                                                    null, null);
        channel.basicPublish("", q, props, "".getBytes());
        BasicProperties rProps = channel.basicGet(q, true).getProps();
        assertMapsEqual(props.getHeaders(), rProps.getHeaders());

        //sending as part of method arguments - we are relying on
        //exchange.declare ignoring the arguments table.
        channel.exchangeDeclare("x", "direct", false, false, table);
        channel.exchangeDelete("x");
View Full Code Here

  public void serveRequests() {
    while (true) {
      try {

        Delivery delivery = consumer.nextDelivery();
        BasicProperties props = delivery.getProperties();

        channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
        System.out.println(
          "Received API call...replying..."
        );

        channel.basicPublish(
          "",
          props.getReplyTo(),
          null,
          getResponse(delivery).getBytes("UTF-8")
        );

      } catch (Exception e){
View Full Code Here

                //  Get next request
                QueueingConsumer.Delivery delivery = consumer.nextDelivery();
                String replyTo = delivery.getProperties().getReplyTo();
                String correlationId = delivery.getProperties().getCorrelationId();

                BasicProperties props =
                  (BasicProperties) (delivery.getProperties().clone());
                // We must set the correlation ID, because it is used
                // by AMQP and 0MQ clients for correlating replies
                props.setReplyTo(null);
                System.err.println("processing request");

                //  Send the reply
                channel.basicPublish("", replyTo, props, "World!".getBytes());
            }
View Full Code Here

TOP

Related Classes of com.rabbitmq.client.AMQP.BasicProperties

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.