Java Code Examples for javax.jms.MapMessage#setObjectProperty()

The following examples show how to use javax.jms.MapMessage#setObjectProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AmqpManagementTest.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
@Test
public void testCreateQueueOnBrokerManagement() throws Exception
{
    assumeThat(isSupportedClient(), is(true));

    Connection connection = getBrokerManagementConnection();
    try
    {
        setUp(connection);

        MapMessage message = _session.createMapMessage();

        message.setStringProperty("type", "org.apache.qpid.Queue");
        message.setStringProperty("operation", "CREATE");
        message.setString("name", getTestName());
        message.setLong(ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, 100L);
        String path = getVirtualHostName() + "/" + getVirtualHostName() + "/" + getTestName();
        message.setString("object-path", path);
        message.setJMSReplyTo(_replyAddress);
        _producer.send(message);

        Message responseMessage = _consumer.receive(getReceiveTimeout());
        assertResponseCode(responseMessage, 201);
        checkResponseIsMapType(responseMessage);
        assertEquals("The created queue was not a standard queue",
                     "org.apache.qpid.StandardQueue",
                     getValueFromMapResponse(responseMessage, "type"));
        assertEquals("The created queue was not a standard queue",
                     "standard",
                     getValueFromMapResponse(responseMessage, "qpid-type"));
        assertEquals("the created queue did not have the correct alerting threshold",
                     100L,
                     getValueFromMapResponse(responseMessage, ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES));
        Object identity = getValueFromMapResponse(responseMessage, "identity");

        message = _session.createMapMessage();

        message.setStringProperty("type", "org.apache.qpid.Queue");
        message.setStringProperty("operation", "UPDATE");
        message.setObjectProperty("identity", identity);
        message.setLong(ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, 250L);

        message.setJMSReplyTo(_replyAddress);
        _producer.send(message);

        responseMessage = _consumer.receive(getReceiveTimeout());
        assertResponseCode(responseMessage, 200);
        checkResponseIsMapType(responseMessage);
        assertEquals("the created queue did not have the correct alerting threshold",
                     250L,
                     getValueFromMapResponse(responseMessage, ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES));

        message = _session.createMapMessage();

        message.setStringProperty("type", "org.apache.qpid.Queue");
        message.setStringProperty("operation", "DELETE");
        message.setObjectProperty("index", "object-path");
        message.setObjectProperty("key", path);

        message.setJMSReplyTo(_replyAddress);
        _producer.send(message);

        responseMessage = _consumer.receive(getReceiveTimeout());
        assertResponseCode(responseMessage, 204);

        message = _session.createMapMessage();

        message.setStringProperty("type", "org.apache.qpid.Queue");
        message.setStringProperty("operation", "READ");
        message.setObjectProperty("identity", identity);

        message.setJMSReplyTo(_replyAddress);
        _producer.send(message);

        responseMessage = _consumer.receive(getReceiveTimeout());
        assertResponseCode(responseMessage, 404);
    }
    finally
    {
        connection.close();
    }
}