Example usage for javax.jms TextMessage setBooleanProperty

List of usage examples for javax.jms TextMessage setBooleanProperty

Introduction

In this page you can find the example usage for javax.jms TextMessage setBooleanProperty.

Prototype


void setBooleanProperty(String name, boolean value) throws JMSException;

Source Link

Document

Sets a boolean property value with the specified name into the message.

Usage

From source file:de.adorsys.jmspojo.JMSMessageListenerServiceAdapterTest.java

@Test
public void testCreateAdapterWithHeaders() throws JMSException {
    TextMessage textMessage = queueSession.createTextMessage(OBJECT_MAPPER.serialize(new PingMessage("ping")));
    textMessage.setJMSReplyTo(reqlayQ);//from w ww  .jav a  2 s  .co  m
    textMessage.setBooleanProperty("testHeader", true);

    SampleMessageServiceWithHeaders service = new SampleMessageServiceWithHeaders();
    JMSMessageListenerServiceAdapter<SampleMessageServiceWithHeaders> adapter = JMSMessageListenerServiceAdapter
            .createAdapter(service, cf, OBJECT_MAPPER);
    adapter.onMessage(textMessage);

    TextMessage message = (TextMessage) queueSession.createReceiver(reqlayQ).receive(1000);
    assertNotNull(message);
    assertNull(message.getStringProperty("ERROR"));
    assertNull(message.getText());
}

From source file:eu.learnpad.simulator.mon.manager.GlimpseManager.java

