Search in sources :

Example 81 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class PropertyConverter_v0_8_to_InternalTest method testApplicationIdConversion.

public void testApplicationIdConversion() {
    final String applicationId = "appId";
    BasicContentHeaderProperties header = new BasicContentHeaderProperties();
    header.setAppId(applicationId);
    final AMQMessage originalMessage = createTestMessage(header);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertEquals("Unexpected applicationId", applicationId, convertedMessage.getMessageHeader().getAppId());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 82 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class PropertyConverter_v0_8_to_InternalTest method testDeliveryModePersistentConversion.

public void testDeliveryModePersistentConversion() {
    BasicContentHeaderProperties header = new BasicContentHeaderProperties();
    header.setDeliveryMode(BasicContentHeaderProperties.PERSISTENT);
    final AMQMessage originalMessage = createTestMessage(header);
    InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
    assertTrue("Unexpected persistence of message", convertedMessage.isPersistent());
    assertTrue("Unexpected persistence of meta data", convertedMessage.getStoredMessage().getMetaData().isPersistent());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)

Example 83 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class ManagementNode method sendResponse.

private void sendResponse(final InternalMessage message, final InternalMessage response) {
    String replyTo = message.getMessageHeader().getReplyTo();
    response.setInitialRoutingAddress(replyTo);
    final MessageDestination responseDestination = getResponseDestination(replyTo);
    RoutingResult<InternalMessage> result = responseDestination.route(response, replyTo, InstanceProperties.EMPTY);
    result.send(new AutoCommitTransaction(_addressSpace.getMessageStore()), null);
}
Also used : AutoCommitTransaction(org.apache.qpid.server.txn.AutoCommitTransaction) MessageDestination(org.apache.qpid.server.message.MessageDestination) InternalMessage(org.apache.qpid.server.message.internal.InternalMessage)

Example 84 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class ManagementNode method processRequest.

private synchronized void processRequest(InternalMessage message) {
    String id = (String) message.getMessageHeader().getHeader(IDENTITY_ATTRIBUTE);
    String type = (String) message.getMessageHeader().getHeader(TYPE_ATTRIBUTE);
    String operation = (String) message.getMessageHeader().getHeader(OPERATION_HEADER);
    LOGGER.debug("Management Node identity: {}, type: {}, operation {}", id, type, operation);
    InternalMessage response;
    if (SELF_NODE_NAME.equals(id) && type.equals(MANAGEMENT_TYPE)) {
        response = performManagementOperation(operation, message);
    } else if (_managedTypes.containsKey(type)) {
        response = performOperation(_managedTypes.get(type), operation, message);
    } else {
        response = createFailureResponse(message, STATUS_CODE_NOT_FOUND, "Unknown type {0}", type);
    }
    sendResponse(message, response);
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage)

Example 85 with InternalMessage

use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.

the class ManagementNode method enqueue.

@Override
public void enqueue(final ServerMessage message, final Action<? super MessageInstance> action, final MessageEnqueueRecord record) {
    @SuppressWarnings("unchecked") MessageConverter<ServerMessage, InternalMessage> converter = (MessageConverter<ServerMessage, InternalMessage>) MessageConverterRegistry.getConverter((message.getClass()), InternalMessage.class);
    final InternalMessage msg = converter.convert(message, _addressSpace);
    try {
        if (action != null) {
            action.performAction(new ConsumedMessageInstance(msg));
        }
        processRequest(msg);
    } finally {
        converter.dispose(msg);
    }
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) ServerMessage(org.apache.qpid.server.message.ServerMessage) MessageConverter(org.apache.qpid.server.plugin.MessageConverter)

Aggregations

InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)185 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)60 Matchers.anyString (org.mockito.Matchers.anyString)45 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)36 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)25 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)24 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)23 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)18 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)18 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)17 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)15 HashMap (java.util.HashMap)13 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)12 ReplyTo (org.apache.qpid.server.protocol.v0_10.transport.ReplyTo)9 UUID (java.util.UUID)8 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)8 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)7 Map (java.util.Map)6 Exchange (org.apache.qpid.server.model.Exchange)6 ArrayList (java.util.ArrayList)5