private TextMessage createMessage(String msg, String sender) {
    try {//from ww w  .  ja v  a 2s  .  co m
        TextMessage sendMessage = publishSession.createTextMessage();
        sendMessage.setText(msg);
        sendMessage.setStringProperty("DESTINATION", sender);
        sendMessage.setBooleanProperty("ISASCORE", false);
        return sendMessage;
    } catch (JMSException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:org.apache.activemq.usecases.RequestReplyToTopicViaThreeNetworkHopsTest.java

public void testMessages(Session sess, MessageProducer req_prod, Destination resp_dest, int num_msg)
        throws Exception {
    MessageConsumer resp_cons;//w  w w.ja  v  a2 s  .  c o m
    TextMessage msg;
    MessageClient cons_client;
    int cur;
    int tot_expected;

    resp_cons = sess.createConsumer(resp_dest);

    cons_client = new MessageClient(resp_cons, num_msg);
    cons_client.start();

    cur = 0;
    while ((cur < num_msg) && (!fatalTestError)) {
        msg = sess.createTextMessage("MSG AAAA " + cur);
        msg.setIntProperty("SEQ", 100 + cur);
        msg.setStringProperty("TEST", "TOPO");
        msg.setJMSReplyTo(resp_dest);

        if (cur == (num_msg - 1))
            msg.setBooleanProperty("end-of-response", true);

        sendWithRetryOnDeletedDest(req_prod, msg);
        LOG.debug("Sent:" + msg);

        cur++;
    }

    //
    // Give the consumer some time to receive the response.
    //
    cons_client.waitShutdown(5000);

    //
    // Now shutdown the consumer if it's still running.
    //
    if (cons_client.shutdown())
        LOG.debug("Consumer client shutdown complete");
    else
        LOG.debug("Consumer client shutdown incomplete!!!");

    //
    // Check that the correct number of messages was received.
    //
    tot_expected = num_msg * (echoResponseFill + 1);

    if (cons_client.getNumMsgReceived() == tot_expected) {
        LOG.debug("Have " + tot_expected + " messages, as-expected");
    } else {
        testError = true;

        if (cons_client.getNumMsgReceived() == 0)
            fatalTestError = true;

        LOG.error("Have " + cons_client.getNumMsgReceived() + " messages; expected " + tot_expected
                + " on destination " + resp_dest);
    }

    resp_cons.close();
}

From source file:org.apache.qpid.multiconsumer.AMQTest.java

public void testCompression() throws Exception {
    setup();/*from w  ww  .java 2  s  . c o  m*/
    String comp = this.compressString(HUGECONTENT);
    try {
        MsgHandler listener = new MsgHandler();
        MessageConsumer subscriber = subSession.createConsumer(topic);
        subscriber.setMessageListener(listener);
        MessageProducer publisher = pubSession.createProducer(topic);

        // Send a single message
        TextMessage msg = pubSession.createTextMessage();
        // Set the compressed text
        msg.setText(comp);
        msg.setBooleanProperty(COMPRESSION_PROPNAME, true);
        publisher.send(msg);
        Thread.sleep(1000);
        // Check listeners to ensure we got it
        if (listener.isGotIt()) {
            System.out.println("Got callback for listener");
        } else {
            TestCase.fail("Listener did not get callback");
        }
    } finally {
        close();
    }
}

From source file:org.codehaus.stomp.StompTest.java

public void testSubscribeWithMessageSentWithProperties() throws Exception {

    String frame = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
    sendFrame(frame);/*from  w  w  w  .  j  av a 2s  .c  o  m*/

    frame = receiveFrame(100000);
    Assert.assertTrue(frame.startsWith("CONNECTED"));

    frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "ack:auto\n\n" + Stomp.NULL;
    sendFrame(frame);

    MessageProducer producer = session.createProducer(queue);
    TextMessage message = session.createTextMessage("Hello World");
    message.setStringProperty("s", "value");
    message.setBooleanProperty("n", false);
    message.setByteProperty("byte", (byte) 9);
    message.setDoubleProperty("d", 2.0);
    message.setFloatProperty("f", (float) 6.0);
    message.setIntProperty("i", 10);
    message.setLongProperty("l", 121);
    message.setShortProperty("s", (short) 12);
    producer.send(message);

    frame = receiveFrame(10000);
    Assert.assertTrue(frame.startsWith("MESSAGE"));

    //        System.out.println("out: "+frame);

    frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
    sendFrame(frame);
}

From source file:org.openanzo.combus.endpoint.BaseServiceListener.java

private TextMessage sendJMSErrorMessage(Destination replyTo, Message request, Throwable jmex, long errorCode,
        String... args) throws JMSException {
    try {//ww  w. j av a2  s .  com
        if (replyTo != null) {
            if (log.isWarnEnabled()) {
                log.warn(LogUtils.COMBUS_MARKER,
                        "Exception while ServiceListener [" + name + "] was precessing request.", jmex);

            }
            String message = null;
            if (jmex instanceof AnzoException) {
                message = ((AnzoException) jmex).getMessage(false);
            } else if (jmex instanceof AnzoRuntimeException) {
                message = ((AnzoRuntimeException) jmex).getMessage(false);
            } else {
                message = jmex.getMessage();
            }
            TextMessage response = session.createTextMessage(message);
            response.setJMSCorrelationID(request.getJMSCorrelationID());
            response.setBooleanProperty(SerializationConstants.operationFailed, true);
            response.setLongProperty(SerializationConstants.errorTags, 0);
            response.setLongProperty(SerializationConstants.errorCode, errorCode);
            response.setIntProperty(SerializationConstants.protocolVersion, Constants.VERSION);
            // send a single arg string for compat. with older readers
            response.setStringProperty(SerializationConstants.errorMessageArg, Arrays.toString(args));

            // send the individual error args for readers that can make use of them
            for (int i = 0; i < args.length; i++) {
                response.setStringProperty(SerializationConstants.errorMessageArg + i, args[i]);
            }

            // we log all JMS messages, even errors.
            if (log.isDebugEnabled()) {
                log.debug(LogUtils.COMBUS_MARKER,
                        MessageUtils.prettyPrint(response, "Sending Response to " + replyTo));
            }
            mp.send(replyTo, response);
            return response;
        }
    } catch (JMSException jmsex) {
        log.debug(LogUtils.COMBUS_MARKER, "Error sending error message to client", jmsex);
    }
    return null;
